Made some migrations work backwards, too.
- Legacy-Id: 11964
This commit is contained in:
parent
ecd4491150
commit
9cb627f1cc
|
@ -15,11 +15,20 @@ class Migration(migrations.Migration):
|
|||
used=True,
|
||||
order=8)
|
||||
|
||||
def del_draft_submission_state_name(apps, schema_editor):
|
||||
# We can't import the model directly as it may be a newer
|
||||
# version than this migration expects. We use the historical version.
|
||||
DraftSubmissionStateName = apps.get_model("name", "DraftSubmissionStateName")
|
||||
DraftSubmissionStateName.objects.filter(slug="waiting-for-draft",
|
||||
name="Manual Post Waiting for Draft",
|
||||
desc="",
|
||||
used=True,
|
||||
order=8).delete()
|
||||
|
||||
dependencies = [
|
||||
('submit', '0011_submissionemail'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(add_draft_submission_state_name),
|
||||
migrations.RunPython(add_draft_submission_state_name, del_draft_submission_state_name),
|
||||
]
|
||||
|
|
|
@ -30,10 +30,13 @@ class Migration(migrations.Migration):
|
|||
|
||||
remove_submission_files(submission)
|
||||
|
||||
def reverse(apps, schema_editor):
|
||||
pass
|
||||
|
||||
dependencies = [
|
||||
('submit', '0012_auto_20160414_1902'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(remove_old_submissions),
|
||||
migrations.RunPython(remove_old_submissions, reverse),
|
||||
]
|
||||
|
|
|
@ -10,16 +10,25 @@ class Migration(migrations.Migration):
|
|||
|
||||
cancelled = DraftSubmissionStateName.objects.get(slug="cancel")
|
||||
posted = DraftSubmissionStateName.objects.get(slug="posted")
|
||||
mad = DraftSubmissionStateName.objects.get(slug="waiting-for-draft")
|
||||
waiting = DraftSubmissionStateName.objects.get(slug="waiting-for-draft")
|
||||
|
||||
mad.next_states.add(cancelled)
|
||||
mad.next_states.add(posted)
|
||||
mad.save()
|
||||
waiting.next_states.add(cancelled)
|
||||
waiting.next_states.add(posted)
|
||||
|
||||
def reverse(apps, schema_editor):
|
||||
DraftSubmissionStateName = apps.get_model("name", "DraftSubmissionStateName")
|
||||
|
||||
cancelled = DraftSubmissionStateName.objects.get(slug="cancel")
|
||||
posted = DraftSubmissionStateName.objects.get(slug="posted")
|
||||
waiting = DraftSubmissionStateName.objects.get(slug="waiting-for-draft")
|
||||
|
||||
waiting.next_states.remove(cancelled)
|
||||
waiting.next_states.remove(posted)
|
||||
|
||||
dependencies = [
|
||||
('submit', '0013_auto_20160415_2120'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(add_next_states),
|
||||
migrations.RunPython(add_next_states, reverse),
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue