Skip to content

Commit c5b0b9c

Browse files
committed
Figure out some missing groups, spit it those the script doesn't handle
- Legacy-Id: 2728
1 parent 518a038 commit c5b0b9c

1 file changed

Lines changed: 63 additions & 32 deletions

File tree

redesign/import-groups.py

Lines changed: 63 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -21,34 +21,53 @@
2121
# FIXME: should also import IRTF
2222

2323
# make sure we got the names
24-
GroupStateName.objects.get_or_create(slug="bof", name="BOF") # is this a state?
25-
GroupStateName.objects.get_or_create(slug="proposed", name="Proposed")
26-
GroupStateName.objects.get_or_create(slug="active", name="Active")
27-
GroupStateName.objects.get_or_create(slug="dormant", name="Dormant")
28-
GroupStateName.objects.get_or_create(slug="conclude", name="Concluded")
29-
GroupStateName.objects.get_or_create(slug="unknown", name="Unknown")
30-
31-
GroupTypeName.objects.get_or_create(slug="ietf", name="IETF")
32-
GroupTypeName.objects.get_or_create(slug="area", name="Area")
33-
GroupTypeName.objects.get_or_create(slug="wg", name="WG")
34-
GroupTypeName.objects.get_or_create(slug="rg", name="RG")
35-
GroupTypeName.objects.get_or_create(slug="team", name="Team")
36-
GroupTypeName.objects.get_or_create(slug="individ", name="Individual")
37-
# FIXME: what about AG (area group?)?
24+
def name(name_class, slug, name, desc=""):
25+
# create if it doesn't exist, set name and desc
26+
obj, _ = name_class.objects.get_or_create(slug=slug)
27+
obj.name = name
28+
obj.desc = desc
29+
obj.save()
30+
return obj
31+
32+
state_names = dict(
33+
bof=name(GroupStateName, slug="bof", name="BOF"),
34+
proposed=name(GroupStateName, slug="proposed", name="Proposed"),
35+
active=name(GroupStateName, slug="active", name="Active"),
36+
dormant=name(GroupStateName, slug="dormant", name="Dormant"),
37+
conclude=name(GroupStateName, slug="conclude", name="Concluded"),
38+
unknown=name(GroupStateName, slug="unknown", name="Unknown"),
39+
)
40+
41+
type_names = dict(
42+
ietf=name(GroupTypeName, slug="ietf", name="IETF"),
43+
area=name(GroupTypeName, slug="area", name="Area"),
44+
wg=name(GroupTypeName, slug="wg", name="WG"),
45+
rg=name(GroupTypeName, slug="rg", name="RG"),
46+
team=name(GroupTypeName, slug="team", name="Team"),
47+
individ=name(GroupTypeName, slug="individ", name="Individual"),
48+
)
49+
50+
# make sure we got the IESG so we can use it as parent for areas
51+
iesg_group, _ = Group.objects.get_or_create(acronym="iesg")
52+
iesg_group.name = "IESG"
53+
iesg_group.state = state_names["active"]
54+
iesg_group.type = type_names["ietf"]
55+
iesg_group.save()
3856

3957

4058
# Area
4159
for o in Area.objects.all():
4260
group, _ = Group.objects.get_or_create(acronym=o.area_acronym.acronym)
4361
group.name = o.area_acronym.name
4462
if o.status.status == "Active":
45-
s = GroupStateName.objects.get(slug="active")
63+
s = state_names["active"]
4664
elif o.status.status == "Concluded":
47-
s = GroupStateName.objects.get(slug="conclude")
65+
s = state_names["conclude"]
4866
elif o.status.status == "Unknown":
49-
s = GroupStateName.objects.get(slug="unknown")
67+
s = state_names["unknown"]
5068
group.state = s
51-
group.type = GroupTypeName.objects.get(slug="area")
69+
group.type = type_names["area"]
70+
group.parent = iesg_group
5271

5372
# FIXME: missing fields from old: concluded_date, comments, last_modified_date, extra_email_addresses
5473

@@ -64,36 +83,48 @@
6483
group.name = o.group_acronym.name
6584
# state
6685
if o.group_type.type == "BOF":
67-
s = GroupStateName.objects.get(slug="bof")
68-
elif o.group_type.type == "PWG": # FIXME: right?
69-
s = GroupStateName.objects.get(slug="proposed")
86+
s = state_names["bof"]
87+
elif o.group_type.type == "PWG":
88+
s = state_names["proposed"]
7089
elif o.status.status == "Active":
71-
s = GroupStateName.objects.get(slug="active")
90+
s = state_names["active"]
7291
elif o.status.status == "Dormant":
73-
s = GroupStateName.objects.get(slug="dormant")
92+
s = state_names["dormant"]
7493
elif o.status.status == "Concluded":
75-
s = GroupStateName.objects.get(slug="conclude")
94+
s = state_names["conclude"]
7695
group.state = s
7796
# type
7897
if o.group_type.type == "TEAM":
79-
group.type = GroupTypeName.objects.get(slug="team")
98+
group.type = type_names["team"]
8099
elif o.group_type.type == "AG":
81-
# this contains groups like
82-
#apptsv, none, saag, iesg, iab, tsvdir, apples, usac, secdir, apparea, null, opsarea, rtgarea, usvarea, genarea, tsvarea, raiarea, dirdir
83-
# which we currently just ignore
84100
if o.group_acronym.acronym == "none":
85-
group.type = GroupTypeName.objects.get(slug="individ")
101+
# none means individual
102+
group.type = type_names["individ"]
103+
elif o.group_acronym.acronym == "iab":
104+
group.type = type_names["ietf"]
105+
group.parent = None
106+
elif o.group_acronym.acronym in ("tsvdir", "secdir", "saag"):
107+
group.type = type_names["team"]
108+
elif o.group_acronym.acronym == "iesg":
109+
pass # we already treated iesg
110+
elif o.group_acronym.acronym in ('apparea', 'opsarea', 'rtgarea', 'usvarea', 'genarea', 'tsvarea', 'raiarea'):
111+
pass # we already treated areas
86112
else:
113+
# the remaining groups are
114+
# apptsv, apples, usac, null, dirdir
115+
# for now, we don't transfer them
87116
if group.id:
88117
group.delete()
118+
print "not transferring", o.group_acronym.acronym, o.group_acronym.name
89119
continue
90120
else: # PWG/BOF/WG
91-
group.type = GroupTypeName.objects.get(slug="wg")
121+
# some BOFs aren't WG-forming but we currently classify all as WGs
122+
group.type = type_names["wg"]
92123

93124
if o.area:
94125
group.parent = Group.objects.get(acronym=o.area.area.area_acronym.acronym)
95-
else:
96-
print "no area for", group.acronym, group.name, group.type, group.state
126+
elif not group.parent:
127+
print "no area/parent for", group.acronym, group.name, group.type, group.state
97128

98129
# FIXME: missing fields from old: proposed_date, start_date, dormant_date, concluded_date, meeting_scheduled, email_address, email_subscribe, email_keyword, email_archive, comments, last_modified_date, meeting_scheduled_old
99130

0 commit comments

Comments
 (0)