* Cleanup

This commit is contained in:
Phil Zhitnikov 2023-07-10 20:06:11 +04:00
parent 6b1a11d355
commit 5f0f8befcb
3 changed files with 3 additions and 8 deletions

View File

@ -12,10 +12,10 @@ class CRMException(APIException):
self.detail = {'error': detail}
class AuthErrorMixin(CRMException):
class UnauthorizedException(CRMException):
"""Authentication exception error mixin."""
status_code = status.HTTP_401_UNAUTHORIZED
class InvalidCredentialsException(AuthErrorMixin):
class InvalidCredentialsException(UnauthorizedException):
default_detail = 'cannot find the worker'

View File

@ -1,7 +1,4 @@
import base64
from django.contrib.auth import authenticate
from django.core.files.base import ContentFile
from drf_extra_fields.fields import Base64ImageField
from rest_framework import serializers
@ -25,8 +22,7 @@ class LoginSerializer(serializers.Serializer):
password=password)
# The authenticate call simply returns None for is_active=False
# users. (Assuming the default ModelBackend authentication
# backend.)
# users. (Assuming the default ModelBackend authentication backend.)
if not user:
raise InvalidCredentialsException()

View File

@ -90,7 +90,6 @@ class ChecklistAPI(mixins.ListModelMixin, mixins.CreateModelMixin, mixins.Retrie
return self.retrieve(request, *args, **kwargs)
return self.list(request, *args, **kwargs)
# Update some data on current user
def patch(self, request, *args, **kwargs):
data = json.loads(request.body)
instance = get_object_or_404(self.get_queryset(), id=self.kwargs['id'])