fix - compare weight in distribution with parent or none
This commit is contained in:
@@ -65,7 +65,10 @@ class QuotaDistributionSerializer(serializers.ModelSerializer):
|
||||
if total + amount > quota.quota_weight:
|
||||
raise QuotaWeightException()
|
||||
else:
|
||||
if parent_distribution.weight + amount > parent_distribution.weight:
|
||||
children_total = parent_distribution.children.all().aggregate(
|
||||
total=models.Sum('weight')
|
||||
)['total'] or 0
|
||||
if children_total + amount > parent_distribution.weight:
|
||||
raise QuotaWeightException()
|
||||
|
||||
if self.instance:
|
||||
|
||||
Reference in New Issue
Block a user