Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for custom login/warn templates #39

Merged
merged 3 commits into from
Feb 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions docs/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,18 @@ customize behavior and improve security.

This setting has been deprecated in favor of MAMA_CAS_SERVICES.

.. attribute:: MAMA_CAS_LOGIN_TEMPLATE

:default: ``'mama_cas/login.html'``

A path to the login template to use. Make sure Django can find this template
using normal Django template discovery rules.

.. attribute:: MAMA_CAS_WARN_TEMPLATE

:default: ``'mama_cas/warn.html'``

A path to the warning template to use. Make sure Django can find this
template using normal Django template discovery rules.

.. _gevent: http://www.gevent.org/
13 changes: 11 additions & 2 deletions mama_cas/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,23 @@
logger = logging.getLogger(__name__)


login_view_template_name = getattr(settings,
'MAMA_CAS_LOGIN_TEMPLATE',
'mama_cas/login.html')

warn_view_template_name = getattr(settings,
'MAMA_CAS_WARN_TEMPLATE',
'mama_cas/warn.html')


class LoginView(CsrfProtectMixin, NeverCacheMixin, FormView):
"""
(2.1 and 2.2) Credential requestor and acceptor.

This view operates as a credential requestor when a GET request
is received, and a credential acceptor for POST requests.
"""
template_name = 'mama_cas/login.html'
template_name = login_view_template_name
form_class = LoginForm

def get(self, request, *args, **kwargs):
Expand Down Expand Up @@ -137,7 +146,7 @@ class WarnView(NeverCacheMixin, LoginRequiredMixin, TemplateView):
that service authentication is taking place. The user can choose
to continue or cancel the authentication attempt.
"""
template_name = 'mama_cas/warn.html'
template_name = warn_view_template_name

def get(self, request, *args, **kwargs):
service = request.GET.get('service')
Expand Down