6161from ietf .doc .mails import email_comment
6262from ietf .mailtrigger .utils import gather_relevant_expansions
6363from ietf .meeting .models import Session
64+ from ietf .meeting .utils import group_sessions , get_upcoming_manageable_sessions , sort_sessions
6465
6566def render_document_top (request , doc , tab , name ):
6667 tabs = []
@@ -1094,7 +1095,6 @@ def email_aliases(request,name=''):
10941095
10951096class VersionForm (forms .Form ):
10961097
1097- # TODO is required=False correct here?
10981098 version = forms .ChoiceField (required = True ,
10991099 label = 'Which version of this document will be discussed at this session?' )
11001100
@@ -1126,7 +1126,7 @@ def edit_sessionpresentation(request,name,session_id):
11261126 c = DocEvent (type = "added_comment" , doc = doc , by = request .user .person )
11271127 c .desc = "Revision for session %s changed to %s" % (sp .session ,new_selection )
11281128 c .save ()
1129- return redirect ('ietf.doc.views_material .all_presentations' , name = name )
1129+ return redirect ('ietf.doc.views_doc .all_presentations' , name = name )
11301130 else :
11311131 form = VersionForm (choices = choices ,initial = initial )
11321132
@@ -1147,47 +1147,10 @@ def remove_sessionpresentation(request,name,session_id):
11471147 c = DocEvent (type = "added_comment" , doc = doc , by = request .user .person )
11481148 c .desc = "Removed from session: %s" % (sp .session )
11491149 c .save ()
1150- return redirect ('ietf.doc.views_material .all_presentations' , name = name )
1150+ return redirect ('ietf.doc.views_doc .all_presentations' , name = name )
11511151
11521152 return render (request ,'doc/remove_sessionpresentation.html' , {'sp' : sp })
11531153
1154-
1155- def get_upcoming_manageable_sessions (user ):
1156-
1157- # TODO: Move this into meeting.models or utils, or maybe person.models or utils - it doesn't depend on doc
1158- # Find all the sessions for meetings that haven't ended that the user could affect
1159- # This motif is also in Document.future_presentations - it would be nice to consolodate it somehow
1160-
1161- # Consider adding an argument that has some Qs to append to the queryset
1162-
1163- candidate_sessions = Session .objects .exclude (status__in = ['canceled' ,'disappr' ,'notmeet' ,'deleted' ]).filter (meeting__date__gte = datetime .date .today ()- datetime .timedelta (days = 15 ))
1164- refined_candidates = [ sess for sess in candidate_sessions if sess .meeting .end_date ()>= datetime .date .today ()]
1165-
1166- # Consider keeping this (put acronym=None back in argument list
1167- #if acronym:
1168- # refined_candidates = [ sess for sess in refined_candidates if sess.group.acronym==acronym]
1169-
1170- return [ sess for sess in refined_candidates if can_manage_materials (user , sess .group ) ]
1171-
1172- def sort_sessions (sessions ):
1173-
1174- # Python sorts are stable since version 2,2, so this series results in a list sorted first
1175- # by the meeting 'number', then by session's group acronym, then by scheduled time
1176- # (or the time of the session request if the session isn't scheduled).
1177-
1178- def time_sort_key (session ):
1179- official_sessions = session .timeslotassignments .filter (schedule = session .meeting .agenda )
1180- if official_sessions :
1181- return official_sessions .first ().timeslot .time
1182- else :
1183- return session .requested
1184-
1185- time_sorted = sorted (sessions ,key = time_sort_key )
1186- acronym_sorted = sorted (time_sorted ,key = lambda x : x .group .acronym )
1187- meeting_sorted = sorted (acronym_sorted ,key = lambda x : x .meeting .number )
1188-
1189- return meeting_sorted
1190-
11911154class SessionChooserForm (forms .Form ):
11921155 session = forms .ChoiceField (label = "Which session should this document be added to?" ,required = True )
11931156
@@ -1221,10 +1184,27 @@ def add_sessionpresentation(request,name):
12211184 c = DocEvent (type = "added_comment" , doc = doc , by = request .user .person )
12221185 c .desc = "%s to session: %s" % ('Added -%s' % rev if rev else 'Added' , Session .objects .get (pk = session_id ))
12231186 c .save ()
1224- return redirect ('ietf.doc.views_material .all_presentations' , name = name )
1187+ return redirect ('ietf.doc.views_doc .all_presentations' , name = name )
12251188
12261189 else :
12271190 version_form = VersionForm (choices = version_choices ,initial = {'version' :'current' })
12281191 session_form = SessionChooserForm (choices = session_choices )
12291192
12301193 return render (request ,'doc/add_sessionpresentation.html' ,{'doc' :doc ,'version_form' :version_form ,'session_form' :session_form })
1194+
1195+ def all_presentations (request , name ):
1196+ doc = get_object_or_404 (Document , name = name )
1197+
1198+
1199+ sessions = doc .session_set .filter (status__in = ['sched' ,'schedw' ,'appr' ,'canceled' ],
1200+ type__in = ['session' ,'plenary' ,'other' ])
1201+
1202+ future , in_progress , past = group_sessions (sessions )
1203+
1204+ return render (request , 'doc/material/all_presentations.html' , {
1205+ 'user' : request .user ,
1206+ 'doc' : doc ,
1207+ 'future' : future ,
1208+ 'in_progress' : in_progress ,
1209+ 'past' : past ,
1210+ })
0 commit comments