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

« back to all changes in this revision

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

  • Committer: matt.giuca
  • Date: 2009-02-25 01:15:49 UTC
  • Revision ID: svn-v4:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:1206
tutorial/__init__.py: Fixed path to exercises template
    (prefixed "templates/").

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
        return req.user is not None
43
43
 
44
44
    def populate(self, req, ctx):
45
 
        ctx['enrolments'] = req.user.active_enrolments
 
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
 
46
66
 
47
67
class Plugin(ViewPlugin, MediaPlugin):
48
68
    urls = [