Files
RasadDam_Backend/apps/authentication/exceptions.py

58 lines
2.2 KiB
Python
Raw Normal View History

from django.utils.translation import gettext_lazy as _
from rest_framework import status
from rest_framework.exceptions import APIException
class TokenBlackListedException(APIException):
2025-06-02 15:26:49 +03:30
""" exception for blocked access tokens """
status_code = status.HTTP_401_UNAUTHORIZED
default_detail = _('unauthorized')
default_code = 'unauthorized'
2025-11-05 12:47:13 +03:30
class BankAccountExistException(APIException):
status_code = status.HTTP_403_FORBIDDEN
default_detail = "اطلاعات بانکی وارد شده از قبل ثبت شده است" # noqa
default_code = "اطلاعات بانکی وارد شده از قبل ثبت شده است" # noqa
class OrganizationBankAccountException(APIException):
""" if organization does not have bank account """
status_code = status.HTTP_403_FORBIDDEN
default_detail = "برای این سازمان حساب بانکی تعریف نشده است, ابتدا حساب بانکی تعریف کنید" # noqa
default_code = "برای این سازمان حساب بانکی تعریف نشده است" # noqa
class OrganizationNationalUniqueIDException(APIException):
""" if organization unique id exist """
status_code = status.HTTP_403_FORBIDDEN
default_detail = _('این شناسه ملی قبلا ثبت شده است') # noqa
default_code = 'organization_unique_id_exist'
class OrganizationTypeRepeatableException(APIException):
""" if organization type is repeatable """
status_code = status.HTTP_403_FORBIDDEN
default_detail = _('این نوع سازمان قابلیت تکرار ندارد و از قبل وجود دارد') # noqa
default_code = 'organization_type_repeatable'
class UserExistException(APIException):
""" if user exist """
status_code = status.HTTP_403_FORBIDDEN
default_detail = _('کاربری با این شماره موبایل یا با این نام کاربری از قبل وجود دارد') # noqa
default_code = 'user_does_not_exist'
2025-10-27 15:53:47 +03:30
2025-10-27 15:53:47 +03:30
class AdminDeleteException(APIException):
""" admin user can not be deleted """
status_code = status.HTTP_403_FORBIDDEN
default_detail = _('این کاربر ادمین است و قابلیت حذف ندارد') # noqa
default_code = 'user_does_not_exist'