Skip to content

Commit 0bebccd

Browse files
committed
Added a data migration which adds 2 new WG states: 'Waiting for Implementation' and 'Held by WG'.
- Legacy-Id: 12969
1 parent 9bbd501 commit 0bebccd

1 file changed

Lines changed: 60 additions & 0 deletions

File tree

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# -*- coding: utf-8 -*-
2+
# Generated by Django 1.10.5 on 2017-03-04 04:58
3+
from __future__ import unicode_literals
4+
5+
from django.db import migrations
6+
from django.utils.text import slugify
7+
8+
reordered_states = [
9+
# old, new, slug
10+
(8, 10, 'chair-w'),
11+
(9, 11, 'writeupw'),
12+
(10, 12, 'sub-pub'),
13+
]
14+
15+
new_states = [
16+
(8, "Waiting for Implementation",
17+
"In some areas, it can be desirable to wait for multiple interoperable "
18+
"implementations before progressing a draft to be an RFC, and in some "
19+
"WGs this is required. This state should be entered after WG Last Call "
20+
"has completed."),
21+
(9, "Held by WG", "Held by WG, see document history for details.",),
22+
]
23+
24+
def forwards(apps,schema_editor):
25+
State = apps.get_model('doc', 'State')
26+
StateType = apps.get_model('doc', 'StateType')
27+
wg_type = StateType.objects.get(slug='draft-stream-ietf')
28+
# change order on some existing states to make room for the new ones
29+
for old_order, new_order, slug in reordered_states:
30+
state = State.objects.get(type=wg_type, slug=slug)
31+
state.order=new_order
32+
state.save()
33+
for order, name, desc in new_states:
34+
slug = slugify(name)
35+
State.objects.create(type=wg_type, slug=slug, name=name, used=True, desc=desc, order=order, )
36+
37+
38+
def backwards(apps,schema_editor):
39+
State = apps.get_model('doc', 'State')
40+
StateType = apps.get_model('doc', 'StateType')
41+
wg_type = StateType.objects.get(slug='draft-stream-ietf')
42+
# change order on some existing states to make room for the new ones
43+
for old_order, new_order, slug in reordered_states:
44+
state = State.objects.get(type=wg_type, slug=slug)
45+
state.order=old_order
46+
state.save()
47+
for order, name, desc in new_states:
48+
slug = slugify(name)
49+
State.objects.get(type=wg_type, slug=slug).delete()
50+
51+
52+
class Migration(migrations.Migration):
53+
54+
dependencies = [
55+
('doc', '0020_auto_20170224_0222'),
56+
]
57+
58+
operations = [
59+
migrations.RunPython(forwards, backwards),
60+
]

0 commit comments

Comments
 (0)