duplicated rancher
This commit is contained in:
@@ -9,7 +9,7 @@ class UniqueRancherApiException(APIException):
|
|||||||
|
|
||||||
class DuplicateRancherException(APIException):
|
class DuplicateRancherException(APIException):
|
||||||
status_code = status.HTTP_403_FORBIDDEN
|
status_code = status.HTTP_403_FORBIDDEN
|
||||||
default_detail = "دامدار با این شماره تماس از قبل در سیستم وجود دارد" # noqa
|
default_detail = "اطلاعات دامدار استعلام شده دارای مشکل میباشد با پشتیبانی تماس بگیرید" # noqa
|
||||||
|
|
||||||
|
|
||||||
class HerdCapacityException(APIException):
|
class HerdCapacityException(APIException):
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ from rest_framework.permissions import AllowAny
|
|||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
|
|
||||||
from apps.core.mixins.search_mixin import DynamicSearchMixin
|
from apps.core.mixins.search_mixin import DynamicSearchMixin
|
||||||
from apps.herd.exception import DuplicateRancherException
|
|
||||||
from apps.herd.models import Herd, Rancher
|
from apps.herd.models import Herd, Rancher
|
||||||
from apps.herd.pos.api.v1.serializers import HerdSerializer, RancherSerializer
|
from apps.herd.pos.api.v1.serializers import HerdSerializer, RancherSerializer
|
||||||
from apps.livestock.web.api.v1.serializers import LiveStockSerializer
|
from apps.livestock.web.api.v1.serializers import LiveStockSerializer
|
||||||
@@ -141,8 +140,8 @@ class RancherViewSet(viewsets.ModelViewSet, DynamicSearchMixin):
|
|||||||
|
|
||||||
rancher = self.queryset.filter(national_code=request.data['national_code'])
|
rancher = self.queryset.filter(national_code=request.data['national_code'])
|
||||||
|
|
||||||
if len(rancher) > 1:
|
# if len(rancher) > 1:
|
||||||
raise DuplicateRancherException()
|
# raise DuplicateRancherException()
|
||||||
|
|
||||||
if rancher.exists():
|
if rancher.exists():
|
||||||
serializer = self.serializer_class(rancher.first())
|
serializer = self.serializer_class(rancher.first())
|
||||||
|
|||||||
Reference in New Issue
Block a user