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

« back to all changes in this revision

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

MergedĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
class SubjectsView(XHTMLView):
37
37
    '''The view of the list of subjects.'''
38
38
    template = 'subjects.html'
39
 
    appname = 'subjects' # XXX
 
39
    tab = 'subjects'
40
40
 
41
41
    def authorize(self, req):
42
42
        return req.user is not None
43
43
 
44
44
    def populate(self, req, ctx):
45
 
        enrolled_subjects = req.user.subjects
46
 
        unenrolled_subjects = [subject for subject in
47
 
                               req.store.find(Subject)
48
 
                               if subject not in enrolled_subjects]
49
 
 
50
 
        ctx['enrolled_subjects'] = []
51
 
        ctx['other_subjects'] = []
52
 
 
53
 
        for subject in enrolled_subjects:
54
 
            new_subj = {}
55
 
            new_subj['name'] = subject.name
56
 
            new_subj['url'] = subject.url
57
 
            ctx['enrolled_subjects'].append(new_subj)
58
 
 
59
 
        if len(unenrolled_subjects) > 0:
60
 
            for subject in unenrolled_subjects:
61
 
                new_subj = {}
62
 
                new_subj['name'] = subject.name
63
 
                new_subj['url'] = subject.url
64
 
                ctx['other_subjects'].append(new_subj)
65
 
 
 
45
        ctx['enrolments'] = req.user.active_enrolments
66
46
 
67
47
class Plugin(ViewPlugin, MediaPlugin):
68
48
    urls = [
70
50
    ]
71
51
 
72
52
    tabs = [
73
 
        ('subjects', 'Subjects', 'Announcements and information about the '
74
 
         'subjects you are enrolled in.', 'subjects.png', 'subjects', 5)
 
53
        ('subjects', 'Subjects',
 
54
         'View subject content and complete worksheets',
 
55
         'subjects.png', 'subjects', 5)
75
56
    ]
76
57
 
77
58
    media = 'subject-media'