From 8f5a692338aa82811e4d5dcbf2b9826af62c6d03 Mon Sep 17 00:00:00 2001 From: Robert Sparks Date: Mon, 4 Jan 2016 22:49:17 +0000 Subject: [PATCH] Add page counts to iesg/agenda/documents and to the edit telechat date form. Fixes #1772. Commit ready for merge. - Legacy-Id: 10631 --- ietf/doc/forms.py | 10 ++++++-- ietf/iesg/templatetags/__init__.py | 0 ietf/iesg/templatetags/iesg_filters.py | 15 +++++++++++ ietf/templates/doc/edit_telechat_date.html | 30 +++++++++++++++++++++- ietf/templates/iesg/agenda_documents.html | 7 ++++- 5 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 ietf/iesg/templatetags/__init__.py create mode 100644 ietf/iesg/templatetags/iesg_filters.py diff --git a/ietf/doc/forms.py b/ietf/doc/forms.py index 33a2b9150..abf765191 100644 --- a/ietf/doc/forms.py +++ b/ietf/doc/forms.py @@ -3,9 +3,10 @@ import datetime from django import forms from ietf.iesg.models import TelechatDate +from ietf.doc.models import Document class TelechatForm(forms.Form): - telechat_date = forms.TypedChoiceField(coerce=lambda x: datetime.datetime.strptime(x, '%Y-%m-%d').date(), empty_value=None, required=False) + telechat_date = forms.TypedChoiceField(coerce=lambda x: datetime.datetime.strptime(x, '%Y-%m-%d').date(), empty_value=None, required=False, help_text="Page counts are the current page counts for the telechat, before this telechat date edit is made.") returning_item = forms.BooleanField(required=False) def __init__(self, *args, **kwargs): @@ -16,7 +17,12 @@ class TelechatForm(forms.Form): if init and init not in dates: dates.insert(0, init) - self.fields['telechat_date'].choices = [("", "(not on agenda)")] + [(d, d.strftime("%Y-%m-%d")) for d in dates] + self.page_count = {} + choice_display = {} + for d in dates: + self.page_count[d] = sum([doc.pages for doc in Document.objects.filter(docevent__telechatdocevent__telechat_date=d,type='draft').distinct() if doc.telechat_date()==d]) + choice_display[d] = '%s (%s pages)' % (d.strftime("%Y-%m-%d"),self.page_count[d]) + self.fields['telechat_date'].choices = [("", "(not on agenda)")] + [(d, choice_display[d]) for d in dates] from ietf.person.models import Person diff --git a/ietf/iesg/templatetags/__init__.py b/ietf/iesg/templatetags/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/ietf/iesg/templatetags/iesg_filters.py b/ietf/iesg/templatetags/iesg_filters.py new file mode 100644 index 000000000..4407c07da --- /dev/null +++ b/ietf/iesg/templatetags/iesg_filters.py @@ -0,0 +1,15 @@ +from django import template + +register = template.Library() + +@register.filter +def telechat_page_count(telechat): + page_count = 0 + for num, section in telechat['sections']: + if num in ('2.1.1','2.1.2','2.2.1','2.2.2','3.1.1','3.1.2','3.2.1','3.2.2',): + for doc in section['docs']: + page_count += getattr(doc,'pages',0) + return page_count + +# An alternate implementation: +# sum([doc.pages for doc in Document.objects.filter(docevent__telechatdocevent__telechat_date=d,type='draft').distict() if doc.telechat_date()==d]) diff --git a/ietf/templates/doc/edit_telechat_date.html b/ietf/templates/doc/edit_telechat_date.html index dabd11899..b6fcac384 100644 --- a/ietf/templates/doc/edit_telechat_date.html +++ b/ietf/templates/doc/edit_telechat_date.html @@ -8,7 +8,7 @@ {% block content %} {% origin %} -

Set telechat date
{{ doc.name }}

+

Set telechat date
{{ doc.name }} ({{ doc.pages }} page{{ doc.pages|pluralize }})

{% bootstrap_messages %} @@ -20,10 +20,38 @@ {% csrf_token %} {% bootstrap_form form %} +
+ Putting the document on this telechat gives the telechat a very large document page count. Please consider choosing another telechat date for this document. +
+ {% buttons %} Back {% endbuttons %} + +{% endblock %} + +{% block js %} + {% endblock %} diff --git a/ietf/templates/iesg/agenda_documents.html b/ietf/templates/iesg/agenda_documents.html index 75ae473a4..8f19125c9 100644 --- a/ietf/templates/iesg/agenda_documents.html +++ b/ietf/templates/iesg/agenda_documents.html @@ -4,6 +4,7 @@ {% load ballot_icon %} {% load ietf_filters %} +{% load iesg_filters %} {% block pagehead %} @@ -21,7 +22,11 @@ {% endif %} {% for t in telechats %} -

IESG telechat {{t.date}}

+

IESG telechat {{t.date}} + {% with t|telechat_page_count as pages %} + {{pages}} page{{pages|pluralize}} + {% endwith %} +