-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
161 additions
and
271 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
milestones/migrations/0002_data__seed_relationship_types.py
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,36 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
|
||
from milestones.data import fetch_milestone_relationship_types | ||
|
||
|
||
def seed_relationship_types(apps, schema_editor): | ||
"""Seed the relationship types.""" | ||
MilestoneRelationshipType = apps.get_model("milestones", "MilestoneRelationshipType") | ||
db_alias = schema_editor.connection.alias | ||
for name in fetch_milestone_relationship_types().values(): | ||
MilestoneRelationshipType.objects.using(db_alias).get_or_create( | ||
name=name, | ||
description='Autogenerated milestone relationship type "{}"'.format(name), | ||
) | ||
|
||
|
||
def delete_relationship_types(apps, schema_editor): | ||
"""Clean up any relationships we made.""" | ||
MilestoneRelationshipType = apps.get_model("milestones", "MilestoneRelationshipType") | ||
db_alias = schema_editor.connection.alias | ||
for name in fetch_milestone_relationship_types().values(): | ||
MilestoneRelationshipType.objects.using(db_alias).filter(name=name).delete() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('milestones', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(seed_relationship_types, delete_relationship_types), | ||
] |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,6 @@ | |
|
||
'milestones', | ||
'django_nose', | ||
'south', | ||
) | ||
|
||
MIDDLEWARE_CLASSES = {} |
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