uw.local.grad.webui package

Submodules

uw.local.grad.webui.ajax module

AJAX API implementation.

Handles all ajax calls for specific uses on various pages. These live under /ajax relative to the application root. Most functions return json results intended to be used in javascript files.

TODO: Why do we pass most results through json.dumps()? The return_json handler does that itself. We end up returning a JSON string containing the JSON instead of just the JSON.

uw.local.grad.webui.analysis module

Analysis pages UI implementation.

uw.local.grad.webui.authority module

Authorization-related utility routines.

This includes authorization checkers for academic units and applications.

uw.local.grad.webui.authority.check_unit_authority(environ, cursor, unit, **params)[source]

Check for authorization within the unit.

For use with uw.web.wsgi.authority.check_authority().

uw.local.grad.webui.authority.check_unitapp_authority(environ, cursor, unitapp, **params)[source]

Check for authorization within the unit application.

For use with uw.web.wsgi.authority.check_authority().

uw.local.grad.webui.coordinator module

Admissions coordinator interface UI implementation.

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

uw.local.grad.webui.coordinator.make_table_columns()[source]

Assemble table column definitions for application list.

Returns

a list of column definitions for use with uw.web.html.format.make_table_format().

Compare with 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.

uw.local.grad.webui.delegate module

Convenient URL delegators.

These are used to build up the URL structure of the application by analyzing an URL path arc as the ID of an application.

uw.local.grad.webui.delegate.app_delegate(dir_handler, arc_handler)[source]

WSGI URL delegator based on application ID.

Parameters
  • dir_handler – the WSGI handler for requests for the root.

  • arc_handler – the WSGI handler for non-root requests.

Converts the URL path arc into an application and looks up that application in the database.

uw.local.grad.webui.delegate.app_from_arc(arc, cursor, **params)[source]

URL path arc parser for application IDs.

Takes the path arc as an appl_id and converts it into a uw.local.grad.db.unitapp.UnitApplication.

uw.local.grad.webui.director module

Director of Admissions interface UI implementation.

This implements the director page, which attempts to show the Director the information that is relevant to them.

uw.local.grad.webui.director.is_director(cursor, remote_identity)[source]
uw.local.grad.webui.director.make_table_columns(confirm=False)[source]

Assemble table column definitions for application list.

Parameters

confirm (bool) – whether the application list is for the action confirmation screen. If not a column with checkboxes for applications will be included.

Returns

a list of column definitions for use with uw.web.html.format.make_table_format().

Compare with 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.

uw.local.grad.webui.faculty module

Faculty interface UI implementation.

This implements the faculty page, which attempts to show each faculty member the applications that are relevant to them.

uw.local.grad.webui.faculty.get_research_areas(cursor, person_id)[source]

Get the research areas for a person.

Parameters
  • cursor – DB connection cursor.

  • person_id – the identity of the person.

Returns the appropriate rows from _grad.work_faculty_interest_complete.

uw.local.grad.webui.faculty.make_table_columns(is_current, base_prefix, confirm=False)[source]

Assemble table column definitions for application list.

Parameters
  • is_current (bool) – whether the application list is for “current” applications, in which case the term column will be included.

  • base_prefix – the base URL prefix for links to the applications.

  • confirm (bool) – whether the application list is for the action confirmation screen. If not, a column with checkboxes for selecting applications will be included.

Returns

a list of column definitions for use with uw.web.html.format.make_table_format().

uw.local.grad.webui.list module

Application list UI implementation.

This implements the main application list page.

uw.local.grad.webui.list.get_distinct_inst_country_codes(cursor, staff_person_id, termcode)[source]

Returns a list of distinct institution country codes and names for the given termcode like : ((‘CAN’, ‘Canada’) …)

uw.local.grad.webui.list.get_distinct_inst_ids(cursor, staff_person_id, termcode, inst, instcoun, limit=None)[source]

Returns a list of distinct insitution names matching either an institution string or institution country code.

Parameters
  • cursor – database cursor

  • inst – institution string

  • instcoun – institution country code (e.g. ‘CAN’)

  • limit – Integer or None, the number of results to show, at maximum.

uw.local.grad.webui.list.get_distinct_plans_codes(cursor, staff_person_id, termcode)[source]

Returns a list of distinct plan codes for the given termcode like : ((‘CSM’, ‘Computer Science’) …)

uw.local.grad.webui.list.get_distinct_status_codes(cursor, staff_person_id, termcode)[source]

Returns a list of distinct status codes for the given termcode like : ((‘REJ’, ‘Denied’) …)

uw.local.grad.webui.list.render_inst_options(cursor, values, staff_person_id, termcode)[source]

