From 81b66ecdcd4ad9c6bb2961a3a22cb33fbfcc125c Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 27 Feb 2020 16:39:30 +0100 Subject: [PATCH] core: remove some more dead code, add more help texts for factors --- passbook/core/templates/base/skeleton.html | 2 +- .../email/account_password_reset.html | 1 - passbook/core/templates/email/base.html | 4 +-- passbook/core/templates/login/loading.html | 2 +- passbook/factors/captcha/forms.py | 7 +++- passbook/factors/email/forms.py | 7 +++- passbook/factors/otp/forms.py | 7 +++- passbook/factors/password/forms.py | 7 +++- passbook/lib/default.yml | 23 ------------- passbook/lib/templatetags/utils.py | 34 ------------------- .../templates/oauth2_provider/authorize.html | 2 +- .../sources/saml/templates/saml/sp/login.html | 2 +- 12 files changed, 30 insertions(+), 68 deletions(-) diff --git a/passbook/core/templates/base/skeleton.html b/passbook/core/templates/base/skeleton.html index 57944e7f3..d4105aec1 100644 --- a/passbook/core/templates/base/skeleton.html +++ b/passbook/core/templates/base/skeleton.html @@ -8,7 +8,7 @@ - {% block title %}{% title %}{% endblock %} + {% block title %}{% trans title %}{% endblock %} diff --git a/passbook/core/templates/email/account_password_reset.html b/passbook/core/templates/email/account_password_reset.html index c201e811e..827ab9716 100644 --- a/passbook/core/templates/email/account_password_reset.html +++ b/passbook/core/templates/email/account_password_reset.html @@ -8,7 +8,6 @@ {% endblock %} {% block content %} -{% config 'passbook.branding' as branding %} diff --git a/passbook/core/templates/email/base.html b/passbook/core/templates/email/base.html index d2038808c..86b82f8ae 100644 --- a/passbook/core/templates/email/base.html +++ b/passbook/core/templates/email/base.html @@ -5,7 +5,7 @@ - {% config passbook.branding %} + passbook @@ -118,7 +118,7 @@ -

{% config 'passbook.branding' %}

+

passbook

