-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #43: Stop slugifying choices, thereby supporting non-latin languages
- Loading branch information
Showing
4 changed files
with
56 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
exclude: ".yarn/|yarn.lock|\\.min\\.(css|js)$" | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.6.0 | ||
rev: v5.0.0 | ||
hooks: | ||
- id: check-added-large-files | ||
- id: check-builtin-literals | ||
|
@@ -14,35 +14,27 @@ repos: | |
- id: mixed-line-ending | ||
- id: trailing-whitespace | ||
- repo: https://github.com/adamchainz/django-upgrade | ||
rev: 1.20.0 | ||
rev: 1.22.1 | ||
hooks: | ||
- id: django-upgrade | ||
args: [--target-version, "3.2"] | ||
- repo: https://github.com/MarcoGorelli/absolufy-imports | ||
rev: v0.3.1 | ||
hooks: | ||
- id: absolufy-imports | ||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
rev: "v0.6.2" | ||
rev: "v0.7.0" | ||
hooks: | ||
- id: ruff | ||
args: [--unsafe-fixes] | ||
- id: ruff-format | ||
- repo: https://github.com/pre-commit/mirrors-prettier | ||
rev: v3.1.0 | ||
hooks: | ||
- id: prettier | ||
args: [--list-different, --no-semi] | ||
exclude: "^conf/|.*\\.html$" | ||
- repo: https://github.com/biomejs/pre-commit | ||
rev: "v0.4.0" | ||
rev: "v0.5.0" | ||
hooks: | ||
- id: biome-check | ||
additional_dependencies: ["@biomejs/[email protected]"] | ||
additional_dependencies: ["@biomejs/[email protected]"] | ||
args: [--unsafe] | ||
- repo: https://github.com/tox-dev/pyproject-fmt | ||
rev: 2.2.1 | ||
rev: 2.4.3 | ||
hooks: | ||
- id: pyproject-fmt | ||
- repo: https://github.com/abravalheri/validate-pyproject | ||
rev: v0.19 | ||
rev: v0.21 | ||
hooks: | ||
- id: validate-pyproject |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,7 +94,7 @@ def test_forms(self): | |
) | ||
self.assertContains(response, "<textarea", 1) | ||
self.assertContains( | ||
response, 'value="two-what" required id="id_fc1-radio_1" checked', 1 | ||
response, 'value="two what" required id="id_fc1-radio_1" checked', 1 | ||
) | ||
self.assertContains(response, 'type="date"', 1) | ||
|
||
|
@@ -133,9 +133,9 @@ def test_forms(self): | |
f"fc{form.id}-subject": "Test", | ||
f"fc{form.id}-email": "[email protected]", | ||
f"fc{form.id}-body": "Hello World", | ||
f"fc{form.id}-radio": "two-what", | ||
f"fc{form.id}-radio": "two what", | ||
f"fc{form.id}-date": "2022-10-02", | ||
f"fc{form.id}-multiple-choice": ["choice-a", "choice-c"], | ||
f"fc{form.id}-multiple-choice": ["Choice A", "Choice C"], | ||
}, | ||
) | ||
|
||
|
@@ -407,3 +407,35 @@ def test_email_to_author(self): | |
self.assertEqual(message.subject, "Test contact form") | ||
self.assertIn("Subject:\nTest\n", message.body) | ||
self.assertIn("Email:\n[email protected]\n", message.body) | ||
|
||
def test_choices(self): | ||
"""Legacy slugified choices should also use the pretty format""" | ||
|
||
form = Form.objects.create( | ||
title="Test contact form", | ||
config={"save_fs": {}}, | ||
) | ||
form.fields.create( | ||
ordering=6, | ||
title="Multiple Choice", | ||
name="multiple-choice", | ||
type="multiple-select", | ||
choices="Choice A,Choice B,Choice C", | ||
is_required=False, | ||
) | ||
|
||
s1 = FormSubmission.objects.create( | ||
form=form, | ||
data={ | ||
"multiple-choice": ["Choice A", "Choice C"], | ||
}, | ||
) | ||
self.assertIn("Multiple Choice:\nChoice A, Choice C", s1.formatted_data()) | ||
|
||
s2 = FormSubmission.objects.create( | ||
form=form, | ||
data={ | ||
"multiple-choice": ["choice-a", "choice-c"], | ||
}, | ||
) | ||
self.assertIn("Multiple Choice:\nChoice A, Choice C", s2.formatted_data()) |