Skip to content

Commit e889177

Browse files
committed
merged forward
- Legacy-Id: 8432
2 parents a5f49b3 + 754ee80 commit e889177

19 files changed

Lines changed: 1253 additions & 16 deletions

ietf/doc/migrations/0020_archive_slides.py

Lines changed: 398 additions & 0 deletions
Large diffs are not rendered by default.

ietf/doc/models.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,37 @@ def active_ballot(self):
171171
return None
172172

173173
def meeting_related(self):
174+
if self.type_id in ("agenda","minutes",):
175+
return (self.name.split("-")[1] == "interim"
176+
or (self.session_set.exists() if isinstance(self, Document) else self.doc.session_set.exists()))
177+
elif self.type_id in ("slides",):
178+
return (self.name.split("-")[1] == "interim"
179+
or (self.get_state('slides') in ("sessonly","archived") ))
180+
else:
181+
return False
182+
174183
return(self.type_id in ("agenda", "minutes", "slides") and (
175184
self.name.split("-")[1] == "interim"
176185
or (self.session_set.exists() if isinstance(self, Document) else self.doc.session_set.exists())))
177186

187+
def future_presentations(self):
188+
""" returns related SessionPresentation objects for meetings that
189+
have not yet ended. This implementation allows for 2 week meetings """
190+
candidate_presentations = self.sessionpresentation_set.filter(session__meeting__date__gte=datetime.date.today()-datetime.timedelta(days=15))
191+
return [pres for pres in candidate_presentations if pres.session.meeting.end_date()>=datetime.date.today()]
192+
193+
def last_presented(self):
194+
""" returns related SessionPresentation objects for the most recent meeting in the past"""
195+
# Assumes no two meetings have the same start date - if the assumption is violated, one will be chosen arbitrariy
196+
candidate_presentations = self.sessionpresentation_set.filter(session__meeting__date__lte=datetime.date.today())
197+
candidate_meetings = set([p.session.meeting for p in candidate_presentations if p.session.meeting.end_date()<datetime.date.today()])
198+
if candidate_meetings:
199+
mtg = sorted(list(candidate_meetings),key=lambda x:x.date,reverse=True)[0]
200+
return self.sessionpresentation_set.filter(session__meeting=mtg)
201+
else:
202+
return None
203+
204+
178205
class Meta:
179206
abstract = True
180207

ietf/doc/templatetags/ietf_filters.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,11 @@ def format_history_text(text):
448448
if text.startswith("This was part of a ballot set with:"):
449449
full = urlize_ietf_docs(full)
450450

451-
full = mark_safe(keep_spacing(linebreaksbr(urlize(sanitize_html(full)))))
451+
return format_snippet(full)
452+
453+
@register.filter
454+
def format_snippet(text):
455+
full = mark_safe(keep_spacing(linebreaksbr(urlize(sanitize_html(text)))))
452456
snippet = truncatewords_html(full, 25)
453457
if snippet != full:
454458
return mark_safe(u'<div class="snippet">%s<span class="show-all">[show all]</span></div><div style="display:none" class="full">%s</div>' % (snippet, full))

ietf/doc/urls_material.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22

33
urlpatterns = patterns('ietf.doc.views_material',
44
url(r'^(?P<action>state|title|revise)/$', "edit_material", name="material_edit"),
5+
url(r'^sessions/$', "material_presentations", name="material_presentations"),
56
)
67

ietf/doc/views_doc.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,9 @@ def document_main(request, name, rev=None):
494494

495495
if doc.type_id in ("slides", "agenda", "minutes"):
496496
can_manage_material = can_manage_materials(request.user, doc.group)
497+
presentations = None
498+
if doc.type_id=='slides' and doc.get_state_slug('slides') in ['sessonly','active']:
499+
presentations = doc.future_presentations()
497500
if doc.meeting_related():
498501
# disallow editing meeting-related stuff through this
499502
# interface for the time being
@@ -531,6 +534,7 @@ def document_main(request, name, rev=None):
531534
snapshot=snapshot,
532535
can_manage_material=can_manage_material,
533536
other_types=other_types,
537+
presentations=presentations,
534538
),
535539
context_instance=RequestContext(request))
536540

