force update api
This commit is contained in:
@@ -37,6 +37,7 @@ urlpatterns = [
|
||||
views.SoftDeletePrincipalAPIView.as_view(),
|
||||
name="delete_account",
|
||||
),
|
||||
path('version-check/', views.VersionCheck.as_view(), name='version_check'),
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ from django.views.decorators.http import require_http_methods
|
||||
|
||||
# from .authenticate import authticate_with_otp_and_passsword
|
||||
from accounts.models import (
|
||||
AppVersion,
|
||||
IAmPrincipal,
|
||||
IAmPrincipalOtp,
|
||||
IAmPrincipalSource,
|
||||
@@ -933,3 +934,29 @@ class SoftDeletePrincipalAPIView(APIView):
|
||||
message=constants.SUCCESS,
|
||||
data="Account has been successfully deleted.",
|
||||
)
|
||||
|
||||
|
||||
class VersionCheck(APIView):
|
||||
authentication_classes = []
|
||||
permission_classes = []
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
app_version = request.GET.get("appVersion")
|
||||
|
||||
# Query the database to retrieve the upgrade flags based on the app version
|
||||
try:
|
||||
version = AppVersion.objects.get(version=app_version)
|
||||
except AppVersion.DoesNotExist:
|
||||
version = None
|
||||
|
||||
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)
|
||||
|
||||
56
accounts/migrations/0005_appversion.py
Normal file
56
accounts/migrations/0005_appversion.py
Normal file
@@ -0,0 +1,56 @@
|
||||
# Generated by Django 5.0.2 on 2024-03-26 07:05
|
||||
|
||||
import django.core.validators
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("accounts", "0004_alter_iamprincipallocation_latitude_and_more"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name="AppVersion",
|
||||
fields=[
|
||||
(
|
||||
"id",
|
||||
models.BigAutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
verbose_name="ID",
|
||||
),
|
||||
),
|
||||
(
|
||||
"version",
|
||||
models.CharField(
|
||||
max_length=10,
|
||||
validators=[
|
||||
django.core.validators.RegexValidator(
|
||||
"^\\d+\\.\\d+\\.\\d+$"
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
(
|
||||
"force_upgrade",
|
||||
models.BooleanField(
|
||||
default=False,
|
||||
help_text="Indicates whether a force upgrade is needed for this app version.",
|
||||
),
|
||||
),
|
||||
(
|
||||
"recommend_upgrade",
|
||||
models.BooleanField(
|
||||
default=False,
|
||||
help_text="Indicates whether a recommend upgrade is needed for this app version.",
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
"db_table": "app_version",
|
||||
},
|
||||
),
|
||||
]
|
||||
@@ -446,5 +446,26 @@ class IAmPrincipalLocation(BaseModel):
|
||||
# class Meta:
|
||||
# db_table = "iam_principal_kyc_details"
|
||||
|
||||
|
||||
# def __str__(self):
|
||||
# return f"KYC Information for {self.principal.email}"
|
||||
|
||||
|
||||
class AppVersion(models.Model):
|
||||
version = models.CharField(
|
||||
max_length=10, validators=[RegexValidator(r"^\d+\.\d+\.\d+$")]
|
||||
)
|
||||
force_upgrade = models.BooleanField(
|
||||
default=False,
|
||||
help_text="Indicates whether a force upgrade is needed for this app version.",
|
||||
)
|
||||
recommend_upgrade = models.BooleanField(
|
||||
default=False,
|
||||
help_text="Indicates whether a recommend upgrade is needed for this app version.",
|
||||
)
|
||||
|
||||
class Meta:
|
||||
db_table = "app_version"
|
||||
|
||||
def __str__(self):
|
||||
return self.version
|
||||
|
||||
Reference in New Issue
Block a user