uw.local.quest.webui package

Submodules

uw.local.quest.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.

uw.local.quest.webui.building module

Building-related UI pages.

This includes the overall list of buildings, as well as the per-building list of rooms.

uw.local.quest.webui.compare module

Course compare-related UI pages.

This is a tool for course compare searches. User can search multiple courses at once.

uw.local.quest.webui.course module

Course-related UI pages.

This includes the per-course information summary page.

uw.local.quest.webui.course.format_course_detail(cursor, courses, term, subject=None, base_url='../../../../')[source]

Generates a table for course detail.

Parameters
  • cursor – DB connection cursor.

  • courses (list) – the list of relevant courses.

  • term – the relevant term.

  • base_url (str) – the base URL for links.

Returns

a table displaying course descriptions and section meet schedules.

uw.local.quest.webui.course.format_schedule(base_url, cursor, sections, term)[source]

Generates the section meets schedules.

Parameters
  • base_url (str) – the base URL for links.

  • cursor – DB connection cursor.

  • sections (list) – the list of relevant sections.

  • term – the relevant term.

Returns

a list of table rows of schedules for each meets.

uw.local.quest.webui.course.format_schedule_table(rowspan, table)[source]

Generates the section meet table rows.

Parameters
  • rowspan (int) – row count for each section meet.

  • table (dict) – dictionary of section meet information.

Returns

a list of table rows of meet schedules.

uw.local.quest.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 admin unit, sitting, examination, or room.

uw.local.quest.webui.delegate.building_delegate(dir_handler, arc_handler)[source]

Delegate to URL handler based on building_code in URL.

uw.local.quest.webui.delegate.building_from_arc(arc, cursor, **params)[source]

Interpret a URL path arc as a building_code.

Parameters
  • arc – the URL path arc.

  • cursor – DB connection cursor.

  • params – any additional context not needed for this arc parser.

uw.local.quest.webui.delegate.column_delegate(dir_handler, arc_handler)[source]

Delegate to URL handler based on column in URL

uw.local.quest.webui.delegate.column_from_arc(arc, cursor, **params)[source]

Interpret a URL path arc as an owner.

Parameters
  • arc – the URL path arc.

  • cursor – DB connection cursor.

  • params – any additional context not needed for this arc parser.

uw.local.quest.webui.delegate.course_delegate(dir_handler, arc_handler)[source]

Delegate to URL handler based on course_id or catalog in URL.

uw.local.quest.webui.delegate.course_from_arc(arc, cursor, term=None, subject=None, **params)[source]

Interpret a URL path arc as a course_id or catalog.

Parameters
  • arc – the URL path arc.

  • cursor – DB connection cursor.

  • term – the relevant term.

  • subject – the relevant subject, if any.

  • params – any additional context not needed for this arc parser.

If there is no subject in context, this will interpret arc as a course_id. Otherwise, the function interprets arc as a catalog and find its course_id, returning a list of all courses with the given course_id.

If there is a subject in context but no term, this will interpret arc as a catalog and find all possible course_ids, returning a list of all courses with the given subject and catalog.

uw.local.quest.webui.delegate.course_prefix_delegate(dir_handler, arc_handler)[source]

Delegate to URL handler based on catalog prefix in URL.

uw.local.quest.webui.delegate.course_prefix_from_arc(arc, cursor, term, subject, **params)[source]

Interpret a URL path arc as a catalog prefix.

Parameters
  • arc – the URL path arc.

  • cursor – DB connection cursor.

  • term – the relevant term.

  • subject – the relevant subject.

  • params – any additional context not needed for this arc parser.

uw.local.quest.webui.delegate.degree_delegate(dir_handler, arc_handler)[source]

Delegate to URL handler based on degree code in URL.

uw.local.quest.webui.delegate.degree_from_arc(arc, cursor, **params)[source]

Interpret a URL path arc as a degree code.

Parameters
  • arc – the URL path arc.

  • cursor – DB connection cursor.

  • params – any additional context not needed for this arc parser.

uw.local.quest.webui.delegate.instructor_delegate(dir_handler, arc_handler)[source]

Delegate to URL handler based on userid in URL.

uw.local.quest.webui.delegate.instructor_from_arc(arc, cursor, **params)[source]

Interpret a URL path arc as a plan code.

Parameters
  • arc – the URL path arc.

  • cursor – DB connection cursor.

  • params – any additional context not needed for this arc parser.

uw.local.quest.webui.delegate.owner_delegate(dir_handler, arc_handler)[source]

Delegate to URL handler based on owner in URL

uw.local.quest.webui.delegate.owner_from_arc(arc, cursor, **params)[source]

