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

« back to all changes in this revision

Viewing changes to www/apps/subjects/__init__.py

  • Committer: William Grant
  • Date: 2009-01-22 04:47:42 UTC
  • mfrom: (1080.1.93 storm)
  • Revision ID: grantw@unimelb.edu.au-20090122044742-sa8gnww0ma2bm2rv
Merge Storm branch. ivle.db is dead. Watch out for the schema change.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
import urllib
27
27
import cgi
28
28
 
 
29
import ivle.database
29
30
from ivle import util
30
 
import ivle.db
31
31
 
32
32
def handle(req):
33
33
    """Handler for the Subjects application. Links to subject home pages."""
44
44
    if req.uri[-1] != '/':
45
45
        req.throw_redirect(req.uri + '/')
46
46
 
47
 
    (enrolled_subjects, unenrolled_subjects) = \
48
 
              ivle.db.DB().get_subjects_status(req.user.login)
 
47
    enrolled_subjects = req.user.subjects
 
48
    unenrolled_subjects = [subject for subject in
 
49
                           req.store.find(ivle.database.Subject)
 
50
                           if subject not in enrolled_subjects]
49
51
 
50
52
    def print_subject(subject):
51
 
        if subject['url'] is None:
 
53
        if subject.url is None:
52
54
            req.write('  <li>%s (no home page)</li>\n'
53
 
                % cgi.escape(subject['subj_name']))
 
55
                % cgi.escape(subject.name))
54
56
        else:
55
57
            req.write('  <li><a href="%s">%s</a></li>\n'
56
 
                % (cgi.escape(subject['url']),
57
 
                   cgi.escape(subject['subj_name'])))
 
58
                % (cgi.escape(subject.url),
 
59
                   cgi.escape(subject.name)))
58
60
 
59
61
    req.content_type = "text/html"
60
62
    req.write_html_head_foot = True