|
18 | 18 | from redesign.importing.utils import get_or_create_email |
19 | 19 |
|
20 | 20 | from ietf.idtracker.models import IESGLogin, AreaDirector, PersonOrOrgInfo, WGChair, WGEditor, WGSecretary, WGTechAdvisor, ChairsHistory, Role as OldRole, Acronym, IRTFChair |
| 21 | +from ietf.proceedings.models import IESGHistory |
21 | 22 |
|
22 | 23 |
|
23 | 24 | # assumptions: |
24 | 25 | # - persons have been imported |
25 | 26 | # - groups have been imported |
26 | 27 |
|
27 | 28 | # imports IESGLogin, AreaDirector, WGEditor, WGChair, IRTFChair, |
28 | | -# WGSecretary, WGTechAdvisor, NomCom chairs from ChairsHistory, |
| 29 | +# WGSecretary, WGTechAdvisor, NomCom chairs from ChairsHistory, IESGHistory |
29 | 30 |
|
30 | 31 | # FIXME: should probably import Role, LegacyWgPassword, LegacyLiaisonUser |
31 | 32 |
|
|
81 | 82 | except PersonOrOrgInfo.DoesNotExist: |
82 | 83 | print "SKIPPING WGChair", acronym, "with invalid person id", o.person_id |
83 | 84 | continue |
84 | | - |
85 | | - if acronym in ("apples", "apptsv", "usac", "null", "dirdir"): |
86 | | - print "SKIPPING WGChair", acronym, o.person |
| 85 | + |
| 86 | + try: |
| 87 | + group = Group.objects.get(acronym=acronym) |
| 88 | + except Group.DoesNotExist: |
| 89 | + print "SKIPPING WGChair", o.person, "with non-existing group", acronym |
87 | 90 | continue |
88 | 91 |
|
89 | 92 | print "importing WGChair", acronym, o.person |
90 | 93 |
|
91 | 94 | email = get_or_create_email(o, create_fake=True) |
92 | | - group = Group.objects.get(acronym=acronym) |
93 | 95 |
|
94 | 96 | Role.objects.get_or_create(name=chair_role, group=group, email=email) |
95 | 97 |
|
|
170 | 172 | else: |
171 | 173 | Role.objects.get_or_create(name=role_type, group=area, email=email) |
172 | 174 |
|
| 175 | +# IESGHistory |
| 176 | +emails_for_time = {} |
| 177 | +for o in IESGHistory.objects.all().order_by('meeting__start_date', 'pk'): |
| 178 | + print "importing IESGHistory", o.pk, o.area, o.person, o.meeting |
| 179 | + email = get_or_create_email(o, create_fake=False) |
| 180 | + if not email: |
| 181 | + "SKIPPING IESGHistory with unknown email" |
| 182 | + continue |
173 | 183 |
|
| 184 | + # our job here is to make sure we either have the same AD today or |
| 185 | + # got proper GroupHistory and RoleHistory objects in the database; |
| 186 | + # there's only incomplete information available in the database so |
| 187 | + # the reconstructed history will necessarily not be entirely |
| 188 | + # accurate, just good enough to conclude who was AD |
| 189 | + area = Group.objects.get(acronym=o.area.area_acronym.acronym, type="area") |
| 190 | + meeting_time = datetime.datetime.combine(o.meeting.start_date, datetime.time(0, 0, 0)) |
| 191 | + |
| 192 | + key = (area, meeting_time) |
| 193 | + if not key in emails_for_time: |
| 194 | + emails_for_time[key] = [] |
| 195 | + |
| 196 | + emails_for_time[key].append(email) |
| 197 | + |
| 198 | + history = find_group_history_active_at(area, meeting_time) |
| 199 | + if (history and history.rolehistory_set.filter(email__person=email.person) or |
| 200 | + not history and area.role_set.filter(email__person=email.person)): |
| 201 | + continue |
| 202 | + |
| 203 | + if history and history.time == meeting_time: |
| 204 | + # add to existing GroupHistory |
| 205 | + RoleHistory.objects.create(name=area_director_role, group=history, email=email) |
| 206 | + else: |
| 207 | + existing = history if history else area |
| 208 | + |
| 209 | + h = GroupHistory(group=area, |
| 210 | + charter=existing.charter, |
| 211 | + time=meeting_time, |
| 212 | + name=existing.name, |
| 213 | + acronym=existing.acronym, |
| 214 | + state=existing.state, |
| 215 | + type=existing.type, |
| 216 | + parent=existing.parent, |
| 217 | + iesg_state=existing.iesg_state, |
| 218 | + ad=existing.ad, |
| 219 | + list_email=existing.list_email, |
| 220 | + list_subscribe=existing.list_subscribe, |
| 221 | + list_archive=existing.list_archive, |
| 222 | + comments=existing.comments, |
| 223 | + ) |
| 224 | + h.save() |
| 225 | + |
| 226 | + # we need to add all emails for this area at this time |
| 227 | + # because the new GroupHistory resets the known roles |
| 228 | + for e in emails_for_time[key]: |
| 229 | + RoleHistory.objects.get_or_create(name=area_director_role, group=h, email=e) |
| 230 | + |
0 commit comments