Add initial support for mobile login / user menu etc.

This commit is contained in:
Lance Edgar 2016-12-11 18:08:39 -06:00
parent 9d9bc58a99
commit b5c81244ac
3 changed files with 21 additions and 23 deletions

View file

@ -0,0 +1,4 @@
## -*- coding: utf-8 -*-
<%inherit file="tailbone:templates/mobile/base_external_toolbars.mako" />
${parent.body()}

View file

@ -0,0 +1,6 @@
## -*- coding: utf-8 -*-
<%inherit file="tailbone:templates/mobile/login.mako" />
<p>Login with <strong>chuck / admin</strong> for full demo access.</p>
${parent.body()}

View file

@ -5,32 +5,20 @@ Auth views
from __future__ import unicode_literals, absolute_import from __future__ import unicode_literals, absolute_import
from pyramid import httpexceptions
from tailbone.views import auth as base from tailbone.views import auth as base
def change_password(request): class AuthenticationView(base.AuthenticationView):
# prevent password change for 'chuck' """
if request.user and request.user.username == 'chuck': Prevent password change for 'chuck' user
request.session.flash("Cannot change password for 'chuck' in Rattail Demo") """
return httpexceptions.HTTPFound(location=request.get_referrer())
return base.change_password(request) def change_password(self):
if self.request.user and self.request.user.username == 'chuck':
self.request.session.flash("Cannot change password for 'chuck' in Rattail Demo")
return self.redirect(self.request.get_referrer())
return super(AuthenticationView, self).change_password()
def includeme(config): def includeme(config):
# TODO: this is way too much duplication, surely.. AuthenticationView.defaults(config)
base.add_routes(config)
config.add_forbidden_view(base.forbidden)
config.add_view(base.login, route_name='login',
renderer='/login.mako')
config.add_view(base.logout, route_name='logout')
config.add_view(base.become_root, route_name='become_root')
config.add_view(base.stop_root, route_name='stop_root')
config.add_view(change_password, route_name='change_password',
renderer='/change_password.mako')