Commit e567927e by Waheed Ahmed

Add default status unpublished for newly created runs.

Add default status unpublished for newly created course runs, also update
existing course runs with null/empty status to unpublished.

LEARNER-5202
parent 637d63d7
# -*- coding: utf-8 -*-
# Generated by Django 1.11.11 on 2018-05-11 14:06
from __future__ import unicode_literals
import djchoices.choices
from django.db import migrations, models
from course_discovery.apps.course_metadata.choices import CourseRunStatus
def change_runs_null_state_to_unpublished(apps, schema_editor):
CourseRun = apps.get_model('course_metadata', 'CourseRun')
for course_run in CourseRun.objects.filter(status=''):
course_run.status = CourseRunStatus.Unpublished
course_run.save()
class Migration(migrations.Migration):
dependencies = [
('course_metadata', '0082_person_salutation'),
]
operations = [
migrations.AlterField(
model_name='courserun',
name='status',
field=models.CharField(choices=[('published', 'Published'), ('unpublished', 'Unpublished')], db_index=True, default='unpublished', max_length=255, validators=[djchoices.choices.ChoicesValidator({'published': 'Published', 'unpublished': 'Unpublished'})]),
),
migrations.RunPython(change_runs_null_state_to_unpublished, migrations.RunPython.noop),
]
......@@ -451,8 +451,8 @@ class CourseRun(TimeStampedModel):
uuid = models.UUIDField(default=uuid4, editable=False, verbose_name=_('UUID'))
course = models.ForeignKey(Course, related_name='course_runs')
key = models.CharField(max_length=255, unique=True)
status = models.CharField(max_length=255, null=False, blank=False, db_index=True, choices=CourseRunStatus.choices,
validators=[CourseRunStatus.validator])
status = models.CharField(default=CourseRunStatus.Unpublished, max_length=255, null=False, blank=False,
db_index=True, choices=CourseRunStatus.choices, validators=[CourseRunStatus.validator])
title_override = models.CharField(
max_length=255, default=None, null=True, blank=True,
help_text=_(
......
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