Skip to content

Commit

Permalink
Merge pull request #381 from openedx/bbeggs/ENT-8017
Browse files Browse the repository at this point in the history
feat: Add batch_id to assignment creation
  • Loading branch information
macdiesel authored Jan 17, 2024
2 parents 3c77c0b + dc2059e commit fad6c79
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
3 changes: 3 additions & 0 deletions enterprise_access/apps/content_assignments/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import logging
from typing import Iterable
from uuid import uuid4

from django.db import transaction
from django.db.models import Q, Sum
Expand Down Expand Up @@ -437,6 +438,7 @@ def _create_new_assignments(assignment_configuration, learner_emails, content_ke
# First, prepare assignment objects using data available in-memory only.
content_title = _get_content_title(assignment_configuration, content_key)
assignments_to_create = []
allocation_batch_id = uuid4()
for learner_email in learner_emails:
assignment = LearnerContentAssignment(
assignment_configuration=assignment_configuration,
Expand All @@ -445,6 +447,7 @@ def _create_new_assignments(assignment_configuration, learner_emails, content_ke
content_title=content_title,
content_quantity=content_quantity,
state=LearnerContentAssignmentStateChoices.ALLOCATED,
allocation_batch_id=allocation_batch_id,
)
assignments_to_create.append(assignment)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.2.9 on 2024-01-09 23:19

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('content_assignments', '0014_alter_historicalassignmentconfiguration_options_and_more'),
]

operations = [
migrations.AddField(
model_name='historicallearnercontentassignment',
name='allocation_batch_id',
field=models.UUIDField(blank=True, default=None, help_text='A reference to the batch that this assignment was created in. Helpful for grouping assignments together.', null=True),
),
migrations.AddField(
model_name='learnercontentassignment',
name='allocation_batch_id',
field=models.UUIDField(blank=True, default=None, help_text='A reference to the batch that this assignment was created in. Helpful for grouping assignments together.', null=True),
),
]
9 changes: 9 additions & 0 deletions enterprise_access/apps/content_assignments/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,15 @@ class Meta:
"been notified."
),
)

allocation_batch_id = models.UUIDField(
null=True,
blank=True,
default=None,
help_text=(
"A reference to the batch that this assignment was created in. Helpful for grouping assignments together."
),
)
history = HistoricalRecords()

def __str__(self):
Expand Down

0 comments on commit fad6c79

Please sign in to comment.