* Cleanup
This commit is contained in:
parent
6b1a11d355
commit
5f0f8befcb
|
|
@ -12,10 +12,10 @@ class CRMException(APIException):
|
||||||
self.detail = {'error': detail}
|
self.detail = {'error': detail}
|
||||||
|
|
||||||
|
|
||||||
class AuthErrorMixin(CRMException):
|
class UnauthorizedException(CRMException):
|
||||||
"""Authentication exception error mixin."""
|
"""Authentication exception error mixin."""
|
||||||
status_code = status.HTTP_401_UNAUTHORIZED
|
status_code = status.HTTP_401_UNAUTHORIZED
|
||||||
|
|
||||||
|
|
||||||
class InvalidCredentialsException(AuthErrorMixin):
|
class InvalidCredentialsException(UnauthorizedException):
|
||||||
default_detail = 'cannot find the worker'
|
default_detail = 'cannot find the worker'
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,4 @@
|
||||||
import base64
|
|
||||||
|
|
||||||
from django.contrib.auth import authenticate
|
from django.contrib.auth import authenticate
|
||||||
from django.core.files.base import ContentFile
|
|
||||||
from drf_extra_fields.fields import Base64ImageField
|
from drf_extra_fields.fields import Base64ImageField
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
||||||
|
|
@ -25,8 +22,7 @@ class LoginSerializer(serializers.Serializer):
|
||||||
password=password)
|
password=password)
|
||||||
|
|
||||||
# The authenticate call simply returns None for is_active=False
|
# The authenticate call simply returns None for is_active=False
|
||||||
# users. (Assuming the default ModelBackend authentication
|
# users. (Assuming the default ModelBackend authentication backend.)
|
||||||
# backend.)
|
|
||||||
if not user:
|
if not user:
|
||||||
raise InvalidCredentialsException()
|
raise InvalidCredentialsException()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,6 @@ class ChecklistAPI(mixins.ListModelMixin, mixins.CreateModelMixin, mixins.Retrie
|
||||||
return self.retrieve(request, *args, **kwargs)
|
return self.retrieve(request, *args, **kwargs)
|
||||||
return self.list(request, *args, **kwargs)
|
return self.list(request, *args, **kwargs)
|
||||||
|
|
||||||
# Update some data on current user
|
|
||||||
def patch(self, request, *args, **kwargs):
|
def patch(self, request, *args, **kwargs):
|
||||||
data = json.loads(request.body)
|
data = json.loads(request.body)
|
||||||
instance = get_object_or_404(self.get_queryset(), id=self.kwargs['id'])
|
instance = get_object_or_404(self.get_queryset(), id=self.kwargs['id'])
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user