Skip to content

Commit

Permalink
Merge pull request #39 from lorenmh/master
Browse files Browse the repository at this point in the history
Allow for custom login/warn templates
  • Loading branch information
jbittel committed Feb 13, 2017
2 parents 737de6e + 42d1517 commit eade605
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
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

0 comments on commit eade605

Please sign in to comment.