1099.1.108
by William Grant
Port the tos app to the new framework, and fix ivle.webapp.help's reference |
1 |
# IVLE - Informatics Virtual Learning Environment
|
2 |
# Copyright (C) 2007-2009 The University of Melbourne
|
|
458
by mattgiuca
Added "tos" as an app. This app simply displays the Terms of Service |
3 |
#
|
4 |
# This program is free software; you can redistribute it and/or modify
|
|
5 |
# it under the terms of the GNU General Public License as published by
|
|
6 |
# the Free Software Foundation; either version 2 of the License, or
|
|
7 |
# (at your option) any later version.
|
|
8 |
#
|
|
9 |
# This program is distributed in the hope that it will be useful,
|
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
# GNU General Public License for more details.
|
|
13 |
#
|
|
14 |
# You should have received a copy of the GNU General Public License
|
|
15 |
# along with this program; if not, write to the Free Software
|
|
16 |
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
17 |
||
1099.1.108
by William Grant
Port the tos app to the new framework, and fix ivle.webapp.help's reference |
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 |
|
1099.1.161
by William Grant
Move ivle.dispatch.login.get_user_details() to ivle.webapp.security. |
25 |
import ivle.webapp.security |
1099.1.108
by William Grant
Port the tos app to the new framework, and fix ivle.webapp.help's reference |
26 |
from ivle.webapp.base.xhtml import XHTMLView |
1092.1.28
by William Grant
Only load tos.js on /+tos. |
27 |
from ivle.webapp.base.plugins import ViewPlugin, MediaPlugin |
1099.1.108
by William Grant
Port the tos app to the new framework, and fix ivle.webapp.help's reference |
28 |
|
29 |
class TermsOfServiceView(XHTMLView): |
|
1099.1.127
by William Grant
Implement ToS acceptance in the new login machinery. Now implemented through |
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 |
||
1099.1.129
by William Grant
Allow XHTML views to specify that they cannot have overlays. |
36 |
allow_overlays = False |
37 |
||
1099.1.127
by William Grant
Implement ToS acceptance in the new login machinery. Now implemented through |
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: |
|
1099.1.172
by William Grant
Fix a bad reference to ivle.webapp.security.get_user_details in ToS. |
43 |
self.user = ivle.webapp.security.get_user_details(req) |
1099.1.127
by William Grant
Implement ToS acceptance in the new login machinery. Now implemented through |
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 |
||
1099.1.110
by William Grant
Implement an authorization system in the new framework. This breaks the REST |
51 |
def authorize(self, req): |
1099.1.127
by William Grant
Implement ToS acceptance in the new login machinery. Now implemented through |
52 |
# This can be used by any authenticated user, even if they haven't
|
53 |
# accepted the ToS yet.
|
|
1099.1.161
by William Grant
Move ivle.dispatch.login.get_user_details() to ivle.webapp.security. |
54 |
return ivle.webapp.security.get_user_details(req) is not None |
1099.1.110
by William Grant
Implement an authorization system in the new framework. This breaks the REST |
55 |
|
1099.1.108
by William Grant
Port the tos app to the new framework, and fix ivle.webapp.help's reference |
56 |
def populate(self, req, ctx): |
57 |
ctx['text'] = ivle.util.get_terms_of_service() |
|
58 |
||
1099.1.127
by William Grant
Implement ToS acceptance in the new login machinery. Now implemented through |
59 |
if self.mode == 'accept': |
1092.1.28
by William Grant
Only load tos.js on /+tos. |
60 |
self.plugin_scripts[Plugin] = ['tos.js'] |
1099.1.127
by William Grant
Implement ToS acceptance in the new login machinery. Now implemented through |
61 |
ctx['user'] = self.user |
62 |
||
1092.1.28
by William Grant
Only load tos.js on /+tos. |
63 |
class Plugin(ViewPlugin, MediaPlugin): |
1099.1.108
by William Grant
Port the tos app to the new framework, and fix ivle.webapp.help's reference |
64 |
"""Registration for the Terms of Service plugin."""
|
65 |
urls = [ |
|
66 |
('+tos', TermsOfServiceView), |
|
67 |
]
|
|
1092.1.28
by William Grant
Only load tos.js on /+tos. |
68 |
|
69 |
media = 'media' |