|
21 | 21 | # FIXME: should also import IRTF |
22 | 22 |
|
23 | 23 | # 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() |
38 | 56 |
|
39 | 57 |
|
40 | 58 | # Area |
41 | 59 | for o in Area.objects.all(): |
42 | 60 | group, _ = Group.objects.get_or_create(acronym=o.area_acronym.acronym) |
43 | 61 | group.name = o.area_acronym.name |
44 | 62 | if o.status.status == "Active": |
45 | | - s = GroupStateName.objects.get(slug="active") |
| 63 | + s = state_names["active"] |
46 | 64 | elif o.status.status == "Concluded": |
47 | | - s = GroupStateName.objects.get(slug="conclude") |
| 65 | + s = state_names["conclude"] |
48 | 66 | elif o.status.status == "Unknown": |
49 | | - s = GroupStateName.objects.get(slug="unknown") |
| 67 | + s = state_names["unknown"] |
50 | 68 | group.state = s |
51 | | - group.type = GroupTypeName.objects.get(slug="area") |
| 69 | + group.type = type_names["area"] |
| 70 | + group.parent = iesg_group |
52 | 71 |
|
53 | 72 | # FIXME: missing fields from old: concluded_date, comments, last_modified_date, extra_email_addresses |
54 | 73 |
|
|
64 | 83 | group.name = o.group_acronym.name |
65 | 84 | # state |
66 | 85 | 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"] |
70 | 89 | elif o.status.status == "Active": |
71 | | - s = GroupStateName.objects.get(slug="active") |
| 90 | + s = state_names["active"] |
72 | 91 | elif o.status.status == "Dormant": |
73 | | - s = GroupStateName.objects.get(slug="dormant") |
| 92 | + s = state_names["dormant"] |
74 | 93 | elif o.status.status == "Concluded": |
75 | | - s = GroupStateName.objects.get(slug="conclude") |
| 94 | + s = state_names["conclude"] |
76 | 95 | group.state = s |
77 | 96 | # type |
78 | 97 | if o.group_type.type == "TEAM": |
79 | | - group.type = GroupTypeName.objects.get(slug="team") |
| 98 | + group.type = type_names["team"] |
80 | 99 | 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 |
84 | 100 | 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 |
86 | 112 | else: |
| 113 | + # the remaining groups are |
| 114 | + # apptsv, apples, usac, null, dirdir |
| 115 | + # for now, we don't transfer them |
87 | 116 | if group.id: |
88 | 117 | group.delete() |
| 118 | + print "not transferring", o.group_acronym.acronym, o.group_acronym.name |
89 | 119 | continue |
90 | 120 | 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"] |
92 | 123 |
|
93 | 124 | if o.area: |
94 | 125 | 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 |
97 | 128 |
|
98 | 129 | # 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 |
99 | 130 |
|
|
0 commit comments