Skip to content
Snippets Groups Projects
Unverified Commit 49bbd6ab authored by Matthew Piatetsky's avatar Matthew Piatetsky Committed by GitHub
Browse files

Merge pull request #22222 from edx/REV-693-step2

Create data migration to populate FBEEnrollmentExclusion Table
parents e5ee4408 ca8ab76d
Branches
Tags
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% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment