~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to ivle/webapp/admin/subject.py

  • Committer: William Grant
  • Date: 2009-07-05 03:18:14 UTC
  • mto: (1294.4.2 ui-the-third)
  • mto: This revision was merged to the branch mainline in revision 1353.
  • Revision ID: grantw@unimelb.edu.au-20090705031814-yn8oymmawsq0da78
Split out ivle.webapp.admin's routes into annotated functions in ivle.webapp.traversal.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
 
37
37
from ivle.webapp.base.xhtml import XHTMLView
38
38
from ivle.webapp.base.plugins import ViewPlugin, MediaPlugin
39
 
from ivle.webapp.errors import NotFound
40
39
from ivle.webapp import ApplicationRoot
41
40
 
42
41
from ivle.database import Subject, Semester, Offering, Enrolment, User,\
47
46
from ivle.webapp.admin.projectservice import ProjectSetRESTView,\
48
47
                                             ProjectRESTView
49
48
from ivle.webapp.admin.offeringservice import OfferingRESTView
 
49
from ivle.webapp.admin.traversal import (root_to_subject,
 
50
            subject_to_offering, offering_to_projectset, offering_to_project,
 
51
            subject_url, offering_url, projectset_url, project_url)
50
52
 
51
53
class SubjectsView(XHTMLView):
52
54
    '''The view of the list of subjects.'''
215
217
    def __init__(self, offering):
216
218
        self.offering = offering
217
219
 
218
 
def root_to_subject(root, name):
219
 
    return root.store.find(Subject, short_name=name).one()
220
 
 
221
 
def subject_to_offering(subject, year, semester):
222
 
    return subject.offering_for_semester(year, semester)
223
 
 
224
 
def offering_to_project(offering, name):
225
 
    return Store.of(offering).find(Project,
226
 
                                   Project.project_set_id == ProjectSet.id,
227
 
                                   ProjectSet.offering == offering).one()
228
 
 
229
 
def offering_to_projectset(offering, name):
230
 
    return Store.of(offering).find(ProjectSet,
231
 
                                   ProjectSet.offering == offering).one()
232
 
 
233
220
class Plugin(ViewPlugin, MediaPlugin):
234
 
    forward_routes = [(ApplicationRoot, 'subjects', root_to_subject, 1),
235
 
                      (Subject, None, subject_to_offering, 2),
236
 
                      (Offering, '+projects', offering_to_project, 1),
237
 
                      (Offering, '+projectsets', offering_to_projectset, 1),
238
 
                      ]
 
221
    forward_routes = (root_to_subject, subject_to_offering,
 
222
                      offering_to_project, offering_to_projectset)
 
223
    reverse_routes = (subject_url, offering_url, projectset_url, project_url)
239
224
 
240
225
    views = [(ApplicationRoot, ('subjects', '+index'), SubjectsView),
241
226
             (Offering, ('+enrolments', '+new'), EnrolView),