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
22
# Terms of Service app
24
# (Mostly this is here for the "Help" section)
31
"""Handler for the TOS application."""
33
# Set request attributes
34
req.content_type = "text/html"
35
req.write_html_head_foot = True
38
req.write("""<div id="ivle_padding">
39
<p>When you first logged into IVLE, you agreed to the following Terms of
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
20
"""View to display the Terms of Service.
22
This is mainly for the benefit of the link in ivle.webapp.help."""
25
import ivle.webapp.security
26
from ivle.webapp.base.xhtml import XHTMLView
27
from ivle.webapp.base.plugins import ViewPlugin, MediaPlugin
29
class TermsOfServiceView(XHTMLView):
30
"""View of the Terms of Service, allowing acceptance.
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.
36
allow_overlays = False
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.
43
self.user = ivle.webapp.security.get_user_details(req)
45
self.template = 'accept.html'
49
self.template = 'view.html'
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
56
def populate(self, req, ctx):
57
ctx['text'] = ivle.util.get_terms_of_service()
59
if self.mode == 'accept':
60
self.plugin_scripts[Plugin] = ['tos.js']
61
ctx['user'] = self.user
63
class Plugin(ViewPlugin, MediaPlugin):
64
"""Registration for the Terms of Service plugin."""
66
('+tos', TermsOfServiceView),