From 5150775f1ce0cddc1ce76c4295a316e424633f95 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Wed, 13 Mar 2019 11:56:15 -0400 Subject: [PATCH] Update the documentation and validation on org_course to make the formatting clear --- .../djangoapps/config_model_utils/models.py | 11 +++++++++- .../migrations/0008_auto_20190313_1634.py | 21 +++++++++++++++++++ .../migrations/0008_auto_20190313_1634.py | 21 +++++++++++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 openedx/features/content_type_gating/migrations/0008_auto_20190313_1634.py create mode 100644 openedx/features/course_duration_limits/migrations/0008_auto_20190313_1634.py diff --git a/openedx/core/djangoapps/config_model_utils/models.py b/openedx/core/djangoapps/config_model_utils/models.py index d532c5184f..e66124f671 100644 --- a/openedx/core/djangoapps/config_model_utils/models.py +++ b/openedx/core/djangoapps/config_model_utils/models.py @@ -37,6 +37,14 @@ class Provenance(Enum): default = 'Default' +def validate_course_in_org(value): + if value.count('+') != 1: + raise ValidationError( + _('%(value)s should have the form ORG+COURSE'), + params={'value': value}, + ) + + class StackedConfigurationModel(ConfigurationModel): """ A ConfigurationModel that stacks Global, Site, Org, Course, and Course Run level @@ -82,8 +90,9 @@ class StackedConfigurationModel(ConfigurationModel): verbose_name=_("Course in Org"), help_text=_( "Configure values for all course runs associated with this course. " - "This is should be formatted as 'org/course' (i.e. MITx/6.002x, HarvardX/CS50)." + "This is should be formatted as 'org+course' (i.e. MITx+6.002x, HarvardX+CS50)." ), + validators=[validate_course_in_org], ) course = models.ForeignKey( CourseOverview, diff --git a/openedx/features/content_type_gating/migrations/0008_auto_20190313_1634.py b/openedx/features/content_type_gating/migrations/0008_auto_20190313_1634.py new file mode 100644 index 0000000000..f0af785f80 --- /dev/null +++ b/openedx/features/content_type_gating/migrations/0008_auto_20190313_1634.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.20 on 2019-03-13 16:34 +from __future__ import unicode_literals + +from django.db import migrations, models +import openedx.core.djangoapps.config_model_utils.models + + +class Migration(migrations.Migration): + + dependencies = [ + ('content_type_gating', '0007_auto_20190311_1919'), + ] + + operations = [ + migrations.AlterField( + model_name='contenttypegatingconfig', + name='org_course', + field=models.CharField(blank=True, db_index=True, help_text="Configure values for all course runs associated with this course. This is should be formatted as 'org+course' (i.e. MITx+6.002x, HarvardX+CS50).", max_length=255, null=True, validators=[openedx.core.djangoapps.config_model_utils.models.validate_course_in_org], verbose_name='Course in Org'), + ), + ] diff --git a/openedx/features/course_duration_limits/migrations/0008_auto_20190313_1634.py b/openedx/features/course_duration_limits/migrations/0008_auto_20190313_1634.py new file mode 100644 index 0000000000..8b1c685b67 --- /dev/null +++ b/openedx/features/course_duration_limits/migrations/0008_auto_20190313_1634.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.20 on 2019-03-13 16:34 +from __future__ import unicode_literals + +from django.db import migrations, models +import openedx.core.djangoapps.config_model_utils.models + + +class Migration(migrations.Migration): + + dependencies = [ + ('course_duration_limits', '0007_auto_20190311_1919'), + ] + + operations = [ + migrations.AlterField( + model_name='coursedurationlimitconfig', + name='org_course', + field=models.CharField(blank=True, db_index=True, help_text="Configure values for all course runs associated with this course. This is should be formatted as 'org+course' (i.e. MITx+6.002x, HarvardX+CS50).", max_length=255, null=True, validators=[openedx.core.djangoapps.config_model_utils.models.validate_course_in_org], verbose_name='Course in Org'), + ), + ]