Source code for uw.local.grad.webui.coordinator

"""Admissions coordinator interface UI implementation.

This implements the coordinator page, which attempts to show the coordinator
the information that is relevant to them.
"""

from operator import attrgetter
from itertools import groupby

from ll.xist.ns import html

from uw.web.html.format import format_return, make_table_format
from uw.web.wsgi.delegate import delegate_get_post
from uw.web.wsgi.function import return_html

from .util import render_frontpage_header
from ...util.identity import use_remote_identity

from ..db.bulk_unitapp import bulk_app_loader

from .list_render import (make_application_link_column, application_list_columns,
                          application_term_column, render_sort_table)

[docs]def make_table_columns (): """Assemble table column definitions for application list. :return: a list of column definitions for use with :func:`uw.web.html.format.make_table_format`. Compare with :func:`uw.local.grad.webui.faculty.make_table_columns`. Always return the regular application list columns, starting with the link to the individual application, and including the term column. """ table_columns = [make_application_link_column ("../")] table_columns.extend (application_list_columns) table_columns.append (application_term_column) return table_columns
@delegate_get_post @use_remote_identity @return_html def coordinator_index_get_handler (cursor, remote_identity): """Coordinator "front page" GET URL handler. Displays applications for the appropriate Units which are in New, Hold (overdue only), or Generating Offer. These are the applications which the coordinator should routinely need to consider. """ apps = groupby (cursor.execute_tuples ("select status_description, appl_id from (select distinct on (uw_id, appl_id) * from work_application_staff_lookup natural join work_application_status_current AS wacs natural join work_application_status_code AS wasc natural join std_name_primary where admit_term_id >= uw_term_current () and staff_person_id=%(staff_person_id)s and (status_code in ('NEW', 'ACP', 'RJR') or status_code in ('HLD', 'RJS') and deadline < now ())) as t order by status_sequence desc, last_name, first_name, middle_name, uw_id, appl_id", staff_person_id=remote_identity.person_id), attrgetter ('status_description')) table_columns = make_table_columns () rows = [] for status_description, app2 in ((status_description, bulk_app_loader (cursor, (app.appl_id for app in app2))) for status_description, app2 in apps): sorted_app = sorted (app2, key = lambda a : (a.admit_term, a.names)) sort_table = render_sort_table (table_columns, sorted_app, fixed=True) sort_table["class"] += " col-xs-12 table-fixed" table_row = [ html.h3 (status_description), html.div ( sort_table ) ] rows.append (table_row) return 'Your Current Graduate Applications', [ html.div( format_return ('Main Menu'), render_frontpage_header ('their workflow state and deadlines'), html.div ( rows, class_ = "row" ), class_ = "main container" ) ]