Skip to content

Commit

Permalink
new table for the clean up of notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzaloprelatto committed Jul 15, 2020
1 parent 925fde6 commit eaf51a4
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions MagicHolidays/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
6 changes: 6 additions & 0 deletions api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 16 additions & 0 deletions api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit eaf51a4

Please sign in to comment.