Commit 55649355 by Jeff LaJoie

EDUCATOR-842: adds in management command to swap a course's xblocks from…

EDUCATOR-842: adds in management command to swap a course's xblocks from verified track cohorts to enrollment tracks
parent 2d0fc911
......@@ -5,10 +5,18 @@ Django admin page for verified track configuration
from django.contrib import admin
from openedx.core.djangoapps.verified_track_content.forms import VerifiedTrackCourseForm
from openedx.core.djangoapps.verified_track_content.models import VerifiedTrackCohortedCourse
from openedx.core.djangoapps.verified_track_content.models import (
MigrateVerifiedTrackCohortsSetting,
VerifiedTrackCohortedCourse
)
@admin.register(VerifiedTrackCohortedCourse)
class VerifiedTrackCohortedCourseAdmin(admin.ModelAdmin):
"""Admin for enabling verified track cohorting. """
form = VerifiedTrackCourseForm
@admin.register(MigrateVerifiedTrackCohortsSetting)
class MigrateVerifiedTrackCohortsSettingAdmin(admin.ModelAdmin):
"""Admin for configuring migration settings of verified track cohorting"""
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
import openedx.core.djangoapps.xmodule_django.models
from django.conf import settings
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('verified_track_content', '0002_verifiedtrackcohortedcourse_verified_cohort_name'),
]
operations = [
migrations.CreateModel(
name='MigrateVerifiedTrackCohortsSetting',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('change_date', models.DateTimeField(auto_now_add=True, verbose_name='Change date')),
('enabled', models.BooleanField(default=False, verbose_name='Enabled')),
('old_course_key', openedx.core.djangoapps.xmodule_django.models.CourseKeyField(help_text=b'Course key for which to migrate verified track cohorts from', max_length=255)),
('rerun_course_key', openedx.core.djangoapps.xmodule_django.models.CourseKeyField(help_text=b'Course key for which to migrate verified track cohorts to enrollment tracks to', max_length=255)),
('audit_cohort_names', models.TextField(help_text=b'Comma-separated list of audit cohort names')),
('changed_by', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, editable=False, to=settings.AUTH_USER_MODEL, null=True, verbose_name='Changed by')),
],
),
]
......@@ -3,6 +3,7 @@ Models for verified track selections.
"""
import logging
from config_models.models import ConfigurationModel
from django.db import models
from django.db.models.signals import post_save, pre_save
from django.dispatch import receiver
......@@ -147,3 +148,30 @@ class VerifiedTrackCohortedCourse(models.Model):
def invalidate_verified_track_cache(sender, **kwargs): # pylint: disable=unused-argument
"""Invalidate the cache of VerifiedTrackCohortedCourse. """
RequestCache.clear_request_cache(name=VerifiedTrackCohortedCourse.CACHE_NAMESPACE)
class MigrateVerifiedTrackCohortsSetting(ConfigurationModel):
"""
Configuration for the swap_from_auto_track_cohorts management command.
"""
class Meta(object):
app_label = "verified_track_content"
old_course_key = CourseKeyField(
max_length=255,
blank=False,
help_text="Course key for which to migrate verified track cohorts from"
)
rerun_course_key = CourseKeyField(
max_length=255,
blank=False,
help_text="Course key for which to migrate verified track cohorts to enrollment tracks to"
)
audit_cohort_names = models.TextField(
help_text="Comma-separated list of audit cohort names"
)
@classmethod
def get_audit_cohort_names(cls):
"""Get the list of audit cohort names for the course"""
return [cohort_name for cohort_name in cls.current().audit_cohort_names.split(",") if cohort_name]
Markdown is supported
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