Skip to content

Commit

Permalink
refactor: remove unused old slug field from course
Browse files Browse the repository at this point in the history
DISCO-1770
  • Loading branch information
waheedahmed committed Jan 19, 2022
1 parent 30736e7 commit 7c7e9e8
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.2.10 on 2022-01-13 13:12

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('course_metadata', '0266_auto_20210624_1831'),
]

operations = [
migrations.RemoveField(
model_name='course',
name='slug',
),
]
2 changes: 0 additions & 2 deletions course_discovery/apps/course_metadata/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,6 @@ class Course(DraftModelMixin, PkSearchableMixin, CachedMixin, TimeStampedModel):
},
help_text=_('Add the course image')
)
slug = AutoSlugField(populate_from='key', editable=True, slugify_function=uslugify)
video = models.ForeignKey(Video, models.CASCADE, default=None, null=True, blank=True)
faq = NullHtmlField(verbose_name=_('FAQ'))
learner_testimonials = NullHtmlField()
Expand Down Expand Up @@ -1047,7 +1046,6 @@ def _update_or_create_official_version(self, course_run):

if creating:
official_version.canonical_course_run = course_run
official_version.slug = self.slug
official_version.save()
self.canonical_course_run = course_run.draft_version
self.save()
Expand Down
1 change: 0 additions & 1 deletion course_discovery/apps/course_metadata/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,6 @@ def test_official_created(self):
assert official_run.course.draft is False
assert official_run.course.draft_version == draft_run.course
assert official_run.course != draft_run.course
assert official_run.course.slug == draft_run.course.slug

official_entitlement = official_run.course.entitlements.first()
draft_entitlement = draft_run.course.entitlements.first()
Expand Down
3 changes: 0 additions & 3 deletions course_discovery/apps/course_metadata/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,6 @@ def test_ensure_draft_world_not_draft_course_given(self):
assert ensured_draft_course.uuid == not_draft_course.uuid
assert ensured_draft_course.draft

# Check slugs are equal
assert ensured_draft_course.slug == not_draft_course.slug

# Check authoring orgs are equal
assert list(ensured_draft_course.authoring_organizations.all()) ==\
list(not_draft_course.authoring_organizations.all())
Expand Down
1 change: 0 additions & 1 deletion course_discovery/apps/course_metadata/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ def ensure_draft_world(obj):
# We need to null this out because it will fail with a OneToOne uniqueness error when saving the draft
obj.canonical_course_run = None
draft_course, original_course = set_draft_state(obj, Course, related_attrs={'url_slug_history': []})
draft_course.slug = original_course.slug

# Move editors from the original course to the draft course since we only care about CourseEditors
# in the context of draft courses. This code is only necessary during the transition from using
Expand Down

0 comments on commit 7c7e9e8

Please sign in to comment.