Add page counts to iesg/agenda/documents and to the edit telechat date form. Fixes #1772. Commit ready for merge.

- Legacy-Id: 10631
This commit is contained in:
Robert Sparks 2016-01-04 22:49:17 +00:00
parent 95e2147f73
commit 8f5a692338
5 changed files with 58 additions and 4 deletions

View file

@ -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

View file

View file

@ -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])

View file

@ -8,7 +8,7 @@
{% block content %}
{% origin %}
<h1>Set telechat date<br><small>{{ doc.name }}</small></h1>
<h1>Set telechat date<br><small>{{ doc.name }} ({{ doc.pages }} page{{ doc.pages|pluralize }})</small></h1>
{% bootstrap_messages %}
@ -20,10 +20,38 @@
{% csrf_token %}
{% bootstrap_form form %}
<div id="large_page_count_warning" class="hidden-nojs alert alert-warning">
Putting the document on this telechat gives the telechat a very large document page count. Please consider choosing another telechat date for this document.
</div>
{% buttons %}
<button type="submit" class="btn btn-primary">Save</button>
<a class="btn btn-default pull-right" href="{% url "doc_view" name=doc.name %}">Back</a>
{% endbuttons %}
</form>
{% endblock %}
{% block js %}
<script>
var pages = {};
{% for date,count in form.page_count.items %}
pages['{{date}}'] = {{count}};
{% endfor %}
$("#large_page_count_warning").hide();
function toggleWarning(date) {
if ( date==="" | pages[date] + {{ doc.pages }} < 400 ) {
$("#large_page_count_warning").hide();
} else {
$("#large_page_count_warning").show();
}
}
$("select[name='telechat_date']").change(function () {
toggleWarning($(this).val());
});
</script>
{% endblock %}

View file

@ -4,6 +4,7 @@
{% load ballot_icon %}
{% load ietf_filters %}
{% load iesg_filters %}
{% block pagehead %}
<link rel="alternate" type="application/atom+xml" href="/feed/iesg-agenda/">
@ -21,7 +22,11 @@
{% endif %}
{% for t in telechats %}
<h2>IESG telechat {{t.date}}</h2>
<h2>IESG telechat {{t.date}}
{% with t|telechat_page_count as pages %}
<small class="text-muted">{{pages}} page{{pages|pluralize}}</small>
{% endwith %}
</h2>
<p>
<a class="btn btn-default" role="button" href="/iesg/agenda/">
<span class="fa fa-list"></span>