Import IESGHistory as GroupHistory and port meeting views to it
- Legacy-Id: 3301
This commit is contained in:
parent
be6f266052
commit
ba29fa9c7d
|
@ -498,3 +498,26 @@ class SlideProxy(Document):
|
|||
return "%s/slides/%s" % (self.meeting_id, self.external_url)
|
||||
class Meta:
|
||||
proxy = True
|
||||
|
||||
class IESGHistoryProxy(Person):
|
||||
def from_object(self, base):
|
||||
for f in base._meta.fields:
|
||||
setattr(self, f.name, getattr(base, f.name))
|
||||
return self
|
||||
|
||||
#meeting = models.ForeignKey(Meeting, db_column='meeting_num')
|
||||
def from_role(self, role):
|
||||
self.from_object(role.email.person)
|
||||
from redesign.group.proxy import Area
|
||||
self.area = Area().from_object(role.group)
|
||||
self.affiliation = "" #role.email.affiliation
|
||||
return self
|
||||
#area = models.ForeignKey(Area, db_column='area_acronym_id')
|
||||
#person = models.ForeignKey(PersonOrOrgInfo, db_column='person_or_org_tag')
|
||||
@property
|
||||
def person(self):
|
||||
return self
|
||||
#def __str__(self):
|
||||
# return "IESG%s: %s (%s)" % (self.meeting_id, self.person,self.area)
|
||||
class Meta:
|
||||
proxy = True
|
||||
|
|
|
@ -138,11 +138,18 @@ def agenda_infoREDESIGN(num=None):
|
|||
|
||||
update = Switches().from_object(meeting)
|
||||
venue = meeting.meeting_venue
|
||||
|
||||
ads = list(IESGHistory.objects.select_related().filter(meeting=int(meeting.number)))
|
||||
if not ads:
|
||||
ads = list(IESGHistory.objects.select_related().filter(meeting=int(meeting.number)-1))
|
||||
ads.sort(key=(lambda item: item.area.area_acronym.acronym))
|
||||
|
||||
ads = []
|
||||
meeting_time = datetime.datetime.combine(meeting.date, datetime.time(0, 0, 0))
|
||||
from redesign.group.models import Group, find_group_history_active_at
|
||||
for g in Group.objects.filter(type="area").order_by("acronym"):
|
||||
history = find_group_history_active_at(g, meeting_time)
|
||||
if history:
|
||||
if history.state_id == "active":
|
||||
ads.extend(IESGHistory().from_role(x) for x in history.rolehistory_set.filter(name="ad"))
|
||||
else:
|
||||
if g.state_id == "active":
|
||||
ads.extend(IESGHistory().from_role(x) for x in g.role_set.filter(name="ad"))
|
||||
|
||||
from redesign.doc.models import Document
|
||||
plenary_agendas = Document.objects.filter(timeslot__meeting=meeting, timeslot__type="plenary", type="agenda").distinct()
|
||||
|
|
|
@ -7,7 +7,8 @@ class IESGHistoryAdmin(admin.ModelAdmin):
|
|||
list_display = ['meeting', 'area', 'person']
|
||||
list_filter = ['meeting', ]
|
||||
raw_id_fields = ["person", ]
|
||||
admin.site.register(IESGHistory, IESGHistoryAdmin)
|
||||
if not settings.USE_DB_REDESIGN_PROXY_CLASSES:
|
||||
admin.site.register(IESGHistory, IESGHistoryAdmin)
|
||||
|
||||
class MeetingAdmin(admin.ModelAdmin):
|
||||
list_display=('meeting_num', 'start_date', 'city', 'state', 'country', 'time_zone')
|
||||
|
|
|
@ -593,7 +593,8 @@ if settings.USE_DB_REDESIGN_PROXY_CLASSES:
|
|||
WgMeetingSessionOld = WgMeetingSession
|
||||
SlideOld = Slide
|
||||
SwitchesOld = Switches
|
||||
from ietf.meeting.proxy import MeetingProxy as Meeting, ProceedingProxy as Proceeding, MeetingVenueProxy as MeetingVenue, MeetingTimeProxy as MeetingTime, WgMeetingSessionProxy as WgMeetingSession, SlideProxy as Slide, SwitchesProxy as Switches
|
||||
IESGHistoryOld = IESGHistory
|
||||
from ietf.meeting.proxy import MeetingProxy as Meeting, ProceedingProxy as Proceeding, MeetingVenueProxy as MeetingVenue, MeetingTimeProxy as MeetingTime, WgMeetingSessionProxy as WgMeetingSession, SlideProxy as Slide, SwitchesProxy as Switches, IESGHistoryProxy as IESGHistory
|
||||
|
||||
# changes done by convert-096.py:changed maxlength to max_length
|
||||
# removed core
|
||||
|
|
|
@ -97,4 +97,18 @@ class RoleHistory(models.Model):
|
|||
auth = models.CharField(max_length=255, blank=True) # unused?
|
||||
def __unicode__(self):
|
||||
return u"%s is %s in %s" % (self.email.get_name(), self.name.name, self.group.acronym)
|
||||
|
||||
|
||||
|
||||
def find_group_history_active_at(group, time):
|
||||
"""Return the GroupHistory object active at time, or None if the
|
||||
group itself was active at the time."""
|
||||
if group.time <= time:
|
||||
return None
|
||||
|
||||
histories = group.group_history.order_by('-time')
|
||||
|
||||
for h in histories:
|
||||
if h.time <= time:
|
||||
return h
|
||||
|
||||
return None
|
||||
|
|
|
@ -106,8 +106,11 @@ for o in Area.objects.all():
|
|||
group = Group(acronym=o.area_acronym.acronym)
|
||||
group.id = o.area_acronym_id # transfer id
|
||||
|
||||
if o.last_modified_date:
|
||||
group.time = datetime.datetime.combine(o.last_modified_date, datetime.time(12, 0, 0))
|
||||
# we could use last_modified_date for group.time, but in the new
|
||||
# schema, group.time is supposed to change when the roles change
|
||||
# too and some of the history logic depends on this, so it's going
|
||||
# to cause us too much trouble
|
||||
|
||||
group.name = o.area_acronym.name
|
||||
if o.status.status == "Active":
|
||||
s = state_names["active"]
|
||||
|
|
|
@ -58,6 +58,12 @@ for o in AreaDirector.objects.filter(ietfwg__in=IETFWG.objects.all()).exclude(ar
|
|||
|
||||
get_or_create_email(o, create_fake=False)
|
||||
|
||||
# IESGHistory persons
|
||||
for o in PersonOrOrgInfo.objects.filter(iesghistory__id__gte=1).order_by("pk").distinct():
|
||||
print "importing IESGHistory person", o.pk, o.first_name.encode('utf-8'), o.last_name.encode('utf-8')
|
||||
|
||||
email = get_or_create_email(o, create_fake=False)
|
||||
|
||||
# WgMeetingSession persons
|
||||
for o in PersonOrOrgInfo.objects.filter(wgmeetingsession__pk__gte=1).distinct().order_by("pk").iterator():
|
||||
print "importing WgMeetingSession persons", o.pk, o.first_name.encode('utf-8'), o.last_name.encode('utf-8')
|
||||
|
|
|
@ -18,6 +18,7 @@ from redesign.name.utils import name
|
|||
from redesign.importing.utils import get_or_create_email
|
||||
|
||||
from ietf.idtracker.models import IESGLogin, AreaDirector, PersonOrOrgInfo, WGChair, WGEditor, WGSecretary, WGTechAdvisor, ChairsHistory, Role as OldRole, Acronym, IRTFChair
|
||||
from ietf.proceedings.models import IESGHistory
|
||||
|
||||
|
||||
# assumptions:
|
||||
|
@ -25,7 +26,7 @@ from ietf.idtracker.models import IESGLogin, AreaDirector, PersonOrOrgInfo, WGCh
|
|||
# - groups have been imported
|
||||
|
||||
# imports IESGLogin, AreaDirector, WGEditor, WGChair, IRTFChair,
|
||||
# WGSecretary, WGTechAdvisor, NomCom chairs from ChairsHistory,
|
||||
# WGSecretary, WGTechAdvisor, NomCom chairs from ChairsHistory, IESGHistory
|
||||
|
||||
# FIXME: should probably import Role, LegacyWgPassword, LegacyLiaisonUser
|
||||
|
||||
|
@ -81,15 +82,16 @@ for o in WGChair.objects.all():
|
|||
except PersonOrOrgInfo.DoesNotExist:
|
||||
print "SKIPPING WGChair", acronym, "with invalid person id", o.person_id
|
||||
continue
|
||||
|
||||
if acronym in ("apples", "apptsv", "usac", "null", "dirdir"):
|
||||
print "SKIPPING WGChair", acronym, o.person
|
||||
|
||||
try:
|
||||
group = Group.objects.get(acronym=acronym)
|
||||
except Group.DoesNotExist:
|
||||
print "SKIPPING WGChair", o.person, "with non-existing group", acronym
|
||||
continue
|
||||
|
||||
print "importing WGChair", acronym, o.person
|
||||
|
||||
email = get_or_create_email(o, create_fake=True)
|
||||
group = Group.objects.get(acronym=acronym)
|
||||
|
||||
Role.objects.get_or_create(name=chair_role, group=group, email=email)
|
||||
|
||||
|
@ -170,4 +172,59 @@ for o in AreaDirector.objects.all():
|
|||
else:
|
||||
Role.objects.get_or_create(name=role_type, group=area, email=email)
|
||||
|
||||
# IESGHistory
|
||||
emails_for_time = {}
|
||||
for o in IESGHistory.objects.all().order_by('meeting__start_date', 'pk'):
|
||||
print "importing IESGHistory", o.pk, o.area, o.person, o.meeting
|
||||
email = get_or_create_email(o, create_fake=False)
|
||||
if not email:
|
||||
"SKIPPING IESGHistory with unknown email"
|
||||
continue
|
||||
|
||||
# our job here is to make sure we either have the same AD today or
|
||||
# got proper GroupHistory and RoleHistory objects in the database;
|
||||
# there's only incomplete information available in the database so
|
||||
# the reconstructed history will necessarily not be entirely
|
||||
# accurate, just good enough to conclude who was AD
|
||||
area = Group.objects.get(acronym=o.area.area_acronym.acronym, type="area")
|
||||
meeting_time = datetime.datetime.combine(o.meeting.start_date, datetime.time(0, 0, 0))
|
||||
|
||||
key = (area, meeting_time)
|
||||
if not key in emails_for_time:
|
||||
emails_for_time[key] = []
|
||||
|
||||
emails_for_time[key].append(email)
|
||||
|
||||
history = find_group_history_active_at(area, meeting_time)
|
||||
if (history and history.rolehistory_set.filter(email__person=email.person) or
|
||||
not history and area.role_set.filter(email__person=email.person)):
|
||||
continue
|
||||
|
||||
if history and history.time == meeting_time:
|
||||
# add to existing GroupHistory
|
||||
RoleHistory.objects.create(name=area_director_role, group=history, email=email)
|
||||
else:
|
||||
existing = history if history else area
|
||||
|
||||
h = GroupHistory(group=area,
|
||||
charter=existing.charter,
|
||||
time=meeting_time,
|
||||
name=existing.name,
|
||||
acronym=existing.acronym,
|
||||
state=existing.state,
|
||||
type=existing.type,
|
||||
parent=existing.parent,
|
||||
iesg_state=existing.iesg_state,
|
||||
ad=existing.ad,
|
||||
list_email=existing.list_email,
|
||||
list_subscribe=existing.list_subscribe,
|
||||
list_archive=existing.list_archive,
|
||||
comments=existing.comments,
|
||||
)
|
||||
h.save()
|
||||
|
||||
# we need to add all emails for this area at this time
|
||||
# because the new GroupHistory resets the known roles
|
||||
for e in emails_for_time[key]:
|
||||
RoleHistory.objects.get_or_create(name=area_director_role, group=h, email=e)
|
||||
|
||||
|
|
Loading…
Reference in a new issue