fix --> show tag distribution batches on diffrent situations for orgs
This commit is contained in:
@@ -0,0 +1,25 @@
|
|||||||
|
# Generated by Django 5.0 on 2026-02-07 07:29
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('authentication', '0060_organization_ownership_code'),
|
||||||
|
('tag', '0042_tagdistribution_parent_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='tagdistributionbatch',
|
||||||
|
name='owner_org',
|
||||||
|
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='tag_distribution_batch', to='authentication.organization'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='tagdistributionbatch',
|
||||||
|
name='top_root_distribution',
|
||||||
|
field=models.BooleanField(default=False),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -76,11 +76,13 @@ class TagDistributionService:
|
|||||||
# create distribution batch
|
# create distribution batch
|
||||||
distributions_batch = TagDistributionBatch.objects.create(
|
distributions_batch = TagDistributionBatch.objects.create(
|
||||||
parent=TagDistributionBatch.objects.get(id=data.get('parent')) if data.get('parent') else None,
|
parent=TagDistributionBatch.objects.get(id=data.get('parent')) if data.get('parent') else None,
|
||||||
|
owner_org=assigned_org,
|
||||||
assigner_org=org,
|
assigner_org=org,
|
||||||
assigned_org=assigned_org,
|
assigned_org=assigned_org,
|
||||||
total_tag_count=total_counted_tags,
|
total_tag_count=total_counted_tags,
|
||||||
dist_batch_identity=generate_unique_code(f"{random.randint(1000, 9999)}"),
|
dist_batch_identity=generate_unique_code(f"{random.randint(1000, 9999)}"),
|
||||||
distribution_type=distribution_type,
|
distribution_type=distribution_type,
|
||||||
|
top_root_distribution=True
|
||||||
)
|
)
|
||||||
distributions_batch.distributions.add(*distributions)
|
distributions_batch.distributions.add(*distributions)
|
||||||
|
|
||||||
@@ -220,6 +222,7 @@ class TagDistributionService:
|
|||||||
|
|
||||||
dist_batch = TagDistributionBatch.objects.create(
|
dist_batch = TagDistributionBatch.objects.create(
|
||||||
parent=parent_batch,
|
parent=parent_batch,
|
||||||
|
owner_org=assigned_org,
|
||||||
assigner_org=org,
|
assigner_org=org,
|
||||||
assigned_org=assigned_org,
|
assigned_org=assigned_org,
|
||||||
total_tag_count=total_counted_tags,
|
total_tag_count=total_counted_tags,
|
||||||
|
|||||||
@@ -578,8 +578,23 @@ class TagDistributionBatchViewSet(
|
|||||||
"""
|
"""
|
||||||
list of tag distribution batches
|
list of tag distribution batches
|
||||||
"""
|
"""
|
||||||
|
org = get_organization_by_user(request.user)
|
||||||
|
|
||||||
queryset = self.get_queryset(visibility_by_org_scope=True).filter(is_closed=False).order_by('-create_date')
|
queryset = self.get_queryset(
|
||||||
|
visibility_by_org_scope=True
|
||||||
|
).filter(
|
||||||
|
is_closed=False,
|
||||||
|
top_root_distribution=True,
|
||||||
|
).order_by('-create_date')
|
||||||
|
|
||||||
|
if not queryset:
|
||||||
|
queryset = self.get_queryset(
|
||||||
|
visibility_by_org_scope=True
|
||||||
|
).filter(
|
||||||
|
is_closed=False,
|
||||||
|
owner_org=org,
|
||||||
|
top_root_distribution=False,
|
||||||
|
).order_by('-create_date')
|
||||||
|
|
||||||
queryset = self.filter_query(self.filter_queryset(queryset))
|
queryset = self.filter_query(self.filter_queryset(queryset))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user