From 272f1df89ceabcbf0c9ddd2c14fdcd64b97f0e1a Mon Sep 17 00:00:00 2001 From: DjBushido Date: Wed, 4 Dec 2013 13:10:59 -0500 Subject: [PATCH] Only show the registered users over the past week --- uncc_gameday/gameday/views.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/uncc_gameday/gameday/views.py b/uncc_gameday/gameday/views.py index 544608d..433ea34 100755 --- a/uncc_gameday/gameday/views.py +++ b/uncc_gameday/gameday/views.py @@ -1,5 +1,6 @@ from models import ParkingLot, ParkingRating from serializers import * +from datetime import datetime, timedelta from rest_framework.views import APIView from rest_framework.response import Response @@ -77,12 +78,13 @@ class ParkingLotEntrance(APIView): class RegisterUser(APIView): """ Handle Registration of users - **GET**: Get the current information of a registered user by ID + **GET**: List all registered users **POST**: Register a new user. Please POST the and """ def get(self, request): 'Get the first and last names of all registered users' - users = RegisteredUser.objects.all() + one_week = timedelta(7) + users = RegisteredUser.objects.filte(date_registered__gt=datetime.now()-one_week) users_s = SingleUserSerializer(users, many=True) return Response(users_s.data) @@ -96,7 +98,7 @@ class RegisterUser(APIView): class ListRegisteredUsers(APIView): """ - List all registered users. + Get the current information of a registered user by ID We have a separate view set up so we can list all information about one user at a time (this one), and one view to get just id, first_name, and last_name of all users.