From 8fe6a5b62d1f2ecbe0e8ee80f60810736866e6e1 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 9 Jul 2020 17:21:46 +0200 Subject: [PATCH] stages/prompt: fix checkbox not working, fix date and datetime not using HTML5 input types --- e2e/test_sources_oauth.py | 2 +- passbook/stages/prompt/models.py | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/e2e/test_sources_oauth.py b/e2e/test_sources_oauth.py index 5fa7faee4..40b8e8022 100644 --- a/e2e/test_sources_oauth.py +++ b/e2e/test_sources_oauth.py @@ -2,11 +2,11 @@ from os.path import abspath from time import sleep +from oauth2_provider.generators import generate_client_id, generate_client_secret from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support import expected_conditions as ec from yaml import safe_dump, safe_load -from oauth2_provider.generators import generate_client_id, generate_client_secret from docker import DockerClient, from_env from docker.models.containers import Container diff --git a/passbook/stages/prompt/models.py b/passbook/stages/prompt/models.py index a7374e4d6..9c44c0ed5 100644 --- a/passbook/stages/prompt/models.py +++ b/passbook/stages/prompt/models.py @@ -21,7 +21,7 @@ class FieldTypes(models.TextChoices): _( ( "Username: Same as Text input, but checks for " - "duplicate and prevents duplicate usernames." + "and prevents duplicate usernames." ) ), ) @@ -77,12 +77,14 @@ class Prompt(models.Model): kwargs["required"] = False kwargs["initial"] = self.placeholder if self.type == FieldTypes.CHECKBOX: - field_class = forms.CheckboxInput + field_class = forms.BooleanField kwargs["required"] = False if self.type == FieldTypes.DATE: - field_class = forms.DateInput + attrs["type"] = "date" + widget = forms.DateInput(attrs=attrs) if self.type == FieldTypes.DATE_TIME: - field_class = forms.DateTimeInput + attrs["type"] = "datetime-local" + widget = forms.DateTimeInput(attrs=attrs) if self.type == FieldTypes.STATIC: widget = StaticTextWidget(attrs=attrs) kwargs["initial"] = self.placeholder