From 583ed1b2c07123608eacb7af1ac8d015303fa106 Mon Sep 17 00:00:00 2001 From: 7nimor <7nimor@gmail.com> Date: Sat, 7 Feb 2026 16:31:55 +0330 Subject: [PATCH] update hatching --- app/views.py | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/app/views.py b/app/views.py index f74f4b2..b63de68 100644 --- a/app/views.py +++ b/app/views.py @@ -806,9 +806,8 @@ class HatchingsViewSet(viewsets.ModelViewSet): 'MenuUserAccess', 'LogTableName', 'LogTableAlias', 'PageTitle', 'PartIdCode', 'UnitTypeName' ] - good_sum = request.data.get('GoodSum', {}) - print(good_sum.get('loadingSum')) - if int(good_sum.get('loadingSum',0)) > 0: + good_sums = request.data.get('GoodSum', {}) + if int(good_sums.get('loadingSum',0)) > 0: for key in same_keys: if key in request.data and request.data[key] is not None: poultry_data[key] = request.data[key] @@ -865,6 +864,7 @@ class HatchingsViewSet(viewsets.ModelViewSet): evacuation_details = request.data.get('EvacuationDetail', []) if 'EvacuationDetail' in request.data: request.data.pop('EvacuationDetail') + if 'GoodSum' in request.data: request.data.pop('GoodSum') @@ -875,15 +875,14 @@ class HatchingsViewSet(viewsets.ModelViewSet): setattr(hatching, key, value) if hatching.poultry is None: hatching.poultry=poultry - good_sums = request.data.get('GoodSum', {}) - if isinstance(good_sums, dict): - hatching.GoodSum = good_sums.get('goodSum', 0) - hatching.loadingSum = good_sums.get('loadingSum', 0) - elif isinstance(good_sums, list) and len(good_sums) > 0: - item = good_sums[0] - if isinstance(item, dict): - hatching.GoodSum = item.get('goodSum', 0) - hatching.loadingSum = item.get('loadingSum', 0) + # if isinstance(good_sums, dict): + hatching.GoodSum = good_sums.get('goodSum', 0) + hatching.loadingSum = good_sums.get('loadingSum', 0) + # elif isinstance(good_sums, list) and len(good_sums) > 0: + # item = good_sums[0] + # if isinstance(item, dict): + # hatching.GoodSum = item.get('goodSum', 0) + # hatching.loadingSum = item.get('loadingSum', 0) hatching.save() hatching.save() @@ -895,15 +894,14 @@ class HatchingsViewSet(viewsets.ModelViewSet): request.data['Period'] = period hatching = Hatching.objects.create(**request.data) hatching.ArchiveDate = hatching.Date + datetime.timedelta(days=76) - good_sums = request.data.get('GoodSum', {}) - if isinstance(good_sums, dict): - hatching.GoodSum = good_sums.get('goodSum', 0) - hatching.loadingSum = good_sums.get('loadingSum', 0) - elif isinstance(good_sums, list) and len(good_sums) > 0: - item = good_sums[0] - if isinstance(item, dict): - hatching.GoodSum = item.get('goodSum', 0) - hatching.loadingSum = item.get('loadingSum', 0) + # if isinstance(good_sums, dict): + hatching.GoodSum = good_sums.get('goodSum', 0) + hatching.loadingSum = good_sums.get('loadingSum', 0) + # elif isinstance(good_sums, list) and len(good_sums) > 0: + # item = good_sums[0] + # if isinstance(item, dict): + # hatching.GoodSum = item.get('goodSum', 0) + # hatching.loadingSum = item.get('loadingSum', 0) if poultry: hatching.poultry = poultry