From bdd18631776e9d5ec5830dd7e286b1ce94474e68 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 16 Feb 2020 12:30:26 +0100 Subject: [PATCH] providers/saml: move field labels from Form into models --- passbook/providers/saml/forms.py | 7 ------- passbook/providers/saml/models.py | 18 +++++++++++++----- passbook/providers/saml/views.py | 2 +- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/passbook/providers/saml/forms.py b/passbook/providers/saml/forms.py index 67845fce1..778a0e273 100644 --- a/passbook/providers/saml/forms.py +++ b/passbook/providers/saml/forms.py @@ -44,10 +44,6 @@ class SAMLProviderForm(forms.ModelForm): "signing_cert", "signing_key", ] - labels = { - "acs_url": "ACS URL", - "signing_cert": "Singing Certificate", - } widgets = { "name": forms.TextInput(), "audience": forms.TextInput(), @@ -72,6 +68,3 @@ class SAMLPropertyMappingForm(forms.ModelForm): "friendly_name": forms.TextInput(), } field_classes = {"values": DynamicArrayField} - help_texts = { - "values": 'String substitution uses a syntax like "{variable} test}".' - } diff --git a/passbook/providers/saml/models.py b/passbook/providers/saml/models.py index 8dfd84e39..7ccc4d2fa 100644 --- a/passbook/providers/saml/models.py +++ b/passbook/providers/saml/models.py @@ -2,7 +2,7 @@ from django.contrib.postgres.fields import ArrayField from django.db import models from django.shortcuts import reverse -from django.utils.translation import gettext as _ +from django.utils.translation import ugettext_lazy as _ from structlog import get_logger from passbook.core.models import PropertyMapping, Provider @@ -19,7 +19,7 @@ class SAMLProvider(Provider): name = models.TextField() processor_path = models.CharField(max_length=255, choices=[]) - acs_url = models.URLField() + acs_url = models.URLField(verbose_name=_("ACS URL")) audience = models.TextField(default="") issuer = models.TextField() @@ -56,7 +56,7 @@ class SAMLProvider(Provider): ) signing = models.BooleanField(default=True) - signing_cert = models.TextField() + signing_cert = models.TextField(verbose_name=_("Singing Certificate")) signing_key = models.TextField() form = "passbook.providers.saml.forms.SAMLProviderForm" @@ -100,9 +100,17 @@ class SAMLProvider(Provider): class SAMLPropertyMapping(PropertyMapping): """SAML Property mapping, allowing Name/FriendlyName mapping to a list of strings""" - saml_name = models.TextField() + saml_name = models.TextField(verbose_name="SAML Name") friendly_name = models.TextField(default=None, blank=True, null=True) - values = ArrayField(models.TextField()) + values = ArrayField( + models.TextField(), + help_text=_( + ( + "This string can contain string substitutions delimited by {}." + " The following Variables are available: user, request" + ) + ), + ) form = "passbook.providers.saml.forms.SAMLPropertyMappingForm" diff --git a/passbook/providers/saml/views.py b/passbook/providers/saml/views.py index fe52516bc..ce5b4b00b 100644 --- a/passbook/providers/saml/views.py +++ b/passbook/providers/saml/views.py @@ -5,7 +5,7 @@ from django.contrib.auth import logout from django.contrib.auth.mixins import AccessMixin from django.core.exceptions import ValidationError from django.core.validators import URLValidator -from django.http import HttpResponse, HttpResponseBadRequest, HttpRequest +from django.http import HttpRequest, HttpResponse, HttpResponseBadRequest from django.shortcuts import get_object_or_404, redirect, render, reverse from django.utils.datastructures import MultiValueDictKeyError from django.utils.decorators import method_decorator