ietf/doc/views_material.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from ietf.doc.utils import add_state_change_event, check_common_doc_name_rules
1818
from ietf.group.models import Group
1919
from ietf.group.utils import can_manage_materials
20+
from ietf.meeting.models import Session
2021

2122
@login_required
2223
def choose_material_type(request, acronym):
@@ -168,3 +169,56 @@ def edit_material(request, name=None, acronym=None, action=None, doc_type=None):
168169
'document_type': document_type,
169170
'doc_name': doc.name if doc else "",
170171
})
172+
173+
class MaterialPresentationForm(forms.Form):
174+
175+
sesspres = forms.MultipleChoiceField(required=False,widget=forms.CheckboxSelectMultiple,label='Place this document on the agenda for the selected sessions')
176+
177+
def __init__(self,*args,**kwargs):
178+
choices = kwargs.pop('choices')
179+
super(MaterialPresentationForm,self).__init__(*args,**kwargs)
180+
self.fields['sesspres'].choices=choices
181+
182+
@login_required
183+
def material_presentations(request, name):
184+
185+
doc = get_object_or_404(Document, name=name)
186+
if not (doc.type_id=='slides' and doc.get_state('slides').slug=='active'):
187+
raise Http404
188+
189+
group = doc.group
190+
if not (group.features.has_materials and can_manage_materials(request.user,group)):
191+
raise Http404
192+
193+
# Find all the sessions for meetings that haven't ended that the user could affect
194+
# This motif is also in Document.future_presentations - it would be nice to consolodate it somehow
195+
candidate_sessions = Session.objects.filter(meeting__date__gte=datetime.date.today()-datetime.timedelta(days=15))
196+
refined_candidates = [ sess for sess in candidate_sessions if sess.meeting.end_date()>=datetime.date.today()]
197+
changeable_sessions = [ sess for sess in refined_candidates if can_manage_materials(request.user, sess.group) ]
198+
for sess in changeable_sessions:
199+
sess.has_presentation = sess.sessionpresentation_set.filter(document=doc)
200+
sorted_sessions = sorted(changeable_sessions,key=lambda x:'%s%s%s'%('0' if x.has_presentation else '1',x.meeting,x.short_name))
201+
202+
choices=[(sess.pk,'%s: %s'%(sess.meeting,sess.short_name)) for sess in sorted_sessions]
203+
initial = {'sesspres': [sess.pk for sess in sorted_sessions if sess.has_presentation]}
204+
205+
if request.method == 'POST':
206+
form = MaterialPresentationForm(request.POST,choices=choices)
207+
if form.is_valid():
208+
print "STUFF",request.POST.get("action","nothing to be gotten")
209+
if request.POST.get("action", "") == "Save":
210+
new_selections = form.cleaned_data['sesspres']
211+
doc.sessionpresentation_set.filter(session_id__in=(set(initial['sesspres'])-set(new_selections))).delete()
212+
for sess_pk in set(new_selections)-set(initial['sesspres']):
213+
doc.sessionpresentation_set.create(session_id=sess_pk,rev=doc.rev)
214+
return redirect('doc_view',name=doc.name)
215+
else:
216+
form = MaterialPresentationForm(choices=choices,
217+
initial=initial,
218+
)
219+
220+
return render(request, 'doc/material/material_presentations.html', {
221+
'sessions' : sorted_sessions,
222+
'doc': doc,
223+
'form': form,
224+
})

ietf/group/info.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,8 @@ def concluded_groups(request):
267267
dict(group_types=group_types))
268268

269269
def get_group_materials(group):
270-
return Document.objects.filter(group=group, type__in=group.features.material_types, session=None).exclude(states__slug="deleted")
270+
# return Document.objects.filter(group=group, type__in=group.features.material_types, session=None).exclude(states__slug="deleted")
271+
return Document.objects.filter(group=group, type__in=group.features.material_types).exclude(states__slug__in=['deleted','archived'])
271272

272273
def construct_group_menu_context(request, group, selected, group_type, others):
273274
"""Return context with info for the group menu filled in."""

0 commit comments

Comments
 (0)