Render a status selection input element.

Parameters
  • cursor – DB connection cursor.

  • values – a dictionary containing the default values for ‘inst’, ‘instcoun’, and ‘citizen’

  • staff_person_id – the person whose terms should be included.

  • termcode – a term code if the statuses should be limited to those available

Returns an HTML <div> formatted with bootstrap for the institution and citizenship inputs.

uw.local.grad.webui.list.render_plan_options(cursor, plan, staff_person_id, termcode, selected=[])[source]

Render a plan selection input element.

Parameters
  • cursor – DB connection cursor.

  • plan – a dictionary containing the default values for ‘inst’, ‘instcoun’, and ‘citizen’

  • staff_person_id – the person whose terms should be included.

  • termcode – a term code if the statuses should be limited to those available

Returns an HTML <select> for selecting status values.

uw.local.grad.webui.list.render_request_select(cursor, name, default_staff=None, class_=None)[source]

Render a requested supervisor selection input element.

Parameters
  • cursor – DB connection cursor.

  • name – the form control name.

  • default_staff – the default staff or None.

  • class – A css class to be applied to the select element

Returns an HTML <select> for selecting requested supervisor values.

uw.local.grad.webui.list.render_status_select(cursor, name, status=None, all=False, staff_person_id=False, termcode=False, class_=None)[source]

Render a status selection input element.

Parameters
  • cursor – DB connection cursor.

  • name – the form control name.

  • staff_person_id – the person whose terms should be included. Expected alongside termcode.

  • termcode – a term code if the statuses should be limited to those available

  • status – the current status, or None.

  • all – whether the “OLD” status should be included (will be ignored if termcode is specified)

  • class – A css class to be applied to the select element

Returns an HTML <select> for selecting status values.

uw.local.grad.webui.list.render_term_select(cursor, name, staff_person_id, default_term=None, class_=None)[source]

Render a term selection input element.

Parameters
  • cursor – DB connection cursor.

  • name – the form control name.

  • staff_person_id – the person whose terms should be included.

  • default_term – the default term, or None to pick a default based on today’s date.

  • class – A css class to be applied to the select element

Generates an HTML <select> for selecting terms. The relevant terms to be included are obtained by looking in the database to see which terms have applications to which the person has access.

uw.local.grad.webui.list_render module

Application list rendering.

Routines for formatting lists of applications as HTML tables. Provides column definitions for use with uw.web.html.format.make_table_format().

uw.local.grad.webui.list_render.attribute_citizenship_column(unitapp)[source]

Compute the HTML attributes for the citizenship column.

Parameters

unitapp – the candidate application.

Returns

a dictionary of HTML attribute values.

The only attribute returned is the sort value used for ordering when the column header is clicked.

uw.local.grad.webui.list_render.attribute_due_column(unitapp)[source]

Compute the basic HTML attributes for the due column.

Parameters

unitapp – the candidate application.

Returns

a dictionary of HTML attribute values.

The returned attributes are either a style attribute that sets the background, or none at all. The background colour is set to indicate an imminent or passed workflow deadline.

Also used for the status display on the individual application view.

uw.local.grad.webui.list_render.attribute_due_column_sort(unitapp)[source]

Compute the complete HTML attributes for the due column.

Parameters

unitapp – the candidate application.

Returns

a dictionary of HTML attribute values.

The returned attributes are those provided by attribute_due_column, with an additional attribute providing the sort value used for ordering when the column header is clicked.

uw.local.grad.webui.list_render.attribute_rating_column(unitapp)[source]

Compute the HTML attributes for the rating column.

Parameters

unitapp – the candidate application.

Returns

a dictionary of HTML attribute values.

The returned attributes always include the sort value used for ordering when the column header is clicked. Additionally, a style attribute to set the background colour will be provided if the rating has a colour.

uw.local.grad.webui.list_render.attribute_state_column(unitapp)[source]

Compute the HTML attributes for the state column.

Parameters

unitapp – the candidate application.

Returns

a dictionary of HTML attribute values.

The returned attributes are just a data-sort-value providing the sort value used for ordering when the column header is clicked.

uw.local.grad.webui.list_render.format_citizenship(unitapp)[source]

Compute the HTML cell contents for the citizenship column.

Parameters

unitapp – the candidate application.

Returns

a fragment of HTML suitable for inclusion in a table cell.

Return type

xsc.Frag

Includes a short version of the citizenship status as well as the country code (if any).

uw.local.grad.webui.list_render.format_status_column(unitapp)[source]

Compute the HTML cell contents for the status column.

Parameters

unitapp – the candidate application.

