Skip to content

Commit 45abea0

Browse files
committed
Convert IETF111 Constraints
- Legacy-Id: 19285
1 parent f0511fd commit 45abea0

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Generated by Django 2.2.20 on 2021-05-13 07:51
2+
3+
from django.db import migrations
4+
5+
6+
replacement_slugs = (
7+
('conflict', 'chair_conflict'),
8+
('conflic2', 'tech_overlap'),
9+
('conflic3', 'key_participant'),
10+
)
11+
12+
13+
def affected(constraint_qs):
14+
"""Filter constraints, keeping only those to be updated"""
15+
# The constraints were renamed in the UI in commit 16699 on 2019-09-03.
16+
# This was between meetings 105 and 106. Assuming this migration and
17+
# the new conflict types are in place before meeting 111, these
18+
# are the meetings for which the UI disagreed with the constraint
19+
# type actually created.
20+
affected_meetings = ['111']
21+
return constraint_qs.filter(meeting__number__in=affected_meetings)
22+
23+
24+
def forward(apps, schema_editor):
25+
Constraint = apps.get_model('meeting', 'Constraint')
26+
affected_constraints = affected(Constraint.objects.all())
27+
for old, new in replacement_slugs:
28+
affected_constraints.filter(name_id=old).update(name_id=new)
29+
30+
31+
def reverse(apps, schema_editor):
32+
Constraint = apps.get_model('meeting', 'Constraint')
33+
affected_constraints = affected(Constraint.objects.all())
34+
for old, new in replacement_slugs:
35+
affected_constraints.filter(name_id=new).update(name_id=old)
36+
37+
38+
class Migration(migrations.Migration):
39+
40+
dependencies = [
41+
('meeting', '0043_populate_meeting_group_conflict_types'),
42+
('name', '0027_add_bofrequest'),
43+
]
44+
45+
operations = [
46+
migrations.RunPython(forward, reverse),
47+
]

0 commit comments

Comments
 (0)