Fakultas Ilmu Komputer UI

Commit 2103df68 authored by Ami's avatar Ami

adding user's current week number on get_specific_weekly_report

parent 5d56126b
Pipeline #82992 passed with stages
in 11 minutes and 20 seconds
......@@ -184,7 +184,7 @@ class WeeklyReportTest(APITestCase):
reports = WeeklyReport.objects.all()
serializer = WeeklyReportSerializer(reports, many=True)
self.assertEqual(response.data, [{'has_submitted_this_week':False,'data':serializer.data}])
self.assertEqual(response.data, {'today_week': 0,'has_submitted_this_week':False,'data':serializer.data})
self.assertEqual(response.status_code, status.HTTP_200_OK)
def test_get_specific_weekly_report(self):
......@@ -193,7 +193,7 @@ class WeeklyReportTest(APITestCase):
reports = reports.order_by('week_num')
serializer = WeeklyReportSerializer(reports, many=True)
self.assertEqual(response.data, [{'has_submitted_this_week':False,'data':serializer.data}])
self.assertEqual(response.data, {'today_week': 1,'has_submitted_this_week':False,'data':serializer.data})
self.assertEqual(response.status_code, status.HTTP_200_OK)
def test_get_user_weekly_report_belonging_to_a_nutritionist(self):
......@@ -212,7 +212,7 @@ class WeeklyReportTest(APITestCase):
reports = reports.order_by('week_num')
serializer = WeeklyReportSerializer(reports, many=True)
self.assertEqual(response.data, [{'has_submitted_this_week':True,'data':serializer.data}])
self.assertEqual(response.data, {'today_week': 1,'has_submitted_this_week':True,'data':serializer.data})
self.assertEqual(response.status_code, status.HTTP_200_OK)
def test_get_user_weekly_report_belonging_to_non_nutritionist(self):
......@@ -231,7 +231,7 @@ class WeeklyReportTest(APITestCase):
reports = reports.order_by('week_num')
serializer = WeeklyReportSerializer(reports, many=True)
self.assertEqual(response.data, [{'has_submitted_this_week':True,'data':serializer.data}])
self.assertEqual(response.data, {'today_week': 1,'has_submitted_this_week':True,'data':serializer.data})
self.assertEqual(response.status_code, status.HTTP_200_OK)
def test_weekly_report_string(self):
......
......@@ -53,7 +53,7 @@ class WeeklyReportViewSet(viewsets.ModelViewSet):
def list(self, request, *args, **kwargs):
queryset = self.filter_queryset(self.get_queryset())
this_week_submission = False
week_number = 0
user_id = self.request.query_params.get('client_id')
if user_id is not None:
user = CustomUser.objects.get(Q(id=user_id))
......@@ -64,7 +64,10 @@ class WeeklyReportViewSet(viewsets.ModelViewSet):
this_week_submission = True
serializer = self.get_serializer(queryset, many=True)
return Response([{'has_submitted_this_week':this_week_submission,'data':serializer.data}])
return Response({\
'today_week':week_number,\
'has_submitted_this_week':this_week_submission,\
'data':serializer.data})
class WeeklyReportCommentViewSet(viewsets.ModelViewSet):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment