edit tag distribute from distribution
This commit is contained in:
@@ -245,7 +245,7 @@ class TagDistributionService:
|
|||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
|
|
||||||
if tag_batch.assigner_org != org:
|
if tag_batch.assigner_org != org:
|
||||||
raise PermissionDenied("اجازه ویرایش این توزیع را ندارید")
|
raise PermissionDenied("اجازه ویرایش این توزیع را ندارید") # noqa
|
||||||
|
|
||||||
for dist in tag_batch.distributions.all():
|
for dist in tag_batch.distributions.all():
|
||||||
dist.tag.all().update(
|
dist.tag.all().update(
|
||||||
@@ -268,7 +268,9 @@ class TagDistributionService:
|
|||||||
parent_tag_distribution = TagDistribution.objects.get(
|
parent_tag_distribution = TagDistribution.objects.get(
|
||||||
id=dist_data['parent_tag_distribution']
|
id=dist_data['parent_tag_distribution']
|
||||||
)
|
)
|
||||||
batch = TagBatch.objects.get(batch_identity=dist_data.get('batch_identity'))
|
batch = TagBatch.objects.get(
|
||||||
|
batch_identity=dist_data.get('batch_identity')
|
||||||
|
) if dist_data.get('batch_identity') else None
|
||||||
count = dist_data['count']
|
count = dist_data['count']
|
||||||
|
|
||||||
tags = Tag.objects.filter(
|
tags = Tag.objects.filter(
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
from django.db.models import Sum
|
||||||
from django.db.models.signals import m2m_changed
|
from django.db.models.signals import m2m_changed
|
||||||
from django.db.models.signals import post_save
|
from django.db.models.signals import post_save
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
@@ -53,7 +54,9 @@ def calculate_tag_distribution_detail(sender, instance: TagDistributionBatch, **
|
|||||||
tag_dist_batch = instance
|
tag_dist_batch = instance
|
||||||
parent = tag_dist_batch.parent
|
parent = tag_dist_batch.parent
|
||||||
if parent:
|
if parent:
|
||||||
parent.total_distributed_tag_count += tag_dist_batch.total_tag_count
|
parent.total_distributed_tag_count = parent.children.aggregate(
|
||||||
|
total=Sum('total_tag_count')
|
||||||
|
)['total']
|
||||||
parent.remaining_tag_count = (
|
parent.remaining_tag_count = (
|
||||||
parent.total_tag_count - parent.total_distributed_tag_count
|
parent.total_tag_count - parent.total_distributed_tag_count
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -478,9 +478,9 @@ class TagDistributionViewSet(
|
|||||||
@action(
|
@action(
|
||||||
methods=['put'],
|
methods=['put'],
|
||||||
detail=True,
|
detail=True,
|
||||||
url_path='distribute_distribution',
|
url_path='edit_distribute_distribution',
|
||||||
url_name='distribute_distribution',
|
url_name='edit_distribute_distribution',
|
||||||
name='distribute_distribution',
|
name='edit_distribute_distribution',
|
||||||
)
|
)
|
||||||
def update_distribute_from_distribution(self, request, pk=None):
|
def update_distribute_from_distribution(self, request, pk=None):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user