Returns

a fragment of HTML suitable for inclusion in a table cell.

Includes the status description, how many faculty have accepted/waitlisted, and the time until/since the current workflow deadline.

Actually used only for the status display on the individual application view, since the Status column has been split into two columns.

Compute a table column specification for linking to applications.

Parameters
  • base_prefix – the base URL of the application (typically relative).

  • subpage – the subpage of the application to target.

  • confirm (bool) – whether to include the appl_id as a hidden field.

Returns

A column specification suitable for use with uw.web.html.format.make_table_format().

The contents will be the UW ID as a link to the application.

uw.local.grad.webui.list_render.render_sort_table(table_columns, data, fixed=False)[source]

Render a table so that the columns can be sorted by clicking the header.

Parameters
  • table_columns – column specifications for passing to uw.web.html.format.make_table_format().

  • data – the data for the rows of the table.

  • fixed – whether the table should include fixed col percentages

Formats the table using make_table_format and then alters the table to work with the sort table JavaScript module.

uw.local.grad.webui.roles module

Role management UI implementation.

Implements UI related to role management. This includes pages to view ones roles and for authorized users to adjust permissions for other users.

uw.local.grad.webui.stats module

Statistics generator UI implementation.

Implements the statistics pages. These pages display various counts of interest related to admissions. These pages are not currently used and probably need work in order to operate correcty with the current database schema.

uw.local.grad.webui.stats.make_navigation(items, css_class)[source]

uw.local.grad.webui.util module

Miscellaneous utility routines.

These are routines used in various places within Graduate Admissions that are not general enough to warrant a place in the general library.

uw.local.grad.webui.util.format_month_date(d)[source]

Print a date as a year and month.

None and datetime.max are converted into empty strings. Other dates are printed as YYYY-MM.

uw.local.grad.webui.util.get_email_address(cursor, person_id)[source]

Look up a person’s email address, given their Person ID.

Parameters
  • cursor – DB connection cursor.

  • person_id – the identity of the person.

Returns

the email address in the form userid@uwaterloo.ca.

uw.local.grad.webui.util.print_address(address)[source]

Format a parsed (parse_address) address into HTML.

Parameters

address (namedtuple) – An address represented as a namedtuple of field values.

Returns

The address formatted as HTML.

uw.local.grad.webui.util.render_frontpage_header(basis, base_prefix='')[source]

Render the role front page header information.

Parameters
  • basis – a brief explanation of how applications are selected to be displayed on the front page.

  • base_prefix – the relative URL of the role frontpage.

uw.local.grad.webui.view module

Application display implementation.

This module contains the application search form implementation, as well as the WSGI structure definition connecting the various application display pages together.

uw.local.grad.webui.view.canonicalizeOuacNo(ouac)[source]

Canonicalize an OUAC application number.

Parameters

ouac – OUAC application number.

Returns

the application number in a fixed format.

The number may be provided with or without hyphens in specific locations, and with or without the trailing 0. The result will always omit the hyphens but include the trailing 0.

uw.local.grad.webui.view.findCurrentWorkApplicationsByName(cursor, search, staff_person_id)[source]

Find current applications by applicant name.

Parameters
  • cursor – DB connection cursor.

  • search – part of the name of the student whose applications should be found; “*” may be used to match any string.

  • staff_person_id – the identity of the person on whose behalf the search is being conducted.

uw.local.grad.webui.view.findCurrentWorkApplicationsByOuacNo(cursor, ouac, staff_person_id)[source]

Find current applications by OUAC application number.

Parameters
  • cursor – DB connection cursor.

  • ouac – OUAC application number.

  • staff_person_id – the identity of the person on whose behalf the search is being conducted.

uw.local.grad.webui.view.findCurrentWorkApplicationsByUserid(cursor, userid, staff_person_id)[source]

Find current applications by applicant userid.

Parameters
  • cursor – DB connection cursor.

  • uwid – the userid of the student whose applications should be found.

  • staff_person_id – the identity of the person on whose behalf the search is being conducted.

uw.local.grad.webui.view.findCurrentWorkApplicationsByUwid(cursor, uwid, staff_person_id)[source]

Find current applications by applicant UW ID.

Parameters
  • cursor – DB connection cursor.

  • uwid – the UW ID of the student whose applications should be found.

  • staff_person_id – the identity of the person on whose behalf the search is being conducted.

uw.local.grad.webui.view.findNamesByPartialName(cursor, names, staff_person_id, limit=None)[source]

Returns a tuple of (uw_id, FN, MN, LN, PN) where one of the name components matches one (or more) of the name fragments seperated by space through a raw case insentitive comparison.

