Source code for uw.local.grad.webui.view_history
"""Application display history page implementation.
WSGI handler and routines for formatting the history page.
"""
from operator import attrgetter
from ll.xist.ns import html
from uw.web.html.format import format_date, format_datetime, make_table_format
from uw.web.wsgi import status
from uw.web.wsgi.form import use_form_param
from uw.web.wsgi.function import return_html
from ..db.unitapp import attendance, levels
from ...util.identity import use_remote_identity
from ...util.format import format_person
from .view_render import render_page
[docs]def render_history (unitapp, remote_identity, roles):
"""Render history information for an application as HTML.
:param unitapp: the candidate application.
:param remote_identity: the user's remote identity.
:param roles: the set of roles possessed by the user.
For use with :func:`uw.local.grad.webui.view_render.render_page`.
"""
result = [html.h2 ('Status History')]
result.append (make_table_format (
('Change Time', lambda r: format_datetime (r.eff_time)),
('State', lambda r: r.status_description + (' (Override)' if r.override else '')),
('Actor', lambda r: format_person (unitapp.cursor, r.person_id)),
('Deadline', lambda r: format_date (r.deadline)),
) (unitapp.history))
result.append (html.h2 ('GSO Decision History'))
result.append (make_table_format (
('Date', lambda r: format_date (r.program_as_of)),
('Plan', attrgetter ('plan_code'), lambda r: {'title': r.plan_transcript_description}),
('Time', attrgetter ('approved_load'), lambda r: {'title': attendance[r.approved_load]}),
('Decision', lambda r: r.program_action_code if r.program_reason_code is None else '%s/%s' % (r.program_action_code, r.program_reason_code), lambda r: {'title': r.program_action_description if r.program_reason_code is None else '%s/%s' % (r.program_action_description, r.program_reason_description)})
) (unitapp.gsohistory))
result.append (html.h2 ('OUAC'))
table = html.table ()
for field, label in [['ouac_reference', "OUAC Reference:"], ['appl_application_method', "Application method:"]]:
value = getattr (unitapp.app_info, field)
if value:
table.append (html.tr (
html.td (label),
html.td (format (value)),
))
result.append (table)
return 'history', result
@return_html
def view_history_handler (cursor, unitapp, remote_identity, roles):
"""Application history display URL handler.
"""
return render_page (unitapp, roles, render_history, remote_identity=remote_identity)