From dc9f8fccb7bc92704f1231bce92f85aabf2434f3 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 19 Mar 2022 08:48:10 -0700 Subject: [PATCH] Adds widgets file --- bookwyrm/forms/widgets.py | 70 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 bookwyrm/forms/widgets.py diff --git a/bookwyrm/forms/widgets.py b/bookwyrm/forms/widgets.py new file mode 100644 index 000000000..ee9345aa0 --- /dev/null +++ b/bookwyrm/forms/widgets.py @@ -0,0 +1,70 @@ +""" using django model forms """ +from django import forms + + +class ArrayWidget(forms.widgets.TextInput): + """Inputs for postgres array fields""" + + # pylint: disable=unused-argument + # pylint: disable=no-self-use + def value_from_datadict(self, data, files, name): + """get all values for this name""" + return [i for i in data.getlist(name) if i] + + +class Select(forms.Select): + """custom template for select widget""" + + template_name = "widgets/select.html" + + +class SelectDateWidget(forms.SelectDateWidget): + """ + A widget that splits date input into two