Merge branch 'master' into e2e

# Conflicts:
#	Pipfile.lock
#	docs/installation/docker-compose.md
This commit is contained in:
Jens Langhammer
2020-06-19 09:00:46 +02:00
141 changed files with 1773 additions and 1105 deletions

View File

@ -1,5 +1,6 @@
"""passbook flows identification forms"""
from django import forms
from django.contrib.admin.widgets import FilteredSelectMultiple
from django.core.validators import validate_email
from django.utils.translation import gettext_lazy as _
from structlog import get_logger
@ -19,6 +20,9 @@ class IdentificationStageForm(forms.ModelForm):
fields = ["name", "user_fields", "template", "enrollment_flow", "recovery_flow"]
widgets = {
"name": forms.TextInput(),
"user_fields": FilteredSelectMultiple(
_("fields"), False, choices=UserFields.choices
),
}
@ -35,8 +39,16 @@ class IdentificationForm(forms.Form):
super().__init__(*args, **kwargs)
if self.stage.user_fields == [UserFields.E_MAIL]:
self.fields["uid_field"] = forms.EmailField()
self.fields["uid_field"].label = human_list(
[x.title() for x in self.stage.user_fields]
label = human_list([x.title() for x in self.stage.user_fields])
self.fields["uid_field"].label = label
self.fields["uid_field"].widget.attrs.update(
{
"placeholder": _(label),
"autofocus": "autofocus",
# Autocomplete according to
# https://www.chromium.org/developers/design-documents/form-styles-that-chromium-understands
"autocomplete": "username",
}
)
def clean_uid_field(self):

View File

@ -0,0 +1,28 @@
# Generated by Django 3.0.7 on 2020-06-15 16:41
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("passbook_flows", "0005_provider_flows"),
("passbook_stages_identification", "0002_auto_20200530_2204"),
]
operations = [
migrations.AlterField(
model_name="identificationstage",
name="recovery_flow",
field=models.ForeignKey(
blank=True,
default=None,
help_text="Optional recovery flow, which is linked at the bottom of the page.",
null=True,
on_delete=django.db.models.deletion.SET_DEFAULT,
related_name="+",
to="passbook_flows.Flow",
),
),
]

View File

@ -48,7 +48,7 @@ class IdentificationStage(Stage):
related_name="+",
default=None,
help_text=_(
"Optional enrollment flow, which is linked at the bottom of the page."
"Optional recovery flow, which is linked at the bottom of the page."
),
)

View File

@ -61,7 +61,7 @@ class TestIdentificationStage(TestCase):
)
def test_invalid_with_username(self):
"""Test invalid with username (user exists but stage only allows e-mail)"""
"""Test invalid with username (user exists but stage only allows email)"""
form_data = {"uid_field": self.user.username}
response = self.client.post(
reverse(
@ -72,7 +72,7 @@ class TestIdentificationStage(TestCase):
self.assertEqual(response.status_code, 200)
def test_invalid_with_invalid_email(self):
"""Test with invalid e-mail (user doesn't exist) -> Will return to login form"""
"""Test with invalid email (user doesn't exist) -> Will return to login form"""
form_data = {"uid_field": self.user.email + "test"}
response = self.client.post(
reverse(