From 5f0f8befcb074fd4d9a7b3710f328d07e27a66f5 Mon Sep 17 00:00:00 2001 From: phzhik Date: Mon, 10 Jul 2023 20:06:11 +0400 Subject: [PATCH] * Cleanup --- store/exceptions.py | 4 ++-- store/serializers.py | 6 +----- store/views.py | 1 - 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/store/exceptions.py b/store/exceptions.py index 0b76681..886e440 100644 --- a/store/exceptions.py +++ b/store/exceptions.py @@ -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' diff --git a/store/serializers.py b/store/serializers.py index 92a42b4..4c4cabf 100644 --- a/store/serializers.py +++ b/store/serializers.py @@ -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() diff --git a/store/views.py b/store/views.py index 6ff1300..b6ce540 100644 --- a/store/views.py +++ b/store/views.py @@ -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'])