~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: 2010-02-11 12:17:37 UTC
  • Revision ID: grantw@unimelb.edu.au-20100211121737-1zsmpp8i8rbyliku
Add a subject listing with new/edit icons.

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
            subject_url, offering_url, projectset_url, project_url)
52
52
from ivle.webapp.admin.breadcrumbs import (SubjectBreadcrumb,
53
53
            OfferingBreadcrumb, UserBreadcrumb, ProjectBreadcrumb)
 
54
from ivle.webapp.core import Plugin as CorePlugin
54
55
from ivle.webapp.groups import GroupsView
 
56
from ivle.webapp.media import media_url
55
57
from ivle.webapp.tutorial import Plugin as TutorialPlugin
56
58
 
57
59
class SubjectsView(XHTMLView):
66
68
        ctx['req'] = req
67
69
        ctx['user'] = req.user
68
70
        ctx['semesters'] = []
 
71
        ctx['mediapath'] = media_url(req, CorePlugin, 'images/')
 
72
        ctx['SubjectEdit'] = SubjectEdit
 
73
 
69
74
        for semester in req.store.find(Semester).order_by(Desc(Semester.year),
70
75
                                                     Desc(Semester.semester)):
71
76
            if req.user.admin:
77
82
            if len(offerings):
78
83
                ctx['semesters'].append((semester, offerings))
79
84
 
 
85
        # Admins get a separate list of subjects so they can add/edit.
 
86
        if req.user.admin:
 
87
            ctx['subjects'] = req.store.find(Subject).order_by(Subject.name)
 
88
 
80
89
 
81
90
class SubjectShortNameUniquenessValidator(formencode.FancyValidator):
82
91
    """A FormEncode validator that checks that a subject name is unused.