Beispiel #1
0
 def update(self, request, pk=None):
     if self.check_user(request):
         book = get_object_or_404(self.get_queryset(), pk=pk)
         book.name = request.data['name']
         book.price = request.data['price']
         book.description = request.data['description']
         book.created_at = request.data['created_at']
         book.genre = request.data['genre']
         book.save()
         serializer = JournalSerializer(book)
         return Response(serializer.data)
     return Response({'error': 'У вас нет доступа к редактированию.'}, status=status.HTTP_404_NOT_FOUND)
Beispiel #2
0
 def retrieve(self, request, journal_id):
     journal = Journal.objects.get(id=journal_id)
     serializer = JournalSerializer(journal, many=False)
     return Response(serializer.data)
Beispiel #3
0
 def list(self, request):
     journals = Journal.objects.all()
     serializer = JournalSerializer(journals, many=True)
     return Response(serializer.data)
 def not_active(self, request):
     serializer = JournalSerializer(self.get_queryset(), many=True)
     return Response(serializer.data)
Beispiel #5
0
 def retrieve(self, request, pk=None):
     journal = get_object_or_404(self.get_queryset(), pk=pk)
     serializer = JournalSerializer(journal)
     return Response(serializer.data)
Beispiel #6
0
 def list(self, request):
     print(self.check_user(request))
     queryset = self.get_queryset()
     serializer = JournalSerializer(queryset, many=True)
     return Response(serializer.data)
Beispiel #7
0
 def completed(self, request, *args, **kwargs):
     serializer = JournalSerializer(self.get_queryset().filter(id=kwargs['pk']), many=True
                                 )
     return Response(serializer.data)