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

« back to all changes in this revision

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

Replaced Python config files (conf.py) with new config files system, using
    configobj (INI-file style config files).

setup.py config now produces ./etc/ivle.conf, a new-style config file.
ivle/conf/conf.py is now part of the IVLE source code. It reads the new config
file and provides the same legacy interface, so all of IVLE still functions,
including setup.py config.

Added /etc to the source tree (config files will be stored here).
Added configobj as a dependency in doc/setup/install_proc.txt.

setup.py install copies ./etc/ivle.conf into /etc/ivle/ivle.conf.

Removed boilerplate code generation from setup/configure.py (that code is now
part of ivle/conf/conf.py which is now in the source tree).

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 ViewPlugin, MediaPlugin
 
30
from ivle.webapp.base.plugins import ViewPlugin
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
 
 
44
41
    def populate(self, req, ctx):
45
 
        ctx['enrolments'] = req.user.active_enrolments
46
 
 
47
 
class Plugin(ViewPlugin, MediaPlugin):
 
42
        enrolled_subjects = req.user.subjects
 
43
        unenrolled_subjects = [subject for subject in
 
44
                               req.store.find(Subject)
 
45
                               if subject not in enrolled_subjects]
 
46
 
 
47
        ctx['enrolled_subjects'] = []
 
48
        ctx['other_subjects'] = []
 
49
 
 
50
        req.content_type = "text/html"
 
51
        req.write_html_head_foot = True
 
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
 
 
66
 
 
67
class Plugin(ViewPlugin):
48
68
    urls = [
49
69
        ('subjects/', SubjectsView),
50
70
    ]
51
 
 
52
 
    tabs = [
53
 
        ('subjects', 'Subjects', 'Announcements and information about the '
54
 
         'subjects you are enrolled in.', 'subjects.png', 'subjects', 5)
55
 
    ]
56
 
 
57
 
    media = 'subject-media'