|
| 1 | +# Generated by Django 5.2.11 on 2026-02-10 03:08 |
| 2 | + |
| 3 | +import django.db.models.deletion |
| 4 | +import opaque_keys.edx.django.models |
| 5 | +import openedx_catalog.models.catalog_course |
| 6 | +import openedx_django_lib.fields |
| 7 | +from django.db import migrations, models |
| 8 | + |
| 9 | + |
| 10 | +class Migration(migrations.Migration): |
| 11 | + initial = True |
| 12 | + |
| 13 | + dependencies = [ |
| 14 | + ("organizations", "0004_auto_20230727_2054"), |
| 15 | + ] |
| 16 | + |
| 17 | + operations = [ |
| 18 | + migrations.CreateModel( |
| 19 | + name="CatalogCourse", |
| 20 | + fields=[ |
| 21 | + ( |
| 22 | + "id", |
| 23 | + models.BigAutoField( |
| 24 | + editable=False, |
| 25 | + help_text="The internal database ID for this catalog course. Should not be exposed to users nor in APIs.", |
| 26 | + primary_key=True, |
| 27 | + serialize=False, |
| 28 | + verbose_name="Primary Key", |
| 29 | + ), |
| 30 | + ), |
| 31 | + ( |
| 32 | + "course_code", |
| 33 | + openedx_django_lib.fields.MultiCollationCharField( |
| 34 | + db_collations={"mysql": "utf8mb4_bin", "sqlite": "BINARY"}, |
| 35 | + help_text='The course ID, e.g. "Math100".', |
| 36 | + max_length=255, |
| 37 | + ), |
| 38 | + ), |
| 39 | + ( |
| 40 | + "display_name", |
| 41 | + models.CharField( |
| 42 | + help_text='The full name of this catalog course. e.g. "Introduction to Calculus". Individual course runs may override this, e.g. "Into to Calc (Fall 2026 with Dr. Newton)".', |
| 43 | + max_length=255, |
| 44 | + ), |
| 45 | + ), |
| 46 | + ( |
| 47 | + "language", |
| 48 | + models.CharField( |
| 49 | + default=openedx_catalog.models.catalog_course.get_default_language_code, |
| 50 | + help_text='The code representing the language of this catalog course\'s content. The first two digits must be the lowercase ISO 639-1 language code. e.g. "en", "es", "en-us", "pt-br". ', |
| 51 | + max_length=64, |
| 52 | + ), |
| 53 | + ), |
| 54 | + ( |
| 55 | + "org", |
| 56 | + models.ForeignKey( |
| 57 | + on_delete=django.db.models.deletion.PROTECT, |
| 58 | + to="organizations.organization", |
| 59 | + to_field="short_name", |
| 60 | + ), |
| 61 | + ), |
| 62 | + ], |
| 63 | + options={ |
| 64 | + "verbose_name": "Catalog Course", |
| 65 | + "verbose_name_plural": "Catalog Courses", |
| 66 | + }, |
| 67 | + ), |
| 68 | + migrations.CreateModel( |
| 69 | + name="CourseRun", |
| 70 | + fields=[ |
| 71 | + ( |
| 72 | + "id", |
| 73 | + models.BigAutoField( |
| 74 | + editable=False, |
| 75 | + help_text="The internal database ID for this course. Should not be exposed to users nor in APIs.", |
| 76 | + primary_key=True, |
| 77 | + serialize=False, |
| 78 | + verbose_name="Primary Key", |
| 79 | + ), |
| 80 | + ), |
| 81 | + ( |
| 82 | + "course_id", |
| 83 | + opaque_keys.edx.django.models.CourseKeyField( |
| 84 | + editable=False, |
| 85 | + help_text="The main identifier for this course. Includes the org, course code, and run.", |
| 86 | + max_length=255, |
| 87 | + unique=True, |
| 88 | + verbose_name="Course ID", |
| 89 | + ), |
| 90 | + ), |
| 91 | + ( |
| 92 | + "run", |
| 93 | + openedx_django_lib.fields.MultiCollationCharField( |
| 94 | + db_collations={"mysql": "utf8mb4_bin", "sqlite": "BINARY"}, |
| 95 | + help_text='The code that identifies this particular run of the course, e.g. "2026", "2026Fall" or "2T2026"', |
| 96 | + max_length=128, |
| 97 | + ), |
| 98 | + ), |
| 99 | + ( |
| 100 | + "display_name", |
| 101 | + models.CharField( |
| 102 | + blank=True, |
| 103 | + help_text='The full name of this course. e.g. "Introduction to Calculus". This is required and will override the name of the catalog course. Leave blank to use the same name as the catalog course. ', |
| 104 | + max_length=255, |
| 105 | + ), |
| 106 | + ), |
| 107 | + ( |
| 108 | + "catalog_course", |
| 109 | + models.ForeignKey( |
| 110 | + on_delete=django.db.models.deletion.PROTECT, |
| 111 | + related_name="runs", |
| 112 | + to="openedx_catalog.catalogcourse", |
| 113 | + ), |
| 114 | + ), |
| 115 | + ], |
| 116 | + options={ |
| 117 | + "verbose_name": "Course Run", |
| 118 | + "verbose_name_plural": "Course Runs", |
| 119 | + }, |
| 120 | + ), |
| 121 | + migrations.AddConstraint( |
| 122 | + model_name="catalogcourse", |
| 123 | + constraint=models.UniqueConstraint( |
| 124 | + fields=("org", "course_code"), name="oex_catalog_catalog_course_org_code_pair_uniq" |
| 125 | + ), |
| 126 | + ), |
| 127 | + migrations.AddConstraint( |
| 128 | + model_name="catalogcourse", |
| 129 | + constraint=models.CheckConstraint( |
| 130 | + condition=models.Q(("course_code__length__gt", 0)), |
| 131 | + name="oex_catalog_catalogcourse_course_code_not_blank", |
| 132 | + ), |
| 133 | + ), |
| 134 | + migrations.AddConstraint( |
| 135 | + model_name="catalogcourse", |
| 136 | + constraint=models.CheckConstraint( |
| 137 | + condition=models.Q(("language__length__gt", 0)), name="oex_catalog_catalogcourse_language_not_blank" |
| 138 | + ), |
| 139 | + ), |
| 140 | + migrations.AddConstraint( |
| 141 | + model_name="catalogcourse", |
| 142 | + constraint=models.CheckConstraint( |
| 143 | + condition=models.Q(("display_name__length__gt", 0)), |
| 144 | + name="oex_catalog_catalogcourse_display_name_not_blank", |
| 145 | + ), |
| 146 | + ), |
| 147 | + migrations.AddConstraint( |
| 148 | + model_name="courserun", |
| 149 | + constraint=models.UniqueConstraint( |
| 150 | + fields=("catalog_course", "run"), name="oex_catalog_courserun_catalog_course_run_uniq" |
| 151 | + ), |
| 152 | + ), |
| 153 | + migrations.AddConstraint( |
| 154 | + model_name="courserun", |
| 155 | + constraint=models.CheckConstraint( |
| 156 | + condition=models.Q(("run__length__gt", 0)), name="oex_catalog_courserun_run_not_blank" |
| 157 | + ), |
| 158 | + ), |
| 159 | + migrations.AddConstraint( |
| 160 | + model_name="courserun", |
| 161 | + constraint=models.CheckConstraint( |
| 162 | + condition=models.Q(("display_name__length__gt", 0)), name="oex_catalog_courserun_display_name_not_blank" |
| 163 | + ), |
| 164 | + ), |
| 165 | + ] |
0 commit comments