create data migration to populate FBEEnrollmentExclusion table
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.25 on 2019-11-01 18:46
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
from experiments.models import ExperimentData
|
||||
from openedx.features.course_duration_limits.config import EXPERIMENT_DATA_HOLDBACK_KEY, EXPERIMENT_ID
|
||||
from student.models import CourseEnrollment, FBEEnrollmentExclusion
|
||||
|
||||
|
||||
def populate_fbeenrollmentexclusion(apps, schema_editor):
|
||||
holdback_entries = ExperimentData.objects.filter(
|
||||
experiment_id=EXPERIMENT_ID,
|
||||
key=EXPERIMENT_DATA_HOLDBACK_KEY,
|
||||
value='True'
|
||||
)
|
||||
for holdback_entry in holdback_entries:
|
||||
enrollments = [FBEEnrollmentExclusion(enrollment=enrollment)
|
||||
for enrollment in CourseEnrollment.objects.filter(user=holdback_entry.user)]
|
||||
if enrollments:
|
||||
FBEEnrollmentExclusion.objects.bulk_create(enrollments)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('student', '0024_fbeenrollmentexclusion'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(populate_fbeenrollmentexclusion, reverse_code=migrations.RunPython.noop),
|
||||
]
|
||||
Reference in New Issue
Block a user