Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.95 KB | None | 0 0
  1. urlpatterns = [
  2.     url(r'^auth/verify/(?P<verification_hash>[0-9A-z-]+)/$', VerifyUserView.as_view(), name='verify_user'),
  3. ]
  4.  
  5.  
  6. class VerifyUserView(generics.UpdateAPIView):
  7.     from .serializers import VerificationHashSerializer
  8.     serializer_class = VerificationHashSerializer
  9.     lookup_field = "verification_hash"
  10.  
  11.     def get_queryset(self):
  12.         from iceberg.models import VerificationHash
  13.         verification_hash = self.kwargs.get('verification_hash')
  14.         token = VerificationHash.objects.get(verification_hash=verification_hash)
  15.         return token
  16.  
  17.     def perform_update(self, serializer: VerificationHashSerializer):
  18.         from iceberg.models import VerificationHash
  19.         verification_hash = self.kwargs.get('verification_hash')
  20.         token = VerificationHash.objects.get(verification_hash=verification_hash)
  21.         token.active = False
  22.         token.save()
  23.         token.user.active = True
  24.         token.user.save()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement