Migration to create documents and sessionpresentations for ietf95 and 96 bluesheets. Add bluesheets to proceedings.

- Legacy-Id: 11747
This commit is contained in:
Robert Sparks 2016-08-02 20:30:40 +00:00
parent 261f97e6c1
commit a34dc40170
3 changed files with 89 additions and 0 deletions

View file

@ -0,0 +1,69 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import os
from django.db import migrations
from django.conf import settings
def official_time(session):
return session.timeslotassignments.filter(schedule=session.meeting.agenda).first()
def forward(apps, schema_editor):
Document = apps.get_model('doc','Document')
State = apps.get_model('doc','State')
Group = apps.get_model('group','Group')
Meeting = apps.get_model('meeting', 'Meeting')
active = State.objects.get(type_id='bluesheets',slug='active')
for num in [95, 96]:
mtg = Meeting.objects.get(number=num)
bs_path = '%s/bluesheets/'% os.path.join(settings.AGENDA_PATH,mtg.number)
bs_files = os.listdir(bs_path)
bs_acronyms = set([x[14:-7] for x in bs_files])
group_acronyms = set([x.group.acronym for x in mtg.session_set.all() if official_time(x) and x.group.type_id in ['wg','rg','ag'] and not x.agenda_note.lower().startswith('cancel')])
if bs_acronyms-group_acronyms:
print "Warning IETF%s : groups that have bluesheets but did not appear to meet: %s"%(num,list(bs_acronyms-group_acronyms))
if group_acronyms-bs_acronyms:
print "Warning IETF%s : groups that appeared to meet but have no bluesheets: %s"%(num,list(group_acronyms-bs_acronyms))
for acronym in group_acronyms & bs_acronyms:
group = Group.objects.get(acronym=acronym)
bs = sorted([x for x in bs_files if '-%s-'%acronym in x])
bs_count = len(bs)
sess = sorted([ x for x in mtg.session_set.filter(group__acronym=acronym) if not x.agenda_note.lower().startswith('cancel')],
key = lambda x: official_time(x).timeslot.time)
sess_count = len(sess)
if bs_count != sess_count:
print "Warning IETF%s: %s : different number of bluesheets (%d) than sessions (%d)"%(num,acronym,bs_count,sess_count)
numdocs = min(bs_count,sess_count)
for n in range(numdocs):
doc = Document.objects.create(
name=bs[n][:-4],
type_id='bluesheets',
title='Bluesheets IETF%d : %s : %s ' % (num,acronym,official_time(sess[n]).timeslot.time.strftime('%a %H:%M')),
group=group,
rev='00',
external_url=bs[n],
)
doc.states.add(active)
sess[n].sessionpresentation_set.create(document=doc,rev='00')
def reverse(apps, schema_editor):
Document = apps.get_model('doc','Document')
Document.objects.filter(type_id='bluesheets',sessionpresentation__session__meeting__number_in=[95,96]).exclude(group__acronym='openpgp').delete()
class Migration(migrations.Migration):
dependencies = [
('meeting', '0028_add_audio_stream_data'),
('doc', '0012_auto_20160207_0537'),
('group','0008_auto_20160505_0523'),
]
operations = [
migrations.RunPython(forward,reverse)
]

View file

@ -1008,6 +1008,9 @@ class Session(models.Model):
def recordings(self):
return list(self.get_material("recording", only_one=False))
def bluesheets(self):
return list(self.get_material("bluesheets", only_one=False))
def slides(self):
if not hasattr(self, "_slides_cache"):
self._slides_cache = list(self.get_material("slides", only_one=False))
@ -1024,6 +1027,14 @@ class Session(models.Model):
recordings.extend(session.recordings())
return recordings
def all_meeting_bluesheets(self):
bluesheets = []
sessions = sorted(self.meeting.session_set.filter(group=self.group),
key = lambda x: x.official_timeslotassignment().timeslot.time)
for session in sessions:
bluesheets.extend(session.bluesheets())
return bluesheets
def all_meeting_drafts(self):
drafts = []
for session in self.meeting.session_set.filter(group=self.group):

View file

@ -35,6 +35,15 @@
<span class="label label-warning">No minutes</span><br>
{% endif %}
{% endif %}
{% if session.all_meeting_bluesheets %}
{% if session.all_meeting_bluesheets|length == 1 %}
<a href="{{bs.0.get_absolute_url}}">Bluesheets</a></br>
{% else %}
{% for bs in session.all_meeting_bluesheets %}
<a href="{{bs.get_absolute_url}}">Bluesheets {{bs.sessionpresentation_set.first.session.official_timeslotassignment.timeslot.time|date:"D G:i"}}</a></br>
{% endfor %}
{% endif %}
{% endif %}
</td>
<td>