25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

views.py 1.1 KiB

1234567891011121314151617181920212223242526272829303132333435363738
  1. from api import models, serializers
  2. from api.permissions import IsOwner
  3. from rest_framework import permissions, viewsets
  4. from rest_framework_simplejwt.views import TokenObtainPairView
  5. class PasswordViewSet(viewsets.ModelViewSet):
  6. serializer_class = serializers.PasswordSerializer
  7. permission_classes = (
  8. permissions.IsAuthenticated,
  9. IsOwner,
  10. )
  11. search_fields = (
  12. "site",
  13. "email",
  14. )
  15. ordering_fields = ("site", "email", "created")
  16. def get_queryset(self):
  17. return models.Password.objects.filter(user=self.request.user)
  18. class EncryptedPasswordProfileViewSet(viewsets.ModelViewSet):
  19. serializer_class = serializers.EncryptedPasswordProfileSerializer
  20. permission_classes = (
  21. permissions.IsAuthenticated,
  22. IsOwner,
  23. )
  24. def get_queryset(self):
  25. return models.EncryptedPasswordProfile.objects.filter(user=self.request.user)
  26. class BackwardCompatibleTokenObtainPairView(TokenObtainPairView):
  27. serializer_class = serializers.BackwardCompatibleTokenObtainPairSerializer
  28. token_obtain_pair = TokenObtainPairView.as_view()