Source code for uw.local.teaching.webui.term
"""Term-related UI pages.
This includes the overall list of course offerings, as well as the per-term
list of offerings. These both depend on the logged-in user.
"""
from operator import attrgetter
from itertools import groupby
from ll.xist.ns import html
from uw.web.html.format import format_return
from uw.web.html.join import html_join
from uw.web.wsgi.delegate import *
from uw.web.wsgi.function import return_html
from uw.local import termtools
from ...util.identity import use_remote_identity
@delegate_get_post
@use_remote_identity
@return_html
def term_index (cursor, remote_identity):
"""Staff term list URL handler.
:param cursor: DB connection cursor
:return: tuple of (description, HTML elements for list of terms)
:rtype: (str, list)
Handles requests for the list of terms. Displays a list of all offerings
relevant to the user, grouped by term and linked to the individual offering
pages.
"""
result = [format_return ('Main Menu')]
admin_units = cursor.offerings_by_person (person_id=remote_identity.person_id)
result.append (format_offerings (admin_units))
return 'My Offerings', result
@delegate_get_post
@use_remote_identity
@return_html
def term_handler (cursor, remote_identity, term):
"""Staff term information URL handler.
:param cursor: DB connection cursor
:param term: the relevant term
:return: tuple of (description, offerings)
:rtype: (str, list)
Handles requests for the per-term summary page. Displays a list of all
offerings in the term relevant to the user, linked to the individual
offering pages.
"""
result = [format_return ('Main Menu', 'My Offerings')]
admin_units = cursor.offerings_by_person_term (person_id=remote_identity.person_id, term_id=term.code ())
result.append (html.p (format_term_offerings (admin_units)))
return 'Your %s Offerings' % term.description (), result