This repository has been archived by the owner on Jan 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #819 from mitodl/rc/0.13.0
rc/0.13.0
- Loading branch information
Showing
26 changed files
with
1,714 additions
and
670 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import models, migrations | ||
from django.db.models import F | ||
|
||
from rest.util import default_slugify | ||
|
||
# pylint: skip-file | ||
|
||
|
||
def backfill_empty_slugs(apps, schema_editor): | ||
""" | ||
Finds all the objects in the Repository | ||
that do not have a slug and change the name; | ||
this will automatically create a new slug. | ||
""" | ||
Repository = apps.get_model("learningresources", "Repository") | ||
|
||
for repo in Repository.objects.filter(slug=''): | ||
repo.slug = default_slugify( | ||
repo.name, | ||
Repository._meta.model_name, | ||
lambda slug: Repository.objects.filter(slug=slug).exists() | ||
) | ||
repo.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('learningresources', '0017_learningresource_missing_title_update'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(backfill_empty_slugs) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.