30 lines
937 B
Python
30 lines
937 B
Python
from rest_framework import status
|
|
from rest_framework.exceptions import APIException
|
|
|
|
|
|
class DeviceException(APIException):
|
|
status_code = status.HTTP_400_BAD_REQUEST
|
|
default_detail = "خطا در اطلاعات پلاک" # noqa
|
|
default_code = 'error'
|
|
|
|
def __init__(self, message=None, status_code=None, code=None):
|
|
if status_code is not None:
|
|
self.status_code = status_code
|
|
|
|
detail = {
|
|
"message": message,
|
|
"status_code": status_code
|
|
}
|
|
|
|
super().__init__(detail)
|
|
|
|
|
|
class DeviceAlreadyAssigned(APIException):
|
|
status_code = status.HTTP_403_FORBIDDEN
|
|
default_detail = "این دستگاه قبلا به این کلاینت تخصیص داده شده است" # noqa
|
|
|
|
|
|
class OrganizationDeviceNotAssigned(APIException):
|
|
status_code = status.HTTP_403_FORBIDDEN
|
|
default_detail = "این سازمان دستگاه فعالی ندارد" # noqa
|