From 05dd63e85a21297262d6f4654e69f189288118d0 Mon Sep 17 00:00:00 2001 From: Gabe Mulley Date: Thu, 26 Oct 2017 10:32:33 -0400 Subject: [PATCH] fix tests, I hope? --- ..._orgdynamicupgradedeadlineconfiguration.py | 10 +++++ lms/djangoapps/courseware/models.py | 40 +++++++++++++------ 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/lms/djangoapps/courseware/migrations/0005_orgdynamicupgradedeadlineconfiguration.py b/lms/djangoapps/courseware/migrations/0005_orgdynamicupgradedeadlineconfiguration.py index 4c34fd1080..2d0c7584f6 100644 --- a/lms/djangoapps/courseware/migrations/0005_orgdynamicupgradedeadlineconfiguration.py +++ b/lms/djangoapps/courseware/migrations/0005_orgdynamicupgradedeadlineconfiguration.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion from django.conf import settings +import courseware.models class Migration(migrations.Migration): @@ -25,5 +26,14 @@ class Migration(migrations.Migration): ('opt_out', models.BooleanField(default=False, help_text='Disable the dynamic upgrade deadline for this organization.')), ('changed_by', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, editable=False, to=settings.AUTH_USER_MODEL, null=True, verbose_name='Changed by')), ], + options={ + 'ordering': ('-change_date',), + 'abstract': False, + }, + bases=(courseware.models.OptOutDynamicUpgradeDeadlineMixin, models.Model), + ), + migrations.AlterModelOptions( + name='coursedynamicupgradedeadlineconfiguration', + options={'ordering': ('-change_date',)}, ), ] diff --git a/lms/djangoapps/courseware/models.py b/lms/djangoapps/courseware/models.py index c0f855e123..e35d31357a 100644 --- a/lms/djangoapps/courseware/models.py +++ b/lms/djangoapps/courseware/models.py @@ -379,27 +379,21 @@ class DynamicUpgradeDeadlineConfiguration(ConfigurationModel): ) -class OptOutDynamicUpgradeDeadlineConfiguration(DynamicUpgradeDeadlineConfiguration): - """ Dynamic upgrade deadline configuration with opt-out switch. - - This is an abstract model that both CourseDynamicUpgradeDeadlineConfiguration and - OrgDynamicUpgradeDeadlineConfiguration inherit. +class OptOutDynamicUpgradeDeadlineMixin(object): + """ + Provides convenience methods for interpreting the enabled and opt out status. """ - opt_out = models.BooleanField( - default=False, - help_text=_('Disable the dynamic upgrade deadline for this course run.') - ) def opted_in(self): - """Convienence function that returns True if this config model is both enabled and opt_out is False""" + """Convenience function that returns True if this config model is both enabled and opt_out is False""" return self.enabled and not self.opt_out def opted_out(self): - """Convienence function that returns True if this config model is both enabled and opt_out is True""" + """Convenience function that returns True if this config model is both enabled and opt_out is True""" return self.enabled and self.opt_out -class CourseDynamicUpgradeDeadlineConfiguration(OptOutDynamicUpgradeDeadlineConfiguration): +class CourseDynamicUpgradeDeadlineConfiguration(OptOutDynamicUpgradeDeadlineMixin, ConfigurationModel): """ Per-course run configuration for dynamic upgrade deadlines. @@ -410,8 +404,18 @@ class CourseDynamicUpgradeDeadlineConfiguration(OptOutDynamicUpgradeDeadlineConf course_id = CourseKeyField(max_length=255, db_index=True) + deadline_days = models.PositiveSmallIntegerField( + default=21, + help_text=_('Number of days a learner has to upgrade after content is made available') + ) -class OrgDynamicUpgradeDeadlineConfiguration(OptOutDynamicUpgradeDeadlineConfiguration): + opt_out = models.BooleanField( + default=False, + help_text=_('Disable the dynamic upgrade deadline for this course run.') + ) + + +class OrgDynamicUpgradeDeadlineConfiguration(OptOutDynamicUpgradeDeadlineMixin, ConfigurationModel): """ Per-org configuration for dynamic upgrade deadlines. @@ -421,3 +425,13 @@ class OrgDynamicUpgradeDeadlineConfiguration(OptOutDynamicUpgradeDeadlineConfigu KEY_FIELDS = ('org_id',) org_id = models.CharField(max_length=255, db_index=True) + + deadline_days = models.PositiveSmallIntegerField( + default=21, + help_text=_('Number of days a learner has to upgrade after content is made available') + ) + + opt_out = models.BooleanField( + default=False, + help_text=_('Disable the dynamic upgrade deadline for this organization.') + )