import --> add distribution type to distribution batch
This commit is contained in:
@@ -134,6 +134,15 @@ class TagDistributionBatch(BaseModel):
|
||||
related_name="to_tag_distribution_batch",
|
||||
null=True
|
||||
)
|
||||
distribution_type = models.CharField(
|
||||
choices=(
|
||||
('random', 'RANDOM'),
|
||||
('batch', 'BATCH'),
|
||||
),
|
||||
max_length=20,
|
||||
null=True,
|
||||
default='batch'
|
||||
)
|
||||
distributions = models.ManyToManyField(TagDistribution, related_name='tag_distribution_batch')
|
||||
total_tag_count = models.IntegerField(default=0)
|
||||
is_closed = models.BooleanField(default=False)
|
||||
|
||||
@@ -32,6 +32,7 @@ class TagDistributionService:
|
||||
species_code=distribution.get('species_code'),
|
||||
status='F'
|
||||
)
|
||||
distribution_type = 'batch'
|
||||
else:
|
||||
batch = None
|
||||
# get tags without batch and only with species code
|
||||
@@ -39,6 +40,7 @@ class TagDistributionService:
|
||||
species_code=distribution.get('species_code'),
|
||||
status='F'
|
||||
)
|
||||
distribution_type = 'random'
|
||||
|
||||
if tags.count() < distribution.get('count'):
|
||||
raise TagException(
|
||||
@@ -71,6 +73,7 @@ class TagDistributionService:
|
||||
assigned_org=assigned_org,
|
||||
total_tag_count=total_counted_tags,
|
||||
dist_batch_identity=generate_unique_code(f"{random.randint(1000, 9999)}"),
|
||||
distribution_type=distribution_type,
|
||||
)
|
||||
distributions_batch.distributions.add(*distributions)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user