22
22
This is mainly for the benefit of the link in ivle.webapp.help."""
25
import ivle.dispatch.login
25
26
from ivle.webapp.base.xhtml import XHTMLView
26
27
from ivle.webapp.base.plugins import ViewPlugin
28
29
class TermsOfServiceView(XHTMLView):
29
"""Static view of the Terms of Service."""
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
def __init__(self, req):
37
# We need to be able to handle the case where a user has status
38
# 'no_agreement'. In that case, req.user will be None, so we have
39
# to get it ourselves.
41
self.user = ivle.dispatch.login.get_user_details(req)
43
self.template = 'accept.html'
47
self.template = 'view.html'
30
49
def authorize(self, req):
31
return req.user is not None
50
# This can be used by any authenticated user, even if they haven't
51
# accepted the ToS yet.
52
return ivle.dispatch.login.get_user_details(req) is not None
33
54
def populate(self, req, ctx):
34
55
ctx['text'] = ivle.util.get_terms_of_service()
57
if self.mode == 'accept':
58
ctx['user'] = self.user
36
60
class Plugin(ViewPlugin):
37
61
"""Registration for the Terms of Service plugin."""