mirror of
https://github.com/i701/sarlink-portal-api.git
synced 2025-04-19 17:36:53 +00:00
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
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 3m32s
This commit is contained in:
parent
ac5675e923
commit
887ffbb4d0
@ -17,6 +17,7 @@ from .views import (
|
||||
ListCreateIslandView,
|
||||
RetrieveUpdateDestroyIslandView,
|
||||
filter_user,
|
||||
filter_temporary_user,
|
||||
UpdateUserWalletView,
|
||||
VerifyOTPView,
|
||||
)
|
||||
@ -37,6 +38,7 @@ urlpatterns = [
|
||||
),
|
||||
path("users/<int:pk>/", UserDetailAPIView.as_view(), name="user-detail"),
|
||||
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("test/", test_email, name="testemail"),
|
||||
path("atolls/", ListAtollView.as_view(), name="atolls"),
|
||||
|
26
api/views.py
26
api/views.py
@ -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):
|
||||
# Create user API view
|
||||
permission_classes = (permissions.AllowAny,)
|
||||
|
Loading…
x
Reference in New Issue
Block a user