Interpret a URL path arc as an owner.

Parameters
  • arc – the URL path arc.

  • cursor – DB connection cursor.

  • params – any additional context not needed for this arc parser.

uw.local.quest.webui.delegate.plan_delegate(dir_handler, arc_handler)[source]

Delegate to URL handler based on plan code in URL.

uw.local.quest.webui.delegate.plan_from_arc(arc, cursor, unit, **params)[source]

Interpret a URL path arc as a plan code.

Parameters
  • arc – the URL path arc.

  • cursor – DB connection cursor.

  • params – any additional context not needed for this arc parser.

uw.local.quest.webui.delegate.program_delegate(dir_handler, arc_handler)[source]

Delegate to URL handler based on program code in URL.

uw.local.quest.webui.delegate.program_from_arc(arc, cursor, unit, **params)[source]

Interpret a URL path arc as a program code.

Parameters
  • arc – the URL path arc.

  • cursor – DB connection cursor.

  • params – any additional context not needed for this arc parser.

uw.local.quest.webui.delegate.room_delegate(dir_handler, arc_handler)[source]

Delegate to URL handler based on room_code in URL.

uw.local.quest.webui.delegate.room_from_arc(arc, cursor, building, **params)[source]

Interpret a URL path arc as a room_code.

Parameters
  • arc – the URL path arc.

  • cursor – DB connection cursor.

  • building – the relevant building.

  • params – any additional context not needed for this arc parser.

The room is found by building_code and arc as room_code.

uw.local.quest.webui.delegate.room_prefix_delegate(dir_handler, arc_handler)[source]

Delegate to URL handler based on room_code prefix in URL.

uw.local.quest.webui.delegate.room_prefix_from_arc(arc, cursor, building, **params)[source]

Interpret a URL path arc as a room_code prefix.

Parameters
  • arc – the URL path arc.

  • cursor – DB connection cursor.

  • building – the relevant building.

  • params – any additional context not needed for this arc parser.

The room is found by building_code and arc as room_code prefix.

uw.local.quest.webui.delegate.subject_delegate(dir_handler, arc_handler)[source]

Delegate to URL handler based on subject_code in URL.

uw.local.quest.webui.delegate.subject_from_arc(arc, cursor, **params)[source]

Interpret a URL path arc as a subject_code.

Parameters
  • arc – the URL path arc.

  • cursor – DB connection cursor.

  • params – any additional context not needed for this arc parser.

uw.local.quest.webui.delegate.table_delegate(dir_handler, arc_handler)[source]

Delegate to URL handler based on subject_code in URL.

uw.local.quest.webui.delegate.table_from_arc(arc, cursor, **params)[source]

uw.local.quest.webui.format module

Convenient quest formatting routines.

uw.local.quest.webui.format.format_courses(cursor, courses, subject=None, term=None, base_url='')[source]

Formats course information to tables

Parameters
  • cursor – DB connection cursor.

  • courses – list of relevant courses.

  • subject – the relevant subject.

Returns

a table of the course information details.

uw.local.quest.webui.format.format_instructor(instructor, base_url='')[source]

Format an instructor’s identity as HTML.

Parameters
  • instructor – the relevant instructor.

  • base_url – the base URL for the link to instructor page.

Returns

the instructor’s name linking to their summary page.

uw.local.quest.webui.format.format_instructor_list(instructor_list, base_url='')[source]

Format the instructor list on /quest/{user_id}/instructor.

Parameters

instructor_list – a list of all the instructors.

Returns

all the instructors names as paragraph elements linked to their summary page.

Formats links to be used for pagination

Parameters
  • cur_page – the current page

  • num_pages – total number of pages

  • query – the query string

Returns

a list of anchor tags.

uw.local.quest.webui.format.format_subject(subject, base_url='')[source]

Format a subject as HTML.

Parameters
  • subject – the relevant subject.

  • base_url – the base URL for the link to subject page.

Returns

the subject code and subject short description linking to the subject list page.

uw.local.quest.webui.format.format_term(term, base_url='')[source]

Format a term as HTML.

Parameters
  • term – the relevant term.

  • base_url – the base URL for the link to term page.

Returns

the term description linking to the term list page.

uw.local.quest.webui.instructor module

Instructor-related UI pages.

This includes the overall list of instructors, as well as the list of courses taught by the instructor.

Instructor search handler.

Parameters
  • cursor – DB connection cursor.

  • search (str) – user search.

Returns

a list of instructors from the search result.

uw.local.quest.webui.room module

Room-related UI pages.

This includes the room_handler for room details and weekly timetable.

uw.local.quest.webui.schema module

uw.local.quest.webui.schema.decode(data, data_type)[source]

