Added comment docevents when changing SessionPresentation objects. Reworked group materials page to be more helpful when there are multiple SessionPresentations withing a given Meeting

- Legacy-Id: 8705
This commit is contained in:
Robert Sparks 2014-11-24 19:54:25 +00:00
parent b7d8ed8491
commit 5f1663530c
3 changed files with 39 additions and 3 deletions

View file

@ -203,7 +203,7 @@ class DocumentInfo(models.Model):
""" returns related SessionPresentation objects for meetings that
have not yet ended. This implementation allows for 2 week meetings """
candidate_presentations = self.sessionpresentation_set.filter(session__meeting__date__gte=datetime.date.today()-datetime.timedelta(days=15))
return [pres for pres in candidate_presentations if pres.session.meeting.end_date()>=datetime.date.today()]
return sorted([pres for pres in candidate_presentations if pres.session.meeting.end_date()>=datetime.date.today()], key=lambda x:x.session.meeting.date)
def last_presented(self):
""" returns related SessionPresentation objects for the most recent meeting in the past"""

View file

@ -270,10 +270,19 @@ def material_presentations(request, name, acronym=None, date=None, seq=None, wee
if initial['version'] != new_selection:
if initial['version'] == 'notpresented':
doc.sessionpresentation_set.create(session=session,rev=new_selection)
c = DocEvent(type="added_comment", doc=doc, by=request.user.person)
c.desc = "Added version %s to session: %s" % (new_selection,session)
c.save()
elif new_selection == 'notpresented':
doc.sessionpresentation_set.filter(session=session).delete()
c = DocEvent(type="added_comment", doc=doc, by=request.user.person)
c.desc = "Removed from session: %s" % (session)
c.save()
else:
doc.sessionpresentation_set.filter(session=session).update(rev=new_selection)
c = DocEvent(type="added_comment", doc=doc, by=request.user.person)
c.desc = "Revision for session %s changed to %s" % (session,new_selection)
c.save()
return redirect('doc_view',name=doc.name)
else:
form = MaterialVersionForm(choices=choices,initial=initial)

View file

@ -33,8 +33,35 @@
<td class='snippable'>{{ d.abstract|format_snippet }} </td>
<td>{{ d.rev }}</td>
<td>{{ d.time|date:"Y-m-d" }}</td>
<td>{% for p in d.last_presented %}{{p.session.meeting}}{% if d.rev != p.rev %} (-{{ p.rev }}){% endif %}{%if not forloop.last%}, {% endif %}{% endfor %}</td>
<td>{% for p in d.future_presentations %}{{p.session.meeting}}{% if d.rev != p.rev %} (-{{p.rev}}){%endif%}{%if not forloop.last%}, {%endif%}{%endfor%}</td>
<td>{% regroup d.last_presented by session.meeting as past_pres_list %}
{% for p in past_pres_list %}
{{ p.grouper }}
{% if p.list|length > 1 %}
( {{ p.list|length }} sessions )
{% else %}
{% for pr in p.list %}
{% if pr.rev != d.rev %}
(-{{ pr.rev }})
{% endif %}
{% endfor %}
{% endif %}
{% if not forloop.last %}, {% endif %}
{% endfor %}
<td>{% regroup d.future_presentations by session.meeting as meeting_pres_list %}
{% for p in meeting_pres_list %}
{{ p.grouper }}
{% if p.list|length > 1 %}
( {{ p.list|length }} sessions )
{% else %}
{% for pr in p.list %}
{% if pr.rev != d.rev %}
(-{{ pr.rev }})
{% endif %}
{% endfor %}
{% endif %}
{% if not forloop.last %}, {% endif %}
{% endfor %}
</td>
</tr>
{% endfor %}
</table>