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

« back to all changes in this revision

Viewing changes to ivle/webapp/tos/__init__.py

  • Committer: William Grant
  • Date: 2009-02-23 23:47:02 UTC
  • mfrom: (1099.1.211 new-dispatch)
  • Revision ID: grantw@unimelb.edu.au-20090223234702-db4b1llly46ignwo
Merge from lp:~ivle-dev/ivle/new-dispatch.

Pretty much everything changes. Reread the setup docs. Backup your databases.
Every file is now in a different installed location, the configuration system
is rewritten, the dispatch system is rewritten, URLs are different, the
database is different, worksheets and exercises are no longer on the
filesystem, we use a templating engine, jail service protocols are rewritten,
we don't repeat ourselves, we have authorization rewritten, phpBB is gone,
and probably lots of other things that I cannot remember.

This is certainly the biggest commit I have ever made, and hopefully
the largest I ever will.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# IVLE
2
 
# Copyright (C) 2007-2008 The University of Melbourne
 
1
# IVLE - Informatics Virtual Learning Environment
 
2
# Copyright (C) 2007-2009 The University of Melbourne
3
3
#
4
4
# This program is free software; you can redistribute it and/or modify
5
5
# it under the terms of the GNU General Public License as published by
15
15
# along with this program; if not, write to the Free Software
16
16
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17
17
 
18
 
# App: tos
19
 
# Author: Matt Giuca
20
 
# Date: 14/2/2008
21
 
 
22
 
# Terms of Service app
23
 
# Displays the TOS
24
 
# (Mostly this is here for the "Help" section)
25
 
 
26
 
import os
27
 
 
28
 
from ivle import util
29
 
 
30
 
def handle(req):
31
 
    """Handler for the TOS application."""
32
 
 
33
 
    # Set request attributes
34
 
    req.content_type = "text/html"
35
 
    req.write_html_head_foot = True
36
 
 
37
 
    # Start writing data
38
 
    req.write("""<div id="ivle_padding">
39
 
<p>When you first logged into IVLE, you agreed to the following Terms of
40
 
Service:</p>
41
 
<hr />
42
 
""")
43
 
 
44
 
    # Print out the contents of the license file
45
 
    util.send_terms_of_service(req)
46
 
    req.write('<hr />\n</div>\n')
 
18
# Author: Matt Giuca, Will Grant
 
19
 
 
20
"""View to display the Terms of Service.
 
21
 
 
22
This is mainly for the benefit of the link in ivle.webapp.help."""
 
23
 
 
24
import ivle.util
 
25
import ivle.webapp.security
 
26
from ivle.webapp.base.xhtml import XHTMLView
 
27
from ivle.webapp.base.plugins import ViewPlugin, MediaPlugin
 
28
 
 
29
class TermsOfServiceView(XHTMLView):
 
30
    """View of the Terms of Service, allowing acceptance.
 
31
 
 
32
    Users with state 'no_agreement' see buttons to accept or decline.
 
33
    If a user has already accepted it, they just see a static page.
 
34
    """
 
35
 
 
36
    allow_overlays = False
 
37
 
 
38
    def __init__(self, req):
 
39
        # We need to be able to handle the case where a user has status
 
40
        # 'no_agreement'. In that case, req.user will be None, so we have
 
41
        # to get it ourselves.
 
42
        if req.user is None:
 
43
            self.user = ivle.webapp.security.get_user_details(req)
 
44
            self.mode = 'accept'
 
45
            self.template = 'accept.html'
 
46
        else:
 
47
            self.user = req.user
 
48
            self.mode = 'view'
 
49
            self.template = 'view.html'
 
50
 
 
51
    def authorize(self, req):
 
52
        # This can be used by any authenticated user, even if they haven't
 
53
        # accepted the ToS yet.
 
54
        return ivle.webapp.security.get_user_details(req) is not None
 
55
 
 
56
    def populate(self, req, ctx):
 
57
        ctx['text'] = ivle.util.get_terms_of_service()
 
58
 
 
59
        if self.mode == 'accept':
 
60
            self.plugin_scripts[Plugin] = ['tos.js']
 
61
            ctx['user'] = self.user
 
62
 
 
63
class Plugin(ViewPlugin, MediaPlugin):
 
64
    """Registration for the Terms of Service plugin."""
 
65
    urls = [
 
66
        ('+tos', TermsOfServiceView),
 
67
    ]
 
68
 
 
69
    media = 'media'