set to get rancher_inventory - change serializer to check context
This commit is contained in:
@@ -50,7 +50,7 @@ class InventoryEntryViewSet(viewsets.ModelViewSet, DynamicSearchMixin, POSDevice
|
||||
return self.get_paginated_response(serializer.data)
|
||||
|
||||
@action(
|
||||
methods=['post'],
|
||||
methods=['get'],
|
||||
detail=False,
|
||||
url_path='rancher_inventory_entries',
|
||||
url_name='rancher_inventory_entries',
|
||||
@@ -60,7 +60,7 @@ class InventoryEntryViewSet(viewsets.ModelViewSet, DynamicSearchMixin, POSDevice
|
||||
def rancher_inventory_entries(self, request):
|
||||
""" """
|
||||
organization = self.get_device_organization()
|
||||
rancher = Rancher.objects.filter(national_code=request.data['national_code']).first()
|
||||
rancher = Rancher.objects.filter(national_code=request.GET['national_code']).first()
|
||||
entries = self.queryset.filter(organization=organization)
|
||||
|
||||
available_entries = [entry for entry in entries if can_buy_from_inventory(rancher, entry)]
|
||||
|
||||
@@ -57,8 +57,9 @@ class InventoryEntrySerializer(serializers.ModelSerializer):
|
||||
'id': instance.distribution.quota.product.id,
|
||||
}
|
||||
|
||||
# rancher herd & live stock statistics
|
||||
representation['rancher_statistics'] = get_rancher_statistics(self.context['rancher'])
|
||||
if self.context['rancher']:
|
||||
# rancher herd & live stock statistics
|
||||
representation['rancher_statistics'] = get_rancher_statistics(self.context['rancher'])
|
||||
|
||||
# rancher live stock statistics by inventory entry
|
||||
representation['rancher_quota_weight_statistics'] = rancher_quota_weight(
|
||||
|
||||
Reference in New Issue
Block a user