mirror of
https://github.com/bspeice/UNCCGameDay-Server
synced 2024-12-04 13:58:14 -05:00
Find a registered user by first and last name
This commit is contained in:
parent
e2161a1ebe
commit
f4f5700303
@ -9,5 +9,7 @@ urlpatterns = patterns('gameday.views',
|
|||||||
url('^lots/(?P<lot>\w+)/$', views.SingleParkingLotList.as_view(), name='parking-lot'),
|
url('^lots/(?P<lot>\w+)/$', views.SingleParkingLotList.as_view(), name='parking-lot'),
|
||||||
url('^rate/$', views.RateLot.as_view(), name='parking-rating'),
|
url('^rate/$', views.RateLot.as_view(), name='parking-rating'),
|
||||||
url('^register/(?P<id>\d+)/$', views.ListRegisteredUsers.as_view(), name='get-registered-user'),
|
url('^register/(?P<id>\d+)/$', views.ListRegisteredUsers.as_view(), name='get-registered-user'),
|
||||||
|
url('^register/(?P<fname>\w+)/(?P<lname>\w+)/$', views.ListRegisteredUserByName.as_view(),
|
||||||
|
name='get-registered-user-by-name'),
|
||||||
url('^register/$', views.RegisterUser.as_view(), name='register-user'),
|
url('^register/$', views.RegisterUser.as_view(), name='register-user'),
|
||||||
)
|
)
|
||||||
|
@ -89,3 +89,19 @@ class ListRegisteredUsers(APIView):
|
|||||||
'Get the information for a registered user'
|
'Get the information for a registered user'
|
||||||
user = get_object_or_404(RegisteredUser, id=id)
|
user = get_object_or_404(RegisteredUser, id=id)
|
||||||
return Response(UserSerializer(user).data)
|
return Response(UserSerializer(user).data)
|
||||||
|
|
||||||
|
class ListRegisteredUserByName(APIView):
|
||||||
|
"""
|
||||||
|
Get a registered user by looking up their first and last name.
|
||||||
|
This isn't a PK lookup, so we get the one registered most recently.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def get(self, request, fname, lname):
|
||||||
|
'Get the information for a specified user'
|
||||||
|
user = RegisteredUser.objects.filter(first_name=fname, last_name=lname)\
|
||||||
|
.order_by("-id")[0]
|
||||||
|
if user is None:
|
||||||
|
return Response("User not found with first_name '%s' and last_name '%s'",
|
||||||
|
status=status.HTTP_404_NOT_FOUND)
|
||||||
|
else:
|
||||||
|
return Response(SingleUserSerializer(user).data)
|
||||||
|
Loading…
Reference in New Issue
Block a user