Fakultas Ilmu Komputer UI

Commit f7cab773 authored by Ami's avatar Ami

adding PUT functionality for weekly report comment

parent e7512924
Pipeline #84409 passed with stages
in 12 minutes and 25 seconds
......@@ -101,3 +101,25 @@ class WeeklyReportCommentViewSet(viewsets.ModelViewSet):
serializer = WeeklyReportCommentSerializer(queryset, many=True)
return Response(serializer.data, status=status.HTTP_200_OK)
def update(self, request, pk=None, *args, **kwargs):
instance = WeeklyReportComment.objects.get(id=pk)
instance.weight = request.data['weight']
instance.height = request.data['height']
instance.waist_size = request.data['waist_size']
instance.changes_felt = request.data['changes_felt']
instance.hunger_level = request.data['hunger_level']
instance.fullness_level = request.data['fullness_level']
instance.heavy_meal = request.data['heavy_meal']
instance.snacks = request.data['snacks']
instance.average_consumption = request.data['average_consumption']
instance.water_consumption = request.data['water_consumption']
instance.physical_activity = request.data['physical_activity']
instance.time_for_activity = request.data['time_for_activity']
instance.feeling_rating = request.data['feeling_rating']
instance.lesson_learned = request.data['lesson_learned']
instance.problem_faced_and_feedbacks = request.data['problem_faced_and_feedbacks']
instance.save()
serializer = WeeklyReportCommentSerializer(instance)
return Response(serializer.data, status=status.HTTP_200_OK)
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