mirror of
https://github.com/i701/sarlink-portal-api.git
synced 2025-04-19 23:46:53 +00:00
Fixed person api checking with database user for verification
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 4m15s
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 4m15s
This commit is contained in:
parent
ba0fa5a831
commit
1401c3ac37
@ -4,7 +4,6 @@ from api.models import User, Atoll, Island, TemporaryUser
|
|||||||
from django.contrib.auth.models import Permission
|
from django.contrib.auth.models import Permission
|
||||||
|
|
||||||
|
|
||||||
# Define a new User admin
|
|
||||||
class UserAdmin(BaseUserAdmin):
|
class UserAdmin(BaseUserAdmin):
|
||||||
list_display = (
|
list_display = (
|
||||||
"username",
|
"username",
|
||||||
@ -24,7 +23,7 @@ class UserAdmin(BaseUserAdmin):
|
|||||||
"island",
|
"island",
|
||||||
"terms_accepted",
|
"terms_accepted",
|
||||||
"policy_accepted",
|
"policy_accepted",
|
||||||
) # Add custom fields here
|
)
|
||||||
|
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
(None, {"fields": ("username", "password")}),
|
(None, {"fields": ("username", "password")}),
|
||||||
@ -48,7 +47,7 @@ class UserAdmin(BaseUserAdmin):
|
|||||||
"policy_accepted",
|
"policy_accepted",
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
), # Add custom fields here
|
),
|
||||||
(
|
(
|
||||||
"Permissions",
|
"Permissions",
|
||||||
{
|
{
|
||||||
@ -97,7 +96,6 @@ class TemporaryUserAdmin(admin.ModelAdmin):
|
|||||||
"t_address",
|
"t_address",
|
||||||
"t_verified",
|
"t_verified",
|
||||||
"otp_verified",
|
"otp_verified",
|
||||||
"otp_expiry",
|
|
||||||
"t_wallet_balance",
|
"t_wallet_balance",
|
||||||
"t_acc_no",
|
"t_acc_no",
|
||||||
"t_id_card",
|
"t_id_card",
|
||||||
@ -110,6 +108,7 @@ class TemporaryUserAdmin(admin.ModelAdmin):
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
search_fields = ("t_username", "t_email", "t_mobile", "t_id_card")
|
||||||
|
|
||||||
|
|
||||||
# Re-register UserAdmin
|
# Re-register UserAdmin
|
||||||
|
22
api/tasks.py
22
api/tasks.py
@ -20,13 +20,29 @@ def verify_user_with_person_api_task(user_id: int):
|
|||||||
response = requests.get(f"{PERSON_API_URL}/api/person/{user.id_card}")
|
response = requests.get(f"{PERSON_API_URL}/api/person/{user.id_card}")
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
data = response.json()
|
data = response.json()
|
||||||
print(f"Data from Person API: {data}")
|
api_nic = data.get("nic")
|
||||||
print("Data from of user: ", user.__dict__)
|
api_name = data.get("name_en")
|
||||||
|
api_house_name = data.get("house_name_en")
|
||||||
|
api_dob = data.get("dob")
|
||||||
|
print(f"API nic: {api_nic}")
|
||||||
|
print(f"API name: {api_name}")
|
||||||
|
print(f"API house name: {api_house_name}")
|
||||||
|
print(f"API dob: {api_dob}")
|
||||||
|
|
||||||
|
user_nic = user.id_card
|
||||||
|
user_name = f"{user.first_name} {user.last_name}"
|
||||||
|
user_house_name = user.address
|
||||||
|
user_dob = user.dob.isoformat()
|
||||||
|
|
||||||
|
print(f"User nic: {user_nic}")
|
||||||
|
print(f"User name: {user_name}")
|
||||||
|
print(f"User house name: {user_house_name}")
|
||||||
|
print(f"User dob: {user_dob}")
|
||||||
if (
|
if (
|
||||||
data.get("nic") == user.id_card
|
data.get("nic") == user.id_card
|
||||||
and data.get("name_en") == f"{user.first_name} {user.last_name}"
|
and data.get("name_en") == f"{user.first_name} {user.last_name}"
|
||||||
and data.get("house_name_en") == user.address
|
and data.get("house_name_en") == user.address
|
||||||
and data.get("dob") == user.dob.isoformat()
|
and data.get("dob").split("T")[0] == user.dob.isoformat()
|
||||||
):
|
):
|
||||||
user.verified = True
|
user.verified = True
|
||||||
user.save()
|
user.save()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user