Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
from django.db import models, migrations
def set_course_metadata(apps, schema_editor):
Course = apps.get_model("course", "Course") # noqa
for course in Course.objects.all():
from course.content import (
get_course_repo, get_course_desc,
get_course_commit_sha)
repo = get_course_repo(course)
course_desc = get_course_desc(
repo, course,
get_course_commit_sha(course, participation=None))
course.name = course_desc.name
course.number = course_desc.number
course.time_period = course_desc.run
repo.close()
course.save()
class Migration(migrations.Migration):
dependencies = [
('course', '0074_flowpagedata_page_type'),
]
operations = [
migrations.AddField(
model_name='course',
name='end_date',
field=models.DateField(null=True, verbose_name='End date', blank=True),
),
migrations.AddField(
model_name='course',
name='name',
field=models.CharField(help_text="A human-readable name for the course. (e.g. 'Numerical Methods')", max_length=200, null=True),
),
migrations.AddField(
model_name='course',
name='number',
field=models.CharField(help_text="A human-readable course number/IDfor the course (e.g. 'CS123')", max_length=200, null=True),
),
migrations.AddField(
model_name='course',
name='start_date',
field=models.DateField(null=True, verbose_name='Start date', blank=True),
),
migrations.AddField(
model_name='course',
name='time_period',
field=models.CharField(help_text="A human-readable description of the time period for the course (e.g. 'Fall 2014')", max_length=200, null=True),
),
migrations.RemoveField(
model_name='course',
name='valid',
),
migrations.RunPython(set_course_metadata),
]