From eaf51a4574c111ea8502f7f82a05d129217054a8 Mon Sep 17 00:00:00 2001 From: gonzalo Date: Wed, 15 Jul 2020 17:21:02 -0300 Subject: [PATCH] new table for the clean up of notifications --- MagicHolidays/urls.py | 1 + api/models.py | 3 +++ api/serializers.py | 6 ++++++ api/views.py | 16 ++++++++++++++++ 4 files changed, 26 insertions(+) diff --git a/MagicHolidays/urls.py b/MagicHolidays/urls.py index 172a0ea..d2d0b17 100644 --- a/MagicHolidays/urls.py +++ b/MagicHolidays/urls.py @@ -30,6 +30,7 @@ router.register(r'payments', views.paymentViewSet) router.register(r'audit', views.auditViewSet) router.register(r'notifications', views.notificationViewSet) +router.register(r'notificationsDone', views.doneTasksViewSet) # Wire up our API using automatic URL routing. # Additionally, we include login URLs for the browsable API. diff --git a/api/models.py b/api/models.py index 0d1b42e..813053e 100644 --- a/api/models.py +++ b/api/models.py @@ -132,3 +132,6 @@ class token(models.Model): deleted_at = models.DateTimeField(null=True) def __str__(self): return '%s' % (self.token) + +class doneTasks(models.Model): + rez = models.ForeignKey(rez, related_name='rel_task_rez', on_delete=models.PROTECT) \ No newline at end of file diff --git a/api/serializers.py b/api/serializers.py index a3ff0dc..6ce8a39 100644 --- a/api/serializers.py +++ b/api/serializers.py @@ -17,6 +17,12 @@ class Meta: model = country fields = ['id','description','lang'] +class doneTasksSerializer(serializers.HyperlinkedModelSerializer): + rez = serializers.PrimaryKeyRelatedField(queryset=rez.objects.all(), many=False) + class Meta: + model = doneTasks + fields = ['id','rez'] + class userSerializer(serializers.HyperlinkedModelSerializer): user_type = serializers.PrimaryKeyRelatedField(queryset=user_type.objects.all(), many=False) country = serializers.PrimaryKeyRelatedField(queryset=country.objects.all(), many=False) diff --git a/api/views.py b/api/views.py index 7668fcf..6a6ca86 100644 --- a/api/views.py +++ b/api/views.py @@ -477,6 +477,22 @@ def create(self, request): return Response(serializer.errors) +class doneTasksViewSet(viewsets.ModelViewSet): + """ + API endpoint that allows taxes to be viewed or edited. + """ + permission_classes = [checkAccess] + queryset = doneTasks.objects.all() + serializer_class = doneTasksSerializer + + def create(self, request): + serializer = doneTasksSerializer(data=request.data) + if serializer.is_valid(): + serializer.save() + return Response(serializer.data) + return Response(serializer.errors) + + class prepaidViewSet(APIView): """ API endpoint that allows taxes to be viewed or edited.