Skip to content

Commit

Permalink
fix: add wit area. imperfectly update m2ms (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
rjsparks authored Oct 25, 2024
1 parent 7754698 commit 76390ac
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
35 changes: 35 additions & 0 deletions guides/migrations/0022_add_wit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright The IETF Trust 2024, All Rights Reserved

from django.db import migrations

def forward(apps, schema_editor):
Area = apps.get_model("guides","Area")
Participant = apps.get_model("guides","Participant")
Guide = apps.get_model("guides","Guide")
wit = Area.objects.create(area="WIT: Web and Intenet Transport", short="wit")
for p in Participant.objects.all():
if p.areas.filter(short="tsv").exists():
p.areas.add(wit)
for g in Guide.objects.all():
if g.areas.filter(short="tsv").exists():
g.areas.add(wit)

def reverse(apps, schema_editor):
Area = apps.get_model("guides","Area")
Participant = apps.get_model("guides","Participant")
Guide = apps.get_model("guides","Guide")
for g in Guide.objects.all():
g.areas.filter(short="wit").delete()
for p in Participant.objects.all():
p.areas.filter(short="wit").delete()
Area.objects.filter(short="wit").delete()

class Migration(migrations.Migration):

dependencies = [
('guides', '0021_guide_gender_pref'),
]

operations = [
migrations.RunPython(forward,reverse),
]
6 changes: 4 additions & 2 deletions guides/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
AREA_OPS = "OPS"
AREA_RTG = "RTG"
AREA_SEC = "SEC"
AREA_TSG = "TSG"
AREA_TSV = "TSV"
AREA_WIT = "WIT"
AREA_UNKNOWN = "UNKNOWN"

# note: these intentionally sort with NO being last
Expand All @@ -95,7 +96,8 @@
(AREA_OPS, "Operations and Management"),
(AREA_RTG, "Routing"),
(AREA_SEC, "Security"),
(AREA_TSG, "Transport"),
(AREA_TSV, "Transport"),
(AREA_WIT, "Web and Internet Transport"),
(AREA_UNKNOWN, "I don't know yet")
)

Expand Down

0 comments on commit 76390ac

Please sign in to comment.