diff --git a/passbook/core/templates/login/loading.html b/passbook/core/templates/login/loading.html index f9b1e548e..239370e51 100644 --- a/passbook/core/templates/login/loading.html +++ b/passbook/core/templates/login/loading.html @@ -5,7 +5,7 @@ {% load utils %} {% block title %} -{% title title %} +{% trans title %} {% endblock %} {% block head %} diff --git a/passbook/factors/captcha/forms.py b/passbook/factors/captcha/forms.py index 9084b6462..9ac94ddeb 100644 --- a/passbook/factors/captcha/forms.py +++ b/passbook/factors/captcha/forms.py @@ -2,7 +2,7 @@ from captcha.fields import ReCaptchaField from django import forms from django.contrib.admin.widgets import FilteredSelectMultiple -from django.utils.translation import gettext as _ +from django.utils.translation import gettext_lazy as _ from passbook.factors.captcha.models import CaptchaFactor from passbook.factors.forms import GENERAL_FIELDS @@ -28,3 +28,8 @@ class CaptchaFactorForm(forms.ModelForm): "public_key": forms.TextInput(), "private_key": forms.TextInput(), } + help_texts = { + "policies": _( + "Policies which determine if this factor applies to the current user." + ) + } diff --git a/passbook/factors/email/forms.py b/passbook/factors/email/forms.py index 5793ea864..862e90959 100644 --- a/passbook/factors/email/forms.py +++ b/passbook/factors/email/forms.py @@ -1,7 +1,7 @@ """passbook administration forms""" from django import forms from django.contrib.admin.widgets import FilteredSelectMultiple -from django.utils.translation import gettext as _ +from django.utils.translation import gettext_lazy as _ from passbook.factors.email.models import EmailFactor from passbook.factors.forms import GENERAL_FIELDS @@ -41,3 +41,8 @@ class EmailFactorForm(forms.ModelForm): "ssl_keyfile": _("SSL Keyfile (optional)"), "ssl_certfile": _("SSL Certfile (optional)"), } + help_texts = { + "policies": _( + "Policies which determine if this factor applies to the current user." + ) + } diff --git a/passbook/factors/otp/forms.py b/passbook/factors/otp/forms.py index 4b665b991..b71198a80 100644 --- a/passbook/factors/otp/forms.py +++ b/passbook/factors/otp/forms.py @@ -4,7 +4,7 @@ from django import forms from django.contrib.admin.widgets import FilteredSelectMultiple from django.core.validators import RegexValidator from django.utils.safestring import mark_safe -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django_otp.models import Device from passbook.factors.forms import GENERAL_FIELDS @@ -80,3 +80,8 @@ class OTPFactorForm(forms.ModelForm): "order": forms.NumberInput(), "policies": FilteredSelectMultiple(_("policies"), False), } + help_texts = { + "policies": _( + "Policies which determine if this factor applies to the current user." + ) + } diff --git a/passbook/factors/password/forms.py b/passbook/factors/password/forms.py index d9def8778..1594ab876 100644 --- a/passbook/factors/password/forms.py +++ b/passbook/factors/password/forms.py @@ -2,7 +2,7 @@ from django import forms from django.conf import settings from django.contrib.admin.widgets import FilteredSelectMultiple -from django.utils.translation import gettext as _ +from django.utils.translation import gettext_lazy as _ from passbook.factors.forms import GENERAL_FIELDS from passbook.factors.password.models import PasswordFactor @@ -49,3 +49,8 @@ class PasswordFactorForm(forms.ModelForm): "password_policies": FilteredSelectMultiple(_("password policies"), False), "reset_factors": FilteredSelectMultiple(_("reset factors"), False), } + help_texts = { + "policies": _( + "Policies which determine if this factor applies to the current user." + ) + } diff --git a/passbook/lib/default.yml b/passbook/lib/default.yml index 35ce3aa63..591a17109 100644 --- a/passbook/lib/default.yml +++ b/passbook/lib/default.yml @@ -25,18 +25,6 @@ passbook: password_reset: # Enable password reset, passwords are reset in internal Database and in LDAP if ldap.reset_password is true enabled: true - # Verification the user has to provide in order to be able to reset passwords. Can be any combination of `email`, `2fa`, `security_questions` - verification: - - email - # Text used in title, on login page and multiple other places - branding: passbook - login: - # Override URL used for logo - logo_url: null - # Override URL used for Background on Login page - bg_url: null - # Optionally add a subtext, placed below logo on the login page - subtext: null footer: links: # Optionally add links to the footer on the login page @@ -46,14 +34,3 @@ passbook: uid_fields: - username - email -# Provider-specific settings -ldap: - # Which field from `uid_fields` maps to which LDAP Attribute - login_field_map: - username: sAMAccountName - email: mail # or userPrincipalName - user_attribute_map: - active_directory: - username: "%(sAMAccountName)s" - email: "%(mail)s" - name: "%(displayName)" diff --git a/passbook/lib/templatetags/utils.py b/passbook/lib/templatetags/utils.py index 6d7d7ad3a..cebd24252 100644 --- a/passbook/lib/templatetags/utils.py +++ b/passbook/lib/templatetags/utils.py @@ -3,11 +3,9 @@ from hashlib import md5 from urllib.parse import urlencode from django import template -from django.apps import apps from django.db.models import Model from django.template import Context from django.utils.html import escape -from django.utils.translation import ugettext as _ from passbook.lib.config import CONFIG from passbook.lib.utils.urls import is_url_absolute @@ -40,38 +38,6 @@ def fieldtype(field): return field.__class__.__name__ -@register.simple_tag(takes_context=True) -def title(context: Context, *title) -> str: - """Return either just branding or title - branding""" - branding = CONFIG.y("passbook.branding", "passbook") - if not title: - return branding - if "request" not in context: - return "" - resolver_match = context.request.resolver_match - if not resolver_match: - return "" - # Include App Title in title - app = "" - if resolver_match.namespace != "": - dj_app = None - namespace = context.request.resolver_match.namespace.split(":")[0] - # New label (App URL Namespace == App Label) - dj_app = apps.get_app_config(namespace) - title_modifier = getattr(dj_app, "title_modifier", None) - if title_modifier: - app_title = dj_app.title_modifier(context.request) - app = app_title + " -" - return _( - "%(title)s - %(app)s %(branding)s" - % { - "title": " - ".join([str(x) for x in title]), - "branding": branding, - "app": app, - } - ) - - @register.simple_tag def config(path, default=""): """Get a setting from the database. Returns default is setting doesn't exist.""" diff --git a/passbook/providers/oauth/templates/oauth2_provider/authorize.html b/passbook/providers/oauth/templates/oauth2_provider/authorize.html index 0ae8e4393..f9ca84bf8 100644 --- a/passbook/providers/oauth/templates/oauth2_provider/authorize.html +++ b/passbook/providers/oauth/templates/oauth2_provider/authorize.html @@ -4,7 +4,7 @@ {% load i18n %} {% block card_title %} -{% title 'Authorize Application' %} +{% trans 'Authorize Application' %} {% endblock %} {% block card %} diff --git a/passbook/sources/saml/templates/saml/sp/login.html b/passbook/sources/saml/templates/saml/sp/login.html index dbca2d946..825bbfe4a 100644 --- a/passbook/sources/saml/templates/saml/sp/login.html +++ b/passbook/sources/saml/templates/saml/sp/login.html @@ -4,7 +4,7 @@ {% load i18n %} {% block title %} -{% title 'Authorize Application' %} +{% trans 'Authorize Application' %} {% endblock %} {% block card %}