Converts a memoryview object into human-readable string

Parameters
  • data – memoryview object to be converted

  • data_type – type of data (ie. VARCHAR2)

Returns

the data in string format.

uw.local.quest.webui.schema.format_oracle_date(data)[source]

Converts oracle DATE into human-readable format. The first 2 bytes represent the century and year respectively offset by 100. The next 2 bytes represent the month and the day respectively.

Parameters

data – data in bytestring form

Returns

a date string in the form of {year-month-day}

uw.local.quest.webui.schema.format_oracle_number(data)[source]

Converts oracle NUMBER into human-readable format. The first bit of the first byte represents the sign. The remaining bits represent the exponent offset by 65. The remaining bytes represent the mantissa.

Parameters

data – data in bytestring form

Returns

a number in base 10 form

uw.local.quest.webui.schema.int_if_not_none(data)[source]

Converts data to integer type if the data is not None

Parameters

data – integer represented by some unknown data type

Returns

integer if the data is not None, None otherwise.

uw.local.quest.webui.schema.is_on_index(column, indexes)[source]

Checks if an index is on a column

Parameters
  • column – named tuple representing a column

  • indexes – list of named tuples each representing an index

Returns

whether an index is on the column

uw.local.quest.webui.schema.make_pagination_format(offset, results_per_page, data_len, query)[source]

Formats pagination links for a large table

Parameters
  • offset – offset parameter in sql query

  • results_per_page – the number of results shown per page

  • data_len – total length of the queried data

  • query – the query string

Returns

a list of anchor tags.

uw.local.quest.webui.subject module

Subject-related UI pages.

uw.local.quest.webui.term module

Term-related UI pages.

This includes the overall list of course offerings, as well as the per-term list of offerings.

uw.local.quest.webui.timetable module

Timetable-related UI pages.

Implemention of Web UI for timetable schedules of given section meets.

uw.local.quest.webui.timetable.add_cell_contents(result, cell_content, overlap_content, lower, upper, default_start_date, default_end_date, has_time_overlaps, base_url='../')[source]

Appends cell content to the given table cell which is represented by result.

Parameters
  • result ([]) – list containing html elements of the contents in the cell.

  • cell_content – a string or a list containing the contents of the cell.

  • overlap_content – dictionary containing information about the overlap range and whether there is a date overlap.

  • lower (datetime.time) – the start time of the cell content.

  • upper (datetime.time) – the end time of the cell content.

  • default_start_date (date) – default start date of the term.

  • default_end_date (date) – default end date of the term.

  • has_time_overlaps (bool) – a boolean describing if the cell contains time overlaps.

  • base_url (str) – the base URL for the link to the course detail page.

uw.local.quest.webui.timetable.day_int_to_str(day)[source]

Converts day integer representing a week day to human-readable string

Parameters

day (int) – integer representing day of the week.

Returns

human-readable string of a week day ie. ‘Friday’.

uw.local.quest.webui.timetable.format_cell_detail(day, contents, lower, upper, default_meet_days, overlap_rows, base_url='../')[source]

Cell detail formatter.

