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

« back to all changes in this revision

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

  • Committer: Matt Giuca
  • Date: 2009-05-19 02:54:08 UTC
  • mfrom: (1258 trunk)
  • mto: This revision was merged to the branch mainline in revision 1322.
  • Revision ID: matt.giuca@gmail.com-20090519025408-19c7cjl7w6ot6frm
MergedĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
This is mainly for the benefit of the link in ivle.webapp.help."""
23
23
 
24
 
import ivle.util
 
24
import os.path
 
25
 
25
26
import ivle.webapp.security
26
27
from ivle.webapp.base.xhtml import XHTMLView
27
28
from ivle.webapp.base.plugins import ViewPlugin, MediaPlugin
28
29
 
 
30
def get_terms_of_service(config):
 
31
    """
 
32
    Sends the Terms of Service document to the req object.
 
33
    This consults conf to find out where the TOS is located on disk, and sends
 
34
    that. If it isn't found, it sends a generic message explaining to admins
 
35
    how to create a real one.
 
36
    """
 
37
    try:
 
38
        return open(os.path.join(config['paths']['data'],
 
39
                    'notices/tos.html')).read()
 
40
    except IOError:
 
41
        return """\
 
42
<p><b>*** SAMPLE ONLY ***</b></p>
 
43
<p>This is the text of the IVLE Terms of Service.</p>
 
44
<p>The administrator should create a license file with an appropriate
 
45
"Terms of Service" license for your organisation.</p>
 
46
<h2>Instructions for Administrators</h2>
 
47
<p>You are seeing this message because you have not configured a Terms of
 
48
Service document.</p>
 
49
<p>When you configured IVLE, you specified a path to the Terms of Service
 
50
document (this is found in <b><tt>ivle/conf/conf.py</tt></b> under
 
51
"<tt>tos_path</tt>").</p>
 
52
<p>Create a file at this location; an HTML file with the appropriately-worded
 
53
license.</p>
 
54
<p>This should be a normal XHTML file, except it should not contain
 
55
<tt>html</tt>, <tt>head</tt> or <tt>body</tt> elements - it should
 
56
just be the contents of a body element (IVLE will wrap it accordingly).</p>
 
57
<p>This will automatically be used as the license text instead of this
 
58
placeholder text.</p>
 
59
"""
 
60
 
29
61
class TermsOfServiceView(XHTMLView):
30
62
    """View of the Terms of Service, allowing acceptance.
31
63
 
54
86
        return ivle.webapp.security.get_user_details(req) is not None
55
87
 
56
88
    def populate(self, req, ctx):
57
 
        ctx['text'] = ivle.util.get_terms_of_service()
 
89
        ctx['text'] = get_terms_of_service(req.config)
58
90
 
59
91
        if self.mode == 'accept':
60
92
            self.plugin_scripts[Plugin] = ['tos.js']