Port /iesg/agenda/documents.txt to new schema, compose the table in

Python instead of using a template to make the code easier to read
 - Legacy-Id: 6400
This commit is contained in:
Ole Laursen 2013-10-09 15:55:45 +00:00
parent 53c59e56e3
commit 516a5fcc92
2 changed files with 24 additions and 43 deletions

View file

@ -251,16 +251,31 @@ def agenda_package(request, date=None):
def agenda_documents_txt(request):
dates = TelechatDates.objects.all()[0].dates()
dates = list(TelechatDate.objects.active().order_by('date').values_list("date", flat=True)[:4])
docs = []
for date in dates:
from ietf.doc.models import TelechatDocEvent
for d in Document.objects.filter(docevent__telechatdocevent__telechat_date=date).distinct():
if d.latest_event(TelechatDocEvent, type="scheduled_for_telechat").telechat_date == date:
docs.append(d)
t = loader.get_template('iesg/agenda_documents.txt')
c = Context({'docs':docs,'special_stream_list':['ise','irtf']})
return HttpResponse(t.render(c), mimetype='text/plain')
for d in Document.objects.filter(docevent__telechatdocevent__telechat_date__in=dates).distinct():
date = d.telechat_date()
if date in dates:
d.computed_telechat_date = date
docs.append(d)
docs.sort(key=lambda d: d.computed_telechat_date)
# output table
rows = []
rows.append("# Fields: telechat date, filename (draft-foo-bar or rfc1234), intended status, rfc editor submission flag (0=no, 1=yes), area acronym, AD name, version")
for d in docs:
row = (
d.computed_telechat_date.isoformat(),
d.name,
unicode(d.intended_std_level),
"1" if d.stream_id in ("ise", "irtf") else "0",
unicode(d.area_acronym()).lower(),
d.ad.plain_name() if d.ad else "None Assigned",
d.rev,
)
rows.append("\t".join(row))
return HttpResponse(u"\n".join(rows), mimetype='text/plain')
class RescheduleForm(forms.Form):
telechat_date = forms.TypedChoiceField(coerce=lambda x: datetime.datetime.strptime(x, '%Y-%m-%d').date(), empty_value=None, required=False)

View file

@ -1,34 +0,0 @@
{% comment %}
Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
All rights reserved. Contact: Pasi Eronen <pasi.eronen@nokia.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of the Nokia Corporation and/or its
subsidiary(-ies) nor the names of its contributors may be used
to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
{% endcomment %}# Fields: telechat date, filename (draft-foo-bar or rfc1234), intended status, rfc editor submission flag (0=no, 1=yes), area acronym, AD name, version{% for doc in docs %}
{{ doc.telechat_date }} {{ doc.name }} {{ doc.intended_std_level }} {% if doc.stream.slug in special_stream_list %}1{% else %}0{% endif %} {{doc.area_acronym|lower}} {% with doc.ad as ad %}{% if ad %}{{ ad.plain_name }}{% else %}None Assigned{% endif %}{% endwith %} {{doc.rev}}{% endfor %}