Parameters
  • day (int) – integer representing day of the week.

  • contents – a string or a list containing the contents of the cell.

  • lower (datetime.time) – the start time of the cell content.

  • upper (datetime.time) – the end time of the cell content.

  • count) default_meet_days ((DateRange,) – object describing default date range of term

  • overlap_rows – a dictionary of a tuple with information about the potential date overlap and the overlap objects by the given time slot.

  • base_url (str) – the base URL for the link to the course detail page.

Returns

an html table cell with the appropriate rowspan.

uw.local.quest.webui.timetable.format_cells(contents, col_headers, row_headers, default_meet_days, overlap_rows, base_url='../')[source]

Timetable cell generator based on given columns and rows.

Parameters
  • contents (dict) – dictionary of cell contents with column headers as keys.

  • col_headers (list) – list containing the table column headers.

  • row_headers (list) – list of time objects to be used as table row labels.

  • count) default_meet_days ((DateRange,) – object describing default date range of term.

  • overlap_rows – a dictionary of a tuple with information about the potential date overlap and the overlap objects by the given time slot.

  • base_url (str) – the base URL for the link to the course detail page.

Returns

a table of formatted cells based on the contents.

uw.local.quest.webui.timetable.format_date_overlaps(overlap_row, default_start_date, default_end_date)[source]

Separate the overlapping sections (by time and date) from the dictionary

Parameters
  • overlap_row (dict) – dictionary of overlaps by start and end time.

  • default_start_date (date) – default start date of the term.

  • default_end_date (date) – default end date of the term.

Returns

a dictionary of a tuple with information about the potential date overlap and the overlap objects by the given time slot.

uw.local.quest.webui.timetable.format_overlaps(sections, day)[source]

Separate the overlapping sections (by time) from the dictionary

Parameters
  • sections (dict) – dictionary of sections by start and end time.

  • day (int) – integer representing day of the week.

Returns

a dictionary of sections without overlaps and a set of strings of the title of the overlapping sections.

uw.local.quest.webui.timetable.format_timetable(section_list, default_meet_days, base_url='../', day_range=range(0, 7))[source]

Formats the timetable of a list of section meets.

Parameters
  • section_list – itertool groupby object of sections to be displayed on timetable grouped by section ids.

  • base_url (str) – the base URL for the link to the course detail page.

  • count) default_meet_days ((DateRange,) – object describing default date range of term

  • day_range (list) – list of integers representing the days of a week.

Returns

a timetable of the given sections meet times.

uw.local.quest.webui.timetable.sections_by_days(sections, day_range)[source]

Separates a dictionary of sections by days.

Parameters
  • sections (dict) – dictionary of sections by section ids.

  • day_range (list) – list of integers representing the days of a week.

Returns

a dictionary by days of a dictionary of sections by time range.

uw.local.quest.webui.timetable_test module

class uw.local.quest.webui.timetable_test.TimetableTests(methodName='runTest')[source]

Bases: unittest.case.TestCase

setUp()[source]

Set up method that runs before each test case.

test_format_overlap_with_overlap_1()[source]
Tests if format_overlaps () works when given 2 overlapping meet

times (13:30 - 16:20 and 15:30 - 18:20)

Returns

a tuple of a dictionary and a set detailing the overlap

test_format_overlap_with_overlap_2()[source]
Tests if format_overlaps () works when given 2 overlapping meet

times (13:30 - 16:20 and 12:30 - 18:20)

Returns

a tuple of a dictionary and a set detailing the overlap

test_format_overlap_with_overlap_3()[source]

Tests if format_overlaps () works when given 2 overlapping meet times (13:30 - 16:20 and 12:30 - 15:20)

Returns

a tuple of a dictionary and a set detailing the overlap

test_format_overlaps_no_overlap_1()[source]
Tests if format_overlaps () works when given a schedule with a

single meet time.

Returns

a tuple of the original schedule and an empty set.

test_format_overlaps_no_overlap_2()[source]
Tests if format_overlaps () works when given 2 non-overlapping

meet times.

Returns

a tuple of the original schedule and an empty set.

test_sections_by_days()[source]

Tests if sections_by_days () works as expected.

Returns

a dictionary of sections with the days as keys.

uw.local.quest.webui.ui module

UI-related utility routines for Quest management.

These are functions that are useful throughout the Quest management portion of the application.

uw.local.quest.webui.ui.get_default_term()[source]

uw.local.quest.webui.unit module

Unit-related UI pages.

This includes the overall list of units, as well as the per-unit plan list.

uw.local.quest.webui.unit.format_object_list_table(lst, lst_type)[source]

Formats a table to be displayed on pages showing a list of specific object types (plans, programs, or subjects)

Parameters
  • lst – list of content for the table.

  • lst_type – string describing the type of the list. Either ‘plan’, ‘program’, or ‘subject’.

Returns

an html table for either plans, programs, or subjects

uw.local.quest.webui.unit.format_table(lst, lst_type, unit)[source]

Formats a table to be displayed on a unit page

Parameters
  • lst – list of content for the table.

  • lst_type – string describing the type of the list. Either ‘plan’, ‘program’, or ‘subject’.

  • unit – the relevant unit.

Returns

an html table for either plans, programs, or subjects

uw.local.quest.webui.wsgifunc module

Overall URL structure for Web UI.

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

uw.local.quest.webui.wsgifunc.format_last_term(cursor, userid)[source]
uw.local.quest.webui.wsgifunc.format_tab_form(name, tab_id, content, warning)[source]

Creates a (tab name, tab id, tab form) triple to use with the format_tabs function.

Parameters
  • name – Tab name.

  • tab_id – Tab id.

  • content – List of HTML elements to include in the form.

  • warning – HTML element for the invalid field warning.

Returns

(Tab name, tab id, tab form) triple. Form includes a warning message and submission button.

uw.local.quest.webui.wsgifunc.redirect(cursor, form)[source]

Page redirect handler.

Parameters
  • cursor – DB connection cursor.

  • form – the GET input form.

Returns

a list of instructors if instructor search form is submitted. Otherwise, it redirects to the relative pages.

Module contents

Web UI implementation for Quest Application.

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