diff --git a/rattail_demo/web/templates/mobile/base.mako b/rattail_demo/web/templates/mobile/base.mako new file mode 100644 index 0000000..3341118 --- /dev/null +++ b/rattail_demo/web/templates/mobile/base.mako @@ -0,0 +1,4 @@ +## -*- coding: utf-8 -*- +<%inherit file="tailbone:templates/mobile/base_external_toolbars.mako" /> + +${parent.body()} diff --git a/rattail_demo/web/templates/mobile/login.mako b/rattail_demo/web/templates/mobile/login.mako new file mode 100644 index 0000000..1848389 --- /dev/null +++ b/rattail_demo/web/templates/mobile/login.mako @@ -0,0 +1,6 @@ +## -*- coding: utf-8 -*- +<%inherit file="tailbone:templates/mobile/login.mako" /> + +

Login with chuck / admin for full demo access.

+ +${parent.body()} diff --git a/rattail_demo/web/views/auth.py b/rattail_demo/web/views/auth.py index 53e031a..38c522a 100644 --- a/rattail_demo/web/views/auth.py +++ b/rattail_demo/web/views/auth.py @@ -5,32 +5,20 @@ Auth views from __future__ import unicode_literals, absolute_import -from pyramid import httpexceptions - from tailbone.views import auth as base -def change_password(request): - # prevent password change for 'chuck' - if request.user and request.user.username == 'chuck': - request.session.flash("Cannot change password for 'chuck' in Rattail Demo") - return httpexceptions.HTTPFound(location=request.get_referrer()) - return base.change_password(request) +class AuthenticationView(base.AuthenticationView): + """ + Prevent password change for 'chuck' user + """ + + 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): - # TODO: this is way too much duplication, surely.. - 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') + AuthenticationView.defaults(config)