Parameters
  • cursor – DB connection cursor.

  • names – a string with names seperated by space (e.g. “Marie Anne”)

  • staff_person_id – the identity of the person on whose behalf the search is being conducted.

  • limit – The number of results to return, None means no limit

Returns

A tuple of postgresql result items.

uw.local.grad.webui.view.render_search_form(cursor, values, errors, apps)[source]

Render the application search form as HTML.

Parameters
  • cursor – DB connection cursor.

  • values – submitted form values.

  • errors – errors to display within the form.

  • apps – applications found to display below the search form, or None to omit the application list.

uw.local.grad.webui.view_accept module

Application display accept page implementation.

WSGI handler and routines for formatting the accept page.

uw.local.grad.webui.view_accept.make_level_select(cursor, name, level_code=None)[source]

Render an HTML form input for choosing a level code.

Return an HTML <select> for choosing a plan level.

uw.local.grad.webui.view_accept.render_accept(unitapp, remote_identity, roles, level_code=None, willfund=False, scholarship=False, fundinghelp=False, **params)[source]

Render the acceptance form as HTML.

Parameters
  • unitapp – the candidate application.

  • remote_identity – the user’s remote identity.

  • roles – the set of roles possessed by the user.

  • level_code – the prefilled level code to include in the form.

  • willfund – whether the willfund box should be checked on the form.

  • scholarship – whether the scholarship box should be checked on the form.

  • fundinghelp – whether the fundinghelp box should be checked on the form.

For use with uw.local.grad.webui.view_render.render_page(); also called from the corresponding form POST handler to allow correction of errors.

uw.local.grad.webui.view_accept.render_waitlist(unitapp, remote_identity, roles, waitlist=False)[source]

Render the waitlisting form as HTML.

Parameters
  • unitapp – the candidate application.

  • remote_identity – the user’s remote identity.

  • roles – the set of roles possessed by the user.

  • waitlist (bool) – whether the confirmation checkbox should be checked.

For use with uw.local.grad.webui.view_render.render_page(); also called from the corresponding form POST handler to allow correction of errors.

uw.local.grad.webui.view_comments module

Application dispay comments page implementation.

Routines for formatting application comments section. These are now part of the main application page. For historical reasons they are in a separate file from the rest of the main page.

uw.local.grad.webui.view_comments.render_comments(unitapp, remote_identity, is_admin)[source]

Render the comments on an application as HTML.

Parameters
  • unitapp – the candidate application.

  • remote_identity – The identification for the currently logged-in user

  • is_admin – whether the user is an administrator.

Displays general comments already made on the application, and provides a form for submitting new comments. If is_admin is specified, internal comments are shown and a form is provided for submitting internal comments.

uw.local.grad.webui.view_comments.render_opinion(unitapp, remote_identity, is_faculty)[source]

Render the user’s opinion of an application as HTML.

Parameters
  • unitapp – the candidate application.

  • remote_identity – the user’s remote identity.

  • is_faculty – whether the user is viewing the application as a faculty member.

Displays the user’s opinion along with related information, including who has recommended the application to the user and been recommended the application by the user. There are also forms for changing the opinion, waitlisting or accepting the application, and recommending the application.

uw.local.grad.webui.view_comments.render_opinion_select(cursor, name, value, class_='')[source]

Render an opinion of an application as an HTML form select control.

Parameters
  • cursor – DB connection cursor.

  • name – the form control name.

  • value – the form control value, the current opinion.

If the current opinion is “WTL” (waitlisted), it will be displayed as “INT” (interested) instead. The selector will not include the choices that correspond to waitlisting or accepting the application.

TODO: what if the current opinion is “ACC” (accepted)?

uw.local.grad.webui.view_compilation module

Compilation document download handler.

Provides a handler which sends the PDF compilation document relevant to the unit application which is in context, using the appl_id form parameter to ensure the correct document is sent.

uw.local.grad.webui.view_contact module

Application dispay contact page implementation.

WSGI handler and routines for formatting the contact page.

uw.local.grad.webui.view_contact.render_contact(unitapp, remote_identity, roles)[source]

Render application contact information as HTML.

Parameters
  • unitapp – the candidate application.

  • remote_identity – the user’s remote identity.

  • roles – the set of roles possessed by the user.

For use with uw.local.grad.webui.view_render.render_page().

uw.local.grad.webui.view_edit module

Application dispay edit page implementation.

WSGI handler and routines for formatting the edit page.

uw.local.grad.webui.view_edit.render_edit(unitapp, remote_identity, roles)[source]

Render application editing form as HTML.

