From 35d58c9046052961e677161780735dbcedb0febd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josip=20Deli=C4=87?= Date: Tue, 14 Nov 2023 14:23:57 +0100 Subject: [PATCH] [WIP] bootstrap5 + icons (#124) * bootstrap5 * update ci py version * update tox python version * update tox python version * use , sperator in tox passenv * use allowlist_externals * add './' in allowlist_externals * pin selenium version * fix select2 test * fix select2 test * fix select2 multiple test * fix select2 multiple test * fix select2 X test * fix selenium tests * fix linting && use new python, pypy version * fix flake8 * fix restructured text https://stackoverflow.com/a/39720161/1154966 does not work * fix unofficial-deformdemo (it never worked) * removed six; reactivated validation (do we still need it?) * make isort happy * update python version in docs, setup.py; added me to contributors * list specific python versions; update ci python setup --- .github/workflows/ci-tests.yml | 13 +- CONTRIBUTORS.txt | 1 + README.rst | 18 +-- deformdemo/__init__.py | 53 ++----- deformdemo/custom_widgets/modal.pt | 4 +- deformdemo/mini.py | 2 - deformdemo/scripts/html5check.py | 2 +- deformdemo/templates/form.pt | 24 ++-- deformdemo/templates/main.pt | 4 +- deformdemo/templates/popup_example.pt | 2 +- deformdemo/test.py | 132 +++++++++--------- deformdemo/validation.py | 29 ++-- setup.py | 18 +-- tox.ini | 13 +- unofficial-deformdemo/__init__.py | 50 +------ unofficial-deformdemo/templates/form.pt | 24 ++-- unofficial-deformdemo/templates/mini.pt | 66 --------- .../templates/popup_example.pt | 65 --------- 18 files changed, 157 insertions(+), 363 deletions(-) delete mode 100644 unofficial-deformdemo/templates/mini.pt delete mode 100644 unofficial-deformdemo/templates/popup_example.pt diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index d3fb8c93..96a76422 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -15,11 +15,12 @@ jobs: strategy: matrix: py: - - "3.6" - - "3.7" - "3.8" - "3.9" - - "pypy3" + - "3.10" + - "3.11" + - "3.12" + - "pypy-3.10" os: - "ubuntu-latest" architecture: @@ -35,7 +36,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Setup python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.py }} architecture: ${{ matrix.architecture }} @@ -57,9 +58,9 @@ jobs: steps: - uses: actions/checkout@v2 - name: Setup python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: - python-version: 3.9 + python-version: 3.11 architecture: x64 - run: | pip install tox diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 01f89002..2efffe2c 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -112,3 +112,4 @@ Contributors - Steve Piercy 2020/05/11 - John Haiducek 2020/06/20 - Maksym Shalenyi 2020/06/20 +- Josip Delić 2023/11/14 diff --git a/README.rst b/README.rst index 5ccab392..8a40d181 100644 --- a/README.rst +++ b/README.rst @@ -6,7 +6,7 @@ Deform Demo Demonstration application for the `Deform `_ Python HTML form library. -This application is tested on Python versions 3.6, 3.7, 3.8, and 3.9, and PyPy3. +This application is tested on Python versions 3.8, 3.9, 3.10, 3.11, and 3.12, and PyPy3. Online version @@ -108,8 +108,8 @@ It performs editable installs of Colander and Deform into your virtual environme Install Firefox latest ^^^^^^^^^^^^^^^^^^^^^^ -macOS -""""" +macOS Firefox +""""""""""""" `Download the latest version of Firefox for your platform `_. @@ -119,8 +119,8 @@ Open the ``.dmg`` (macOS), and drag the Firefox icon to: ~/projects/deformdemo/ -Linux (Debian) -"""""""""""""" +Linux (Debian) Firefox +"""""""""""""""""""""" Use cURL or wget. See the `Firefox download README.txt `_ for instructions. @@ -161,8 +161,8 @@ gettext The functional tests require the installation of the GNU ``gettext`` utilities, specifically ``msgmerge`` and ``msgfmt``. Use your package manager to install these requirements. -macOS -""""" +macOS gettext +""""""""""""" Use `Homebrew `_. @@ -177,8 +177,8 @@ If you ever have problems building packages, you can always unlink it. brew unlink gettext -Linux (Debian) -"""""""""""""" +Linux (Debian) gettext +"""""""""""""""""""""" .. code-block:: bash diff --git a/deformdemo/__init__.py b/deformdemo/__init__.py index 9dcca57a..cc46afa9 100644 --- a/deformdemo/__init__.py +++ b/deformdemo/__init__.py @@ -39,7 +39,12 @@ from io import StringIO PY3 = sys.version_info[0] == 3 -PY38MIN = sys.version_info[0] == 3 and sys.version_info[1] >= 8 +PY38MIN = ( + sys.version_info[0] == 3 + and sys.version_info[1] >= 8 + and sys.version_info[1] <= 9 +) +PY310MIN = sys.version_info[0] == 3 and sys.version_info[1] >= 10 if PY3: @@ -69,7 +74,7 @@ def __call__(self, method): # http://stackoverflow.com/a/16888673/315168 # eliminate u'' def my_safe_repr(obj, context, maxlevels, level, sort_dicts=True): - if type(obj) == unicode: + if type(obj) is unicode: obj = obj.encode("utf-8") # Python 3.8 changed the call signature of pprint._safe_repr. @@ -95,7 +100,6 @@ def render_form( readonly=False, is_i18n=False, ): - captured = None if submitted in self.request.POST: @@ -126,7 +130,8 @@ def render_form( reqts = form.get_widget_resources() printer = pprint.PrettyPrinter() - printer.format = my_safe_repr + if not PY310MIN: + printer.format = my_safe_repr output = printer.pformat(captured) captured = highlight(output, PythonLexer(), formatter) @@ -209,7 +214,7 @@ def predicate(value): L = [] for name, method in demos: url = self.request.resource_url( - self.request.root, name, route_name="deformdemo" + self.request.context, name, route_name="deformdemo" ) L.append((method.demo, url)) L.sort() @@ -259,7 +264,6 @@ class Schema(colander.Schema): @view_config(renderer="templates/form.pt", name="textinput_with_css_class") @demonstrate("Text Input Widget (with CSS class)") def textinput_with_css_class(self): - css_widget = deform.widget.TextInputWidget( css_class="deform-widget-with-style" ) @@ -294,7 +298,6 @@ class Schema(colander.Schema): @view_config(renderer="templates/form.pt", name="money_input") @demonstrate("Money Input") def money_input(self): - widget = deform.widget.MoneyInputWidget(options={"allowZero": True}) class Schema(colander.Schema): @@ -335,7 +338,6 @@ class Schema(colander.Schema): ) @demonstrate("Autocomplete Input Widget (with Remote Data Source)") def autocomplete_remote_input(self): - widget = deform.widget.AutocompleteInputWidget( min_length=1, values=self.request.route_path( @@ -419,7 +421,6 @@ class Schema(colander.Schema): @view_config(renderer="templates/form.pt", name="richtext_i18n") @demonstrate("Rich Text Widget (internationalized)") def richtext_i18n(self): - locale_name = get_locale_name(self.request) class Schema(colander.Schema): @@ -601,7 +602,6 @@ class Schema(colander.Schema): @view_config(renderer="templates/form.pt", name="radiochoice") @demonstrate("Radio Choice Widget") def radiochoice(self): - choices = ( ("habanero", "Habanero"), ("jalapeno", "Jalapeno"), @@ -625,7 +625,6 @@ class Schema(colander.Schema): @view_config(renderer="templates/form.pt", name="radiochoice_inline") @demonstrate("Radio Choice Widget (inline)") def radiochoice_inline(self): - choices = ( ("habanero", "Habanero"), ("jalapeno", "Jalapeno"), @@ -670,7 +669,6 @@ class Schema(colander.Schema): @view_config(renderer="templates/form.pt", name="radiochoice_readonly") @demonstrate("Radio Choice Widget (read-only)") def radiochoice_readonly(self): - choices = ( ("habanero", "Habanero"), ("jalapeno", "Jalapeno"), @@ -693,7 +691,6 @@ class Schema(colander.Schema): @view_config(renderer="templates/form.pt", name="checkedinput") @demonstrate("Checked Input Widget") def checkedinput(self): - widget = deform.widget.CheckedInputWidget( subject="Email", confirm_subject="Confirm Email" ) @@ -715,7 +712,6 @@ class Schema(colander.Schema): @view_config(renderer="templates/form.pt", name="checkedinput_readonly") @demonstrate("Checked Input Widget (read-only)") def checkedinput_readonly(self): - widget = deform.widget.CheckedInputWidget( subject="Email", confirm_subject="Confirm Email", readonly=True ) @@ -787,7 +783,6 @@ class Schema(colander.Schema): @view_config(renderer="templates/form.pt", name="checkedinput_withmask") @demonstrate("Checked Input Widget (with Input Mask)") def checkedinput_withmask(self): - widget = deform.widget.CheckedInputWidget( subject="SSN", confirm_subject="Confirm SSN", @@ -812,7 +807,6 @@ class Schema(colander.Schema): @demonstrate("Dynamic fields: add and remove") def dynamic_field(self): class Schema(colander.Schema): - field1 = colander.SchemaNode( colander.String(), title="Field 1", @@ -826,7 +820,6 @@ class Schema(colander.Schema): ) def after_bind(self, schema, kwargs): - # after_bind() can be used as subclass method # or a parameter passed to schema constructor. # @@ -989,7 +982,7 @@ class Schema(colander.Schema): def succeed(): location = self.request.resource_url( - self.request.root, "thanks.html", route_name="deformdemo" + self.request.context, "thanks.html", route_name="deformdemo" ) # To appease jquery 1.6+, we need to return something that smells # like HTML, or we get a "Node cannot be inserted at the @@ -1012,7 +1005,6 @@ def succeed(): @view_config(renderer="templates/form.pt", name="sequence_of_radiochoices") @demonstrate("Sequence of Radio Choice Widgets") def sequence_of_radiochoices(self): - choices = ( ("habanero", "Habanero"), ("jalapeno", "Jalapeno"), @@ -1685,7 +1677,6 @@ class Schema(colander.Schema): @view_config(renderer="templates/form.pt", name="select") @demonstrate("Select Widget") def select(self): - choices = ( ("", "- Select -"), ("habanero", "Habanero"), @@ -1707,7 +1698,6 @@ class Schema(colander.Schema): @view_config(renderer="templates/form.pt", name="select_with_size") @demonstrate("Select Widget (with size)") def select_with_size(self): - choices = ( ("", "- Select -"), ("habanero", "Habanero"), @@ -1729,7 +1719,6 @@ class Schema(colander.Schema): @view_config(renderer="templates/form.pt", name="select_with_unicode") @demonstrate("Select Widget (with unicode)") def select_with_unicode(self): - choices = ( ("", "- Select -"), (unicode("ハバネロ", "utf-8"), "Habanero"), @@ -1751,7 +1740,6 @@ class Schema(colander.Schema): @view_config(renderer="templates/form.pt", name="select_with_default") @demonstrate("Select Widget (with default)") def select_with_default(self): - choices = ( ("", "- Select -"), ("habanero", "Habanero"), @@ -1774,7 +1762,6 @@ class Schema(colander.Schema): @view_config(renderer="templates/form.pt", name="select_with_multiple") @demonstrate("Select Widget (with multiple)") def select_with_multiple(self): - choices = ( ("habanero", "Habanero"), ("jalapeno", "Jalapeno"), @@ -1800,7 +1787,6 @@ class Schema(colander.Schema): ) @demonstrate("Select Widget (with multiple default integers)") def select_with_multiple_default_integers(self): - choices = ((1, "Habanero"), (2, "Jalapeno"), (3, "Chipotle")) class Schema(colander.Schema): @@ -1851,7 +1837,6 @@ class Schema(colander.Schema): @view_config(renderer="templates/form.pt", name="select_integer") @demonstrate("Select Widget (with Integer values)") def select_integer(self): - choices = (("", "- Select -"), (0, "Zero"), (1, "One"), (2, "Two")) class Schema(colander.Schema): @@ -1901,7 +1886,6 @@ class Schema(colander.Schema): ) @demonstrate("Select Widget (with optgroup and label attributes)") def select_with_optgroup_and_label_attributes(self): - # One may or may not notice any difference with # 'select_with_optgroup' above, depending on the browser being # used. See widget's documentation for further details. @@ -1984,7 +1968,6 @@ class Schema(colander.Schema): @view_config(renderer="templates/form.pt", name="select2") @demonstrate("Select2 Widget") def select2(self): - choices = ( ("", "- Select -"), ("habanero", "Habanero"), @@ -2006,7 +1989,6 @@ class Schema(colander.Schema): @view_config(renderer="templates/form.pt", name="select2_with_multiple") @demonstrate("Select2 Widget (with multiple)") def select2_with_multiple(self): - choices = ( ("habanero", "Habanero"), ("jalapeno", "Jalapeno"), @@ -2059,7 +2041,6 @@ class Schema(colander.Schema): @view_config(renderer="templates/form.pt", name="select2_with_tags") @demonstrate("Select2 Widget (with tags)") def select2_with_tags(self): - choices = () class Schema(colander.Schema): @@ -2078,7 +2059,6 @@ class Schema(colander.Schema): ) @demonstrate("Select2 Widget (with tags and multiple)") def select2_with_tags_and_multiple(self): - choices = () class Schema(colander.Schema): @@ -2097,7 +2077,6 @@ class Schema(colander.Schema): @view_config(renderer="templates/form.pt", name="selectize") @demonstrate("Selectize Widget") def selectize(self): - choices = ( ("", "- Select -"), ("habanero", "Habanero"), @@ -2119,7 +2098,6 @@ class Schema(colander.Schema): @view_config(renderer="templates/form.pt", name="selectize_with_multiple") @demonstrate("Selectize Widget (with multiple)") def selectize_with_multiple(self): - choices = ( ("habanero", "Habanero"), ("jalapeno", "Jalapeno"), @@ -2184,7 +2162,6 @@ class Schema(colander.Schema): @view_config(renderer="templates/form.pt", name="selectize_with_tags") @demonstrate("Selectize Widget (with tags)") def selectize_with_tags(self): - choices = () class Schema(colander.Schema): @@ -2213,7 +2190,6 @@ class Schema(colander.Schema): ) @demonstrate("Selectize Widget (with tags and multiple)") def selectize_with_tags_and_multiple(self): - choices = () class Schema(colander.Schema): @@ -2244,7 +2220,6 @@ class Schema(colander.Schema): @view_config(renderer="templates/form.pt", name="checkboxchoice") @demonstrate("Checkbox Choice Widget") def checkboxchoice(self): - choices = ( ("habanero", "Habanero"), ("jalapeno", "Jalapeno"), @@ -2266,7 +2241,6 @@ class Schema(colander.Schema): @view_config(renderer="templates/form.pt", name="checkboxchoice_inline") @demonstrate("Checkbox Choice Widget (inline)") def checkboxchoice_inline(self): - choices = ( ("habanero", "Habanero"), ("jalapeno", "Jalapeno"), @@ -2290,7 +2264,6 @@ class Schema(colander.Schema): @view_config(renderer="templates/form.pt", name="checkboxchoice2") @demonstrate("Checkbox Choice Widget (with required field)") def checkboxchoice2(self): - choices = ( ("habanero", "Habanero"), ("jalapeno", "Jalapeno"), @@ -2316,7 +2289,6 @@ class Schema(colander.Schema): @view_config(renderer="templates/form.pt", name="checkboxchoice_readonly") @demonstrate("Checkbox Choice Widget (read-only)") def checkboxchoice_readonly(self): - choices = ( ("habanero", "Habanero"), ("jalapeno", "Jalapeno"), @@ -2341,7 +2313,6 @@ class Schema(colander.Schema): @view_config(renderer="templates/form.pt", name="i18n") @demonstrate("Internationalization") def i18n(self): - minmax = {"min": 1, "max": 10} locale_name = get_locale_name(self.request) @@ -2585,7 +2556,7 @@ class Schema2(colander.Schema): if "submit" in self.request.POST: posted_formid = self.request.POST["__formid__"] - for (formid, form) in [("form1", form1), ("form2", form2)]: + for formid, form in [("form1", form1), ("form2", form2)]: if formid == posted_formid: try: controls = self.request.POST.items() diff --git a/deformdemo/custom_widgets/modal.pt b/deformdemo/custom_widgets/modal.pt index 959f2602..375a6cc6 100644 --- a/deformdemo/custom_widgets/modal.pt +++ b/deformdemo/custom_widgets/modal.pt @@ -27,8 +27,8 @@ >