Skip to content

Commit

Permalink
Handle review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep committed Nov 28, 2018
1 parent 6cdea1e commit 1e1385c
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 24 deletions.
7 changes: 7 additions & 0 deletions allauth_2fa/app_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from allauth.account import app_settings as allauth_settings

from django.conf import settings

TEMPLATE_EXTENSION = getattr(settings,
'ALLAUTH_2FA_TEMPLATE_EXTENSION',
allauth_settings.TEMPLATE_EXTENSION)
4 changes: 0 additions & 4 deletions allauth_2fa/settings.py

This file was deleted.

12 changes: 6 additions & 6 deletions allauth_2fa/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from base64 import b32encode

try:
from urllib.parse import quote, urlencode
except ImportError:
Expand All @@ -24,14 +23,15 @@
import qrcode
from qrcode.image.svg import SvgPathImage

from allauth_2fa import app_settings
from allauth_2fa.adapter import OTPAdapter
from allauth_2fa.forms import (TOTPAuthenticateForm,
TOTPDeviceForm,
TOTPDeviceRemoveForm)
from allauth_2fa import settings


class TwoFactorAuthenticate(FormView):
template_name = 'allauth_2fa/authenticate.' + settings.TEMPLATE_EXTENSION
template_name = 'allauth_2fa/authenticate.' + app_settings.TEMPLATE_EXTENSION
form_class = TOTPAuthenticateForm

def dispatch(self, request, *args, **kwargs):
Expand Down Expand Up @@ -87,7 +87,7 @@ def form_valid(self, form):


class TwoFactorSetup(FormView):
template_name = 'allauth_2fa/setup.' + settings.TEMPLATE_EXTENSION
template_name = 'allauth_2fa/setup.' + app_settings.TEMPLATE_EXTENSION
form_class = TOTPDeviceForm
success_url = reverse_lazy('two-factor-backup-tokens')

Expand Down Expand Up @@ -136,7 +136,7 @@ def form_invalid(self, form):


class TwoFactorRemove(FormView):
template_name = 'allauth_2fa/remove.' + settings.TEMPLATE_EXTENSION
template_name = 'allauth_2fa/remove.' + app_settings.TEMPLATE_EXTENSION
form_class = TOTPDeviceRemoveForm
success_url = reverse_lazy('two-factor-setup')

Expand All @@ -162,7 +162,7 @@ def get_form_kwargs(self):


class TwoFactorBackupTokens(TemplateView):
template_name = 'allauth_2fa/backup_tokens.' + settings.TEMPLATE_EXTENSION
template_name = 'allauth_2fa/backup_tokens.' + app_settings.TEMPLATE_EXTENSION

def dispatch(self, request, *args, **kwargs):
# TODO Once Django 1.9 is the minimum supported version, see if we can
Expand Down
13 changes: 13 additions & 0 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Configuration
=============

``ALLAUTH_2FA_TEMPLATE_EXTENSION``
----------------------------------

ALlows you to override the extension for the templates used by the internal
views of django-allauth-2fa.

Defaults to ``ACCOUNT_TEMPLATE_EXTENSION`` from allauth, which is ``html`` by
default.

This can be used to allow a different template engine for 2FA views.
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
:caption: Contents:

installation
configuration
advanced
settings
changelog


Expand Down
13 changes: 0 additions & 13 deletions docs/settings.rst

This file was deleted.

0 comments on commit 1e1385c

Please sign in to comment.