Skip to content

Commit 8f5a692

Browse files
committed
Add page counts to iesg/agenda/documents and to the edit telechat date form. Fixes ietf-tools#1772. Commit ready for merge.
- Legacy-Id: 10631
1 parent 95e2147 commit 8f5a692

5 files changed

Lines changed: 58 additions & 4 deletions

File tree

ietf/doc/forms.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
from django import forms
44

55
from ietf.iesg.models import TelechatDate
6+
from ietf.doc.models import Document
67

78
class TelechatForm(forms.Form):
8-
telechat_date = forms.TypedChoiceField(coerce=lambda x: datetime.datetime.strptime(x, '%Y-%m-%d').date(), empty_value=None, required=False)
9+
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.")
910
returning_item = forms.BooleanField(required=False)
1011

1112
def __init__(self, *args, **kwargs):
@@ -16,7 +17,12 @@ def __init__(self, *args, **kwargs):
1617
if init and init not in dates:
1718
dates.insert(0, init)
1819

19-
self.fields['telechat_date'].choices = [("", "(not on agenda)")] + [(d, d.strftime("%Y-%m-%d")) for d in dates]
20+
self.page_count = {}
21+
choice_display = {}
22+
for d in dates:
23+
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])
24+
choice_display[d] = '%s (%s pages)' % (d.strftime("%Y-%m-%d"),self.page_count[d])
25+
self.fields['telechat_date'].choices = [("", "(not on agenda)")] + [(d, choice_display[d]) for d in dates]
2026

2127
from ietf.person.models import Person
2228

ietf/iesg/templatetags/__init__.py

Whitespace-only changes.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from django import template
2+
3+
register = template.Library()
4+
5+
@register.filter
6+
def telechat_page_count(telechat):
7+
page_count = 0
8+
for num, section in telechat['sections']:
9+
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',):
10+
for doc in section['docs']:
11+
page_count += getattr(doc,'pages',0)
12+
return page_count
13+
14+
# An alternate implementation:
15+
# sum([doc.pages for doc in Document.objects.filter(docevent__telechatdocevent__telechat_date=d,type='draft').distict() if doc.telechat_date()==d])

ietf/templates/doc/edit_telechat_date.html

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
{% block content %}
1010
{% origin %}
11-
<h1>Set telechat date<br><small>{{ doc.name }}</small></h1>
11+
<h1>Set telechat date<br><small>{{ doc.name }} ({{ doc.pages }} page{{ doc.pages|pluralize }})</small></h1>
1212

1313
{% bootstrap_messages %}
1414

@@ -20,10 +20,38 @@ <h1>Set telechat date<br><small>{{ doc.name }}</small></h1>
2020
{% csrf_token %}
2121
{% bootstrap_form form %}
2222

23+
<div id="large_page_count_warning" class="hidden-nojs alert alert-warning">
24+
Putting the document on this telechat gives the telechat a very large document page count. Please consider choosing another telechat date for this document.
25+
</div>
26+
2327
{% buttons %}
2428
<button type="submit" class="btn btn-primary">Save</button>
2529
<a class="btn btn-default pull-right" href="{% url "doc_view" name=doc.name %}">Back</a>
2630
{% endbuttons %}
2731
</form>
2832

33+
34+
{% endblock %}
35+
36+
{% block js %}
37+
<script>
38+
var pages = {};
39+
{% for date,count in form.page_count.items %}
40+
pages['{{date}}'] = {{count}};
41+
{% endfor %}
42+
43+
$("#large_page_count_warning").hide();
44+
45+
function toggleWarning(date) {
46+
if ( date==="" | pages[date] + {{ doc.pages }} < 400 ) {
47+
$("#large_page_count_warning").hide();
48+
} else {
49+
$("#large_page_count_warning").show();
50+
}
51+
}
52+
53+
$("select[name='telechat_date']").change(function () {
54+
toggleWarning($(this).val());
55+
});
56+
</script>
2957
{% endblock %}

ietf/templates/iesg/agenda_documents.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
{% load ballot_icon %}
66
{% load ietf_filters %}
7+
{% load iesg_filters %}
78

89
{% block pagehead %}
910
<link rel="alternate" type="application/atom+xml" href="/feed/iesg-agenda/">
@@ -21,7 +22,11 @@ <h1>Documents on future IESG telechat agendas</h1>
2122
{% endif %}
2223

2324
{% for t in telechats %}
24-
<h2>IESG telechat {{t.date}}</h2>
25+
<h2>IESG telechat {{t.date}}
26+
{% with t|telechat_page_count as pages %}
27+
<small class="text-muted">{{pages}} page{{pages|pluralize}}</small>
28+
{% endwith %}
29+
</h2>
2530
<p>
2631
<a class="btn btn-default" role="button" href="/iesg/agenda/">
2732
<span class="fa fa-list"></span>

0 commit comments

Comments
 (0)