From 971f3f6c92304f1537ccddcbeff2bff4954769de Mon Sep 17 00:00:00 2001 From: bobbyvish Date: Tue, 21 May 2024 19:02:26 +0530 Subject: [PATCH] conf(production):structure setting of production server and app verion api --- module_auth/api/urls.py | 1 + module_auth/api/views.py | 6 +++--- module_iam/models.py | 4 ++-- module_project/settings/production.py | 20 +++++++++---------- module_project/wsgi.py | 5 ----- .../module_support/thank_you_support.html | 2 +- 6 files changed, 16 insertions(+), 22 deletions(-) diff --git a/module_auth/api/urls.py b/module_auth/api/urls.py index 1dada83..0fdf38b 100644 --- a/module_auth/api/urls.py +++ b/module_auth/api/urls.py @@ -19,5 +19,6 @@ urlpatterns = [ path('apple-signin/', views.AppleSignin.as_view(), name='apple_signin'), path('version-check/', views.VersionCheck.as_view(), name='version_check'), + path('app-version/', views.VersionCheck.as_view(), name='version_check'), ] diff --git a/module_auth/api/views.py b/module_auth/api/views.py index 5d33a00..fcd68df 100644 --- a/module_auth/api/views.py +++ b/module_auth/api/views.py @@ -374,14 +374,14 @@ class VersionCheck(APIView): model = AppVersion def get(self, request, *args, **kwargs): - app_version = request.GET.get('appVersion') + # app_version = request.GET.get('appVersion') device_type = request.GET.get('deviceType') - if not app_version or not device_type: + if not device_type: return ApiResponse.error(message=constants.FAILURE, errors="App version and device type is required") # Query the database to retrieve the upgrade flags based on the app version try: - version = self.model.objects.get(version=app_version) + version = self.model.objects.filter(device_type=device_type).last() except self.model.DoesNotExist: version = None diff --git a/module_iam/models.py b/module_iam/models.py index 1b16eca..ff7cba1 100644 --- a/module_iam/models.py +++ b/module_iam/models.py @@ -449,10 +449,10 @@ class IAmPrincipalBiometric(BaseModel): class AppVersion(models.Model): DEVICE_CHOICES = [ - ('apple', 'apple'), + ('ios', 'ios'), ('android', 'android'), ] - device_type = models.CharField(max_length=10, choices=DEVICE_CHOICES, verbose_name='Device Type (apple / android)') + device_type = models.CharField(max_length=10, choices=DEVICE_CHOICES, verbose_name='Device Type (ios / android)') version = models.CharField(max_length=5, validators=[RegexValidator(r'^\d+\.\d+\.\d+$')], verbose_name='Version') force_upgrade = models.BooleanField(default=False, verbose_name='Force Upgrade', help_text='Indicates whether a force upgrade is needed for this app version.') recommend_upgrade = models.BooleanField(default=False, verbose_name='Recommend Upgrade', help_text='Indicates whether a recommend upgrade is needed for this app version.') diff --git a/module_project/settings/production.py b/module_project/settings/production.py index 1ab9f5b..e11deca 100644 --- a/module_project/settings/production.py +++ b/module_project/settings/production.py @@ -4,19 +4,18 @@ import os import colorlog from logging.handlers import TimedRotatingFileHandler -DEBUG = False - -ALLOWED_HOSTS = [] +# DEBUG = True +ALLOWED_HOSTS = ["admin.eatwithdigest.com"] # CORS_ALLOWED_ORIGINS = [ -# # "http://127.0.0.1:3000", +# "http://127.0.0.1:3000", # ] -# CORS_ORIGIN_ALLOW_ALL = True +CORS_ORIGIN_ALLOW_ALL = True -# CORS_ORIGIN_WHITELIST = ("",) +# CORS_ORIGIN_WHITELIST = ("http://localhost:3000",) LOGGING_DIR = os.path.join( @@ -29,7 +28,7 @@ if not os.path.exists(LOGGING_DIR): LOGGING_LEVEL = env.str( "LOG_LEVEL", "INFO" -) # Set your desired log level (e.g., DEBUG, INFO, WARNING, ERROR) +) # Set your desired log level (e.g., DEBUG, INFO, WARNING, ERROR) in the env file LOGGING = { @@ -70,8 +69,7 @@ LOGGING = { }, } - -BASE_DOMAIN = "" +BASE_DOMAIN = "https://admin.eatwithdigest.com" # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/4.2/howto/static-files/ @@ -80,8 +78,8 @@ BASE_DOMAIN = "" MEDIA_URL = "/media/" MEDIA_ROOT = os.path.join(BASE_DIR, "media") -# STATIC_ROOT = os.path.join(BASE_DIR, "static") +STATIC_ROOT = os.path.join(BASE_DIR, "static") STATIC_URL = "/static/" -STATICFILES_DIRS = [BASE_DIR.joinpath("static")] +# STATICFILES_DIRS = [BASE_DIR.joinpath("static")] diff --git a/module_project/wsgi.py b/module_project/wsgi.py index 016ce1a..713dee0 100644 --- a/module_project/wsgi.py +++ b/module_project/wsgi.py @@ -8,11 +8,6 @@ https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/ """ import os -import sys - -sys.path.append('/var/www/testing_django/testing') -sys.path.append('/var/www/testing_django/testing/testing') -sys.path.append('/var/www/testing_django/testing/venv/lib/python3.11/site-packages') from django.core.wsgi import get_wsgi_application diff --git a/templates/module_support/thank_you_support.html b/templates/module_support/thank_you_support.html index faa0143..a62686c 100644 --- a/templates/module_support/thank_you_support.html +++ b/templates/module_support/thank_you_support.html @@ -56,7 +56,7 @@

Your Message:

{{ message }}

We will respond to your inquiry as soon as possible.

-

In the meantime, you may find answers to frequently asked questions on our Help Center: [link to Help Center]

+

In the meantime, you may find answers to frequently asked questions on our Help Center: eatwithdigest.com

Sincerely,

The Digest Team