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

« back to all changes in this revision

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

  • Committer: Nick Chadwick
  • Date: 2009-02-23 23:11:26 UTC
  • mto: (1099.1.227 exercise-ui)
  • mto: This revision was merged to the branch mainline in revision 1100.
  • Revision ID: chadnickbok@gmail.com-20090223231126-zfb5wfw8jnxazefl
Fixed database so that lecturers can edit worksheets

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
import cgi
28
28
 
29
29
from ivle.webapp.base.xhtml import XHTMLView
30
 
from ivle.webapp.base.plugins import BasePlugin
 
30
from ivle.webapp.base.plugins import ViewPlugin, MediaPlugin
31
31
from ivle.webapp.errors import NotFound
32
32
from ivle.database import Subject
33
33
from ivle import util
38
38
    template = 'subjects.html'
39
39
    appname = 'subjects' # XXX
40
40
 
 
41
    def authorize(self, req):
 
42
        return req.user is not None
 
43
 
41
44
    def populate(self, req, ctx):
42
45
        enrolled_subjects = req.user.subjects
43
46
        unenrolled_subjects = [subject for subject in
47
50
        ctx['enrolled_subjects'] = []
48
51
        ctx['other_subjects'] = []
49
52
 
50
 
        req.content_type = "text/html"
51
 
        req.write_html_head_foot = True
52
 
 
53
53
        for subject in enrolled_subjects:
54
54
            new_subj = {}
55
55
            new_subj['name'] = subject.name
64
64
                ctx['other_subjects'].append(new_subj)
65
65
 
66
66
 
67
 
class Plugin(BasePlugin):
 
67
class Plugin(ViewPlugin, MediaPlugin):
68
68
    urls = [
69
69
        ('subjects/', SubjectsView),
70
70
    ]
 
71
 
 
72
    tabs = [
 
73
        ('subjects', 'Subjects', 'Announcements and information about the '
 
74
         'subjects you are enrolled in.', 'subjects.png', 'subjects', 5)
 
75
    ]
 
76
 
 
77
    media = 'subject-media'