Parameters
  • unitapp – the candidate application.

  • remote_identity – the user’s remote identity.

  • roles – the set of roles possessed by the user.

For use with uw.local.grad.webui.view_render.render_page().

uw.local.grad.webui.view_history module

Application display history page implementation.

WSGI handler and routines for formatting the history page.

uw.local.grad.webui.view_history.render_history(unitapp, remote_identity, roles)[source]

Render history information for an application as HTML.

Parameters
  • unitapp – the candidate application.

  • remote_identity – the user’s remote identity.

  • roles – the set of roles possessed by the user.

For use with uw.local.grad.webui.view_render.render_page().

uw.local.grad.webui.view_main module

Application display main page implementation.

WSGI handler and routines for formatting the main application display. For historical reasons some parts of the application display rendering are imported from .view_comments.

uw.local.grad.webui.view_main.format_degree(degree)[source]

Format the ‘degree (specialization)’ in ‘Previous Instituions’ section so the parentheses are not shown when specialization is not provided

Parameters

degree – one of the candidate’s degrees

Returns

a string that shows ‘degree (specialization)’ if specialization is provided, otherwise shows only the degree

uw.local.grad.webui.view_main.format_test_score(component)[source]

Format the component score in ‘Test Scores’ section so the parentheses are not shown when percentile is not applicable

Parameters

component – the component score associated with a test

Returns

a string that shows ‘score (percentile)’ if percentile is applicable, otherwise shows only the component score

uw.local.grad.webui.view_main.render_main(unitapp, remote_identity, roles)[source]

Render the body of the main application display page.

Parameters
  • unitapp – the candidate application.

  • remote_identity – the user’s remote identity.

  • roles – the roles possessed by the user for this application.

The page body includes “opinion”-related information, summary information, and comments.

Designed to be used only with uw.local.grad.webui.view_render.render_page().

uw.local.grad.webui.view_main.render_summary(unitapp)[source]

Render the summary of an application.

Parameters

unitapp – the candidate application.

This includes conditions, citizenship, financial support, previous institutions, and test scores.

uw.local.grad.webui.view_offer module

Application display offering page implementation.

WSGI handler and routines for formatting the offering page.

uw.local.grad.webui.view_offer.render_offer(unitapp, remote_identity, roles)[source]

Render offer information for an application as HTML.

Parameters
  • unitapp – the candidate application.

  • remote_identity – the user’s remote identity.

  • roles – the set of roles possessed by the user.

For use with uw.local.grad.webui.view_render.render_page().

uw.local.grad.webui.view_render module

Overall application display rendering.

Routines for formatting an application display. The overall page, including the application header, is formatting by functions in this module. The portions of the display which differ from page to page are handled by other view_* modules, as are the actual WSGI handlers for the various pages of an application.

uw.local.grad.webui.view_render.format_compilation_document(cursor, unitapp, is_admin, main_url)[source]

Format the HTML interface to an application’s compilation document.

Parameters
  • cursor – DB connection cursor.

  • unitapp – the candidate application.

  • is_admin – whether the current user is an administrator. If so, more information is shown and the form for uploading the compilation document is included.

  • main_url – the base URL of the candidate application.

If the compilation document has been uploaded, a download link is provided, otherwise a message indicating it is not available.

uw.local.grad.webui.view_render.get_active_subpages(subpages, roles)[source]

Determine which of the specified subpages are active for the roles.

Parameters
  • subpages (list) – the eligible subpages.

  • roles (set) – the set of active role codes.

Returns

the subpages which are visible to the active roles, i.e., those whose associated roles intersect the active roles.

Each subpage is represented as a tuple of (subpage, roles) where the subpage describes the subpage and the roles are a set of role codes.

uw.local.grad.webui.view_render.render_page(unitapp, roles, render_body, remote_identity)[source]

Render the entire main part of the HTML page for an application.

Parameters
  • unitapp – the candidate application.

  • roles – the set of roles possessed by the user.

  • render_body – a function to render the body of the page.

  • remote_identity – the user’s remote identity.

Returns

the page title and HTML page body.

This routine records that the user has seen the application. If they have not yet seen it, this changes their opinion from “Unseen” to “Undecided”.

The resulting page consists of a header portion rendered directly by this function and a body below which is rendered by the render_body parameter.

uw.local.grad.webui.wsgifunc module

Overall URL structure for Web UI.

This module defines the overall URL structure of the Graduate Admissions application in the wsgifunc function. It also implements the handler for the top-level URL of the application.

Module contents

Web UI implementation for Graduate Admissions.

This package implements the Web interface for the Graduate Admissions application. The overall URL structure is defined by wsgifunc.py.