Skip to content
Snippets Groups Projects
Commit ca8ab76d authored by Matthew Piatetsky's avatar Matthew Piatetsky
Browse files

create data migration to populate FBEEnrollmentExclusion table

parent db1ef846
No related merge requests found
# -*- 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),
]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment