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

« back to all changes in this revision

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

  • Committer: me at id
  • Date: 2009-01-15 06:11:02 UTC
  • mto: This revision was merged to the branch mainline in revision 1090.
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:branches%2Fstorm:1163
www/app/{subjects,tutorial}: Use the new Storm API to get enrolled subjects.

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