mirror of
https://github.com/i701/sarlink-portal-api.git
synced 2025-10-06 01:55:24 +00:00
feat(verification): handle user verification not found scenario and mark user as verified ✨
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 3m0s
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 3m0s
This commit is contained in:
10
api/views.py
10
api/views.py
@@ -414,6 +414,16 @@ class UserVerifyAPIView(StaffEditorPermissionMixin, generics.UpdateAPIView):
|
||||
serializer = self.get_serializer(user, data=request.data, partial=True)
|
||||
serializer.is_valid(raise_exception=True)
|
||||
result = check_person_api_verification(user_data=user, id_card=user.id_card)
|
||||
# The verification system might not have the records of every user hence can be skipped if not found and verify directly.
|
||||
if result.get("error") == "Not Found":
|
||||
user.verified = True
|
||||
user.save()
|
||||
return Response(
|
||||
{
|
||||
"message": "User not found in the verification system. User marked as verified."
|
||||
},
|
||||
status=status.HTTP_404_NOT_FOUND,
|
||||
)
|
||||
if not result["ok"]:
|
||||
return Response(
|
||||
result,
|
||||
|
@@ -364,6 +364,30 @@ class ListCreateTopupView(StaffEditorPermissionMixin, generics.ListCreateAPIView
|
||||
return queryset
|
||||
return queryset.filter(user=self.request.user)
|
||||
|
||||
def list(self, request, *args, **kwargs):
|
||||
queryset = self.filter_queryset(self.get_queryset())
|
||||
all_topups = request.query_params.get("all_topups", "false").lower() in [
|
||||
"true",
|
||||
"1",
|
||||
"yes",
|
||||
]
|
||||
if (
|
||||
request.user.is_authenticated
|
||||
and getattr(request.user, "is_admin")
|
||||
and bool(all_topups)
|
||||
):
|
||||
pass
|
||||
else:
|
||||
queryset = queryset.filter(user=request.user)
|
||||
|
||||
page = self.paginate_queryset(queryset)
|
||||
if page is not None:
|
||||
serializer = self.get_serializer(page, many=True)
|
||||
return self.get_paginated_response(serializer.data)
|
||||
|
||||
serializer = self.get_serializer(queryset, many=True)
|
||||
return Response(serializer.data)
|
||||
|
||||
|
||||
class TopupDetailAPIView(StaffEditorPermissionMixin, generics.RetrieveAPIView):
|
||||
queryset = Topup.objects.all()
|
||||
|
Reference in New Issue
Block a user