fix - some changes in pos randher/ web herd / web licestock/
This commit is contained in:
@@ -7,7 +7,6 @@ from rest_framework.permissions import AllowAny
|
||||
from rest_framework.response import Response
|
||||
|
||||
from apps.core.mixins.search_mixin import DynamicSearchMixin
|
||||
from apps.herd.exception import DuplicateRancherException
|
||||
from apps.herd.models import Herd, Rancher
|
||||
from apps.herd.pos.api.v1.serializers import HerdSerializer, RancherSerializer
|
||||
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'])
|
||||
|
||||
if len(rancher) > 1:
|
||||
raise DuplicateRancherException()
|
||||
# if len(rancher) > 1:
|
||||
# raise DuplicateRancherException()
|
||||
|
||||
if rancher.exists():
|
||||
serializer = self.serializer_class(rancher.first())
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from django.db import transaction
|
||||
from rest_framework import status
|
||||
from rest_framework import status, filters
|
||||
from rest_framework import viewsets
|
||||
from rest_framework.decorators import action
|
||||
from rest_framework.response import Response
|
||||
@@ -20,6 +20,20 @@ class HerdViewSet(BaseViewSet, SoftDeleteMixin, viewsets.ModelViewSet):
|
||||
""" Herd ViewSet """
|
||||
queryset = Herd.objects.all()
|
||||
serializer_class = HerdSerializer
|
||||
filter_backends = [filters.SearchFilter]
|
||||
search_fields = [
|
||||
"rancher__ranching_farm",
|
||||
"name",
|
||||
"code",
|
||||
"province__name",
|
||||
"city__name",
|
||||
"postal",
|
||||
"institution",
|
||||
"epidemiologic",
|
||||
"contractor",
|
||||
"activity",
|
||||
"capacity",
|
||||
]
|
||||
|
||||
@transaction.atomic
|
||||
def create(self, request, *args, **kwargs):
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
from apps.core.mixins.soft_delete_mixin import SoftDeleteMixin
|
||||
from rest_framework import viewsets
|
||||
from apps.livestock import models as livestock_models
|
||||
from apps.tag.web.api.v1.api import TagViewSet
|
||||
from . import serializers as livestock_serializers
|
||||
from rest_framework.exceptions import APIException
|
||||
from rest_framework.decorators import action
|
||||
from rest_framework.response import Response
|
||||
from common.tools import CustomOperations
|
||||
from django.db import transaction
|
||||
from rest_framework import status
|
||||
from rest_framework import viewsets, filters
|
||||
from rest_framework.decorators import action
|
||||
from rest_framework.exceptions import APIException
|
||||
from rest_framework.response import Response
|
||||
|
||||
from apps.core.mixins.soft_delete_mixin import SoftDeleteMixin
|
||||
from apps.livestock import models as livestock_models
|
||||
from . import serializers as livestock_serializers
|
||||
|
||||
|
||||
def trash(queryset, pk):
|
||||
@@ -27,6 +26,16 @@ def delete(queryset, pk):
|
||||
class LiveStockViewSet(viewsets.ModelViewSet, SoftDeleteMixin): # noqa
|
||||
queryset = livestock_models.LiveStock.objects.all()
|
||||
serializer_class = livestock_serializers.LiveStockSerializer
|
||||
filter_backends = [filters.SearchFilter]
|
||||
search_fields = [
|
||||
"gender",
|
||||
"type__name",
|
||||
"use_type__name",
|
||||
"species__name",
|
||||
"herd__name",
|
||||
"herd__description",
|
||||
"herd__rancher__ranching_farm",
|
||||
]
|
||||
|
||||
@action(
|
||||
methods=['put'],
|
||||
|
||||
Reference in New Issue
Block a user