Add filter_temporary_user view to retrieve TemporaryUser by id_card or mobile
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 3m32s

This commit is contained in:
i701 2025-04-18 13:39:57 +05:00
parent ac5675e923
commit 887ffbb4d0
Signed by: i701
GPG Key ID: 54A0DA1E26D8E587
2 changed files with 28 additions and 0 deletions

View File

@ -17,6 +17,7 @@ from .views import (
ListCreateIslandView, ListCreateIslandView,
RetrieveUpdateDestroyIslandView, RetrieveUpdateDestroyIslandView,
filter_user, filter_user,
filter_temporary_user,
UpdateUserWalletView, UpdateUserWalletView,
VerifyOTPView, VerifyOTPView,
) )
@ -37,6 +38,7 @@ urlpatterns = [
), ),
path("users/<int:pk>/", UserDetailAPIView.as_view(), name="user-detail"), path("users/<int:pk>/", UserDetailAPIView.as_view(), name="user-detail"),
path("users/filter/", filter_user, name="filter-users"), path("users/filter/", filter_user, name="filter-users"),
path("users/temp/filter/", filter_temporary_user, name="filter-temporary-users"),
path("healthcheck/", healthcheck, name="healthcheck"), path("healthcheck/", healthcheck, name="healthcheck"),
path("test/", test_email, name="testemail"), path("test/", test_email, name="testemail"),
path("atolls/", ListAtollView.as_view(), name="atolls"), path("atolls/", ListAtollView.as_view(), name="atolls"),

View File

@ -341,6 +341,32 @@ def filter_user(request):
) )
@api_view(["GET"])
def filter_temporary_user(request):
id_card = request.GET.get("id_card", "").strip() or None
mobile = request.GET.get("mobile", "").strip() or None
if not id_card and not mobile:
return Response({"ok": False})
filters = Q()
if id_card is not None:
filters |= Q(t_id_card=id_card)
if mobile is not None:
filters |= Q(t_mobile=mobile)
user = TemporaryUser.objects.filter(filters).first()
print(f"Querying with filters: {filters}")
print(f"Found temporary user: {user}")
return Response(
{"ok": True, "otp_verified": user.otp_verified}
if user
else {"ok": False, "otp_verified": False}
)
class ListUserByIDCardView(generics.ListAPIView): class ListUserByIDCardView(generics.ListAPIView):
# Create user API view # Create user API view
permission_classes = (permissions.AllowAny,) permission_classes = (permissions.AllowAny,)