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.
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.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.
-
uw.local.quest.webui.format.
format_pagination_links
(cur_page, num_pages, query)[source]¶ 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.instructor module¶
Instructor-related UI pages.
This includes the overall list of instructors, as well as the list of courses taught by the instructor.
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
-
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_test module¶
-
class
uw.local.quest.webui.timetable_test.
TimetableTests
(methodName='runTest')[source]¶ Bases:
unittest.case.TestCase
-
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.
-
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.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_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.
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.