35 lines
1.3 KiB
Python
35 lines
1.3 KiB
Python
from django.utils.translation import gettext_lazy as _
|
|
from rest_framework import status
|
|
from rest_framework.exceptions import APIException
|
|
|
|
|
|
class TokenBlackListedException(APIException):
|
|
""" exception for blocked access tokens """
|
|
|
|
status_code = status.HTTP_401_UNAUTHORIZED
|
|
default_detail = _('unauthorized')
|
|
default_code = 'unauthorized'
|
|
|
|
|
|
class OrganizationBankAccountException(APIException):
|
|
""" if organization does not have bank account """
|
|
|
|
status_code = status.HTTP_403_FORBIDDEN
|
|
default_detail = "برای این سازمان حساب بانکی تعریف نشده است, ابتدا حساب بانکی تعریف کنید" # noqa
|
|
default_code = "برای این سازمان حساب بانکی تعریف نشده است" # noqa
|
|
|
|
|
|
class UserExistException(APIException):
|
|
""" if user exist """
|
|
|
|
status_code = status.HTTP_403_FORBIDDEN
|
|
default_detail = _('کاربری با این شماره موبایل یا با این نام کاربری از قبل وجود دارد') # noqa
|
|
default_code = 'user_does_not_exist'
|
|
|
|
class AdminDeleteException(APIException):
|
|
""" admin user can not be deleted """
|
|
|
|
status_code = status.HTTP_403_FORBIDDEN
|
|
default_detail = _('این کاربر ادمین است و قابلیت حذف ندارد') # noqa
|
|
default_code = 'user_does_not_exist'
|