Merge pull request #54 from WDI-Ideas/development

Development
This commit is contained in:
BOBBY VISHWAKARMA
2024-05-23 12:18:26 +05:30
committed by GitHub
7 changed files with 49 additions and 40 deletions

View File

@@ -3,7 +3,7 @@ from django.contrib.auth.hashers import make_password
from rest_framework import serializers
from rest_framework.validators import UniqueValidator
from module_iam.models import IAmPrincipal
from module_iam.models import AppVersion, IAmPrincipal
from module_project import constants
# class BasePasswordSerializer(serializers.Serializer):
@@ -107,3 +107,13 @@ class PasswordResetSerializer(serializers.ModelSerializer):
instance.password = make_password(new_password)
instance.save()
return instance
class AppVersionSerializer(serializers.ModelSerializer):
class Meta:
model = AppVersion
fields = [
"device_type",
"version",
"force_upgrade",
"recommend_upgrade",
]

View File

@@ -15,7 +15,7 @@ from module_project import constants
from module_project.service import EmailService, SMSService
from module_project.utils import ApiResponse
from .serializers import (LoginSerializer, OtpVerificationSerializer,
from .serializers import (AppVersionSerializer, LoginSerializer, OtpVerificationSerializer,
PasswordResetSerializer, RegistrationSerializer)
from .utils import (AuthService, GoogleAuthService,
authticate_with_otp_and_passsword, blacklist_token,
@@ -369,30 +369,18 @@ class AppleSignin(APIView):
class VersionCheck(APIView):
authentication_classes = []
permission_classes = []
authentication_classes = [JWTAuthentication]
permission_classes = [IsAuthenticated]
model = AppVersion
def get(self, request, *args, **kwargs):
app_version = request.GET.get('appVersion')
print("app version is called")
device_type = request.GET.get('deviceType')
if not app_version or not device_type:
return ApiResponse.error(message=constants.FAILURE, errors="App version and device type is required")
if not device_type:
return ApiResponse.error(message=constants.FAILURE, errors="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)
except self.model.DoesNotExist:
version = None
version = self.model.objects.filter(device_type=device_type).last()
version_data = AppVersionSerializer(version)
if version:
upgrade_flags = {
'forceUpgrade': version.force_upgrade,
'recommendUpgrade': version.recommend_upgrade,
}
else:
upgrade_flags = {
'forceUpgrade': False,
'recommendUpgrade': False,
}
return ApiResponse.success(message=constants.SUCCESS, data=upgrade_flags)
return ApiResponse.success(message=constants.SUCCESS, data=version_data.data)

View File

@@ -0,0 +1,18 @@
# Generated by Django 5.0.2 on 2024-05-21 14:09
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('module_iam', '0009_alter_appversion_device_type_and_more'),
]
operations = [
migrations.AlterField(
model_name='appversion',
name='device_type',
field=models.CharField(choices=[('ios', 'ios'), ('android', 'android')], max_length=10, verbose_name='Device Type (ios / android)'),
),
]

View File

@@ -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.')

View File

@@ -5,18 +5,17 @@ import colorlog
from logging.handlers import TimedRotatingFileHandler
DEBUG = False
ALLOWED_HOSTS = []
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")]

View File

@@ -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

View File

@@ -56,7 +56,7 @@
<p><strong>Your Message:</strong></p>
<p>{{ message }}</p>
<p>We will respond to your inquiry as soon as possible.</p>
<p>In the meantime, you may find answers to frequently asked questions on our Help Center: <a href="#">[link to Help Center]</a></p>
<p>In the meantime, you may find answers to frequently asked questions on our Help Center: <a href="https://eatwithdigest.com">eatwithdigest.com</a></p>
<p>Sincerely,</p>
<p>The Digest Team</p>
</div>