fix - list of assigned_distribution & assigner_distributions of me
This commit is contained in:
@@ -35,10 +35,12 @@ class QuotaSerializer(serializers.ModelSerializer):
|
||||
representation['been_sold'] = quota_weight_by_org['been_sold']
|
||||
representation['distributions'] = [{
|
||||
"id": dist.id,
|
||||
"organization": org.name,
|
||||
"organization_id": org.id,
|
||||
"create_date": dist.create_date,
|
||||
"modify_date": dist.modify_date,
|
||||
"assigner_organization": dist.assigner_organization.name,
|
||||
"assigner_organization_id": dist.assigner_organization.id,
|
||||
"weight": dist.weight,
|
||||
} for dist in instance.distributions_assigned.all()]
|
||||
} for dist in instance.distributions_assigned.filter(assigned_organization=org)]
|
||||
|
||||
if isinstance(instance, product_models.Quota):
|
||||
if instance.sale_unit:
|
||||
|
||||
@@ -398,10 +398,13 @@ class QuotaViewSet(BaseViewSet, SoftDeleteMixin, viewsets.ModelViewSet, DynamicS
|
||||
def get_distributions_by_quota(self, request, pk=None):
|
||||
""" list of distributions by quota """
|
||||
|
||||
my_org = get_organization_by_user(request.user)
|
||||
try:
|
||||
quota = self.get_object()
|
||||
queryset = self.filter_query(
|
||||
quota.distributions_assigned.all().order_by('-modify_date')
|
||||
quota.distributions_assigned.filter(
|
||||
assigner_organization=my_org
|
||||
).order_by('-modify_date')
|
||||
) # return by search param or all objects
|
||||
|
||||
# paginate queryset
|
||||
|
||||
Reference in New Issue
Block a user