django-spec-html 0.2.0__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/.github/workflows/tests.yml +4 -3
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/CHANGELOG.md +112 -1
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/CLAUDE.md +5 -3
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/PKG-INFO +6 -4
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/README.md +4 -2
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/django_spec_html/__init__.py +4 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/django_spec_html/http/adispatch_request.py +1 -1
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/django_spec_html/http/dispatch_request.py +1 -1
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/django_spec_html/http/utils.py +18 -7
- django_spec_html-0.3.0/django_spec_html/templates/django_spec_html/base.html +18 -0
- django_spec_html-0.3.0/django_spec_html/templates/django_spec_html/spec_confirm.html +3 -0
- django_spec_html-0.3.0/django_spec_html/templates/django_spec_html/spec_confirm_fragment.html +13 -0
- django_spec_html-0.3.0/django_spec_html/templates/django_spec_html/spec_form.html +3 -0
- django_spec_html-0.3.0/django_spec_html/templates/django_spec_html/spec_form_fragment.html +17 -0
- django_spec_html-0.3.0/django_spec_html/templates/django_spec_html/spec_form_set.html +3 -0
- django_spec_html-0.3.0/django_spec_html/templates/django_spec_html/spec_form_set_fragment.html +22 -0
- django_spec_html-0.3.0/django_spec_html/templates/django_spec_html/target.html +26 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/django_spec_html/version.py +1 -1
- django_spec_html-0.3.0/django_spec_html/views/__init__.py +7 -0
- django_spec_html-0.3.0/django_spec_html/views/spec_confirm_view.py +299 -0
- django_spec_html-0.3.0/django_spec_html/views/spec_form_set_view.py +528 -0
- django_spec_html-0.3.0/django_spec_html/views/spec_form_view.py +707 -0
- django_spec_html-0.3.0/django_spec_html/views/utils.py +1293 -0
- django_spec_html-0.3.0/docs/confirm.md +219 -0
- django_spec_html-0.3.0/docs/examples/spec_confirm.py +106 -0
- django_spec_html-0.3.0/docs/examples/spec_form.py +435 -0
- django_spec_html-0.3.0/docs/examples/spec_form_set.py +77 -0
- django_spec_html-0.3.0/docs/formsets.md +182 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/docs/http.md +5 -3
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/docs/index.md +4 -2
- django_spec_html-0.3.0/docs/pages.md +851 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/docs/reference.md +48 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/mkdocs.yml +2 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/pyproject.toml +5 -2
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/tests/conftest_settings.py +14 -6
- django_spec_html-0.3.0/tests/docs/test_spec_confirm_examples.py +168 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/tests/docs/test_spec_form_examples.py +365 -2
- django_spec_html-0.3.0/tests/docs/test_spec_form_set_examples.py +166 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/tests/http/test_adispatch_request.py +27 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/tests/http/test_async_spec_view.py +14 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/tests/http/test_dispatch_request.py +31 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/tests/http/test_spec_view.py +16 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/tests/http/utils.py +23 -0
- django_spec_html-0.3.0/tests/templates/spec_confirm.html +1 -0
- django_spec_html-0.3.0/tests/templates/spec_confirm_dialog.html +25 -0
- django_spec_html-0.3.0/tests/templates/spec_confirm_form.html +6 -0
- django_spec_html-0.3.0/tests/templates/spec_confirm_view.html +1 -0
- django_spec_html-0.3.0/tests/templates/spec_confirm_view_form.html +9 -0
- django_spec_html-0.3.0/tests/templates/spec_edition.html +1 -0
- django_spec_html-0.3.0/tests/templates/spec_edition_form.html +5 -0
- django_spec_html-0.3.0/tests/templates/spec_formset.html +1 -0
- django_spec_html-0.3.0/tests/templates/spec_formset_form.html +6 -0
- django_spec_html-0.3.0/tests/templates/spec_target.html +11 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/tests/test_init.py +2 -0
- django_spec_html-0.3.0/tests/views/test_default_templates.py +671 -0
- django_spec_html-0.3.0/tests/views/test_spec_confirm_view.py +619 -0
- django_spec_html-0.3.0/tests/views/test_spec_form_set_view.py +870 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/tests/views/test_spec_form_view.py +1835 -24
- django_spec_html-0.3.0/tests/views/test_utils.py +55 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/uv.lock +7 -7
- django_spec_html-0.2.0/django_spec_html/views/__init__.py +0 -5
- django_spec_html-0.2.0/django_spec_html/views/spec_form_view.py +0 -947
- django_spec_html-0.2.0/docs/examples/spec_form.py +0 -187
- django_spec_html-0.2.0/docs/pages.md +0 -407
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/.github/CODEOWNERS +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/.github/SECURITY.md +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/.github/dependabot.yml +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/.github/workflows/release.yml +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/.github/workflows/upstream-drift.yml +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/.gitignore +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/.pre-commit-config.yaml +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/LICENSE +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/Makefile +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/django_spec_html/http/__init__.py +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/django_spec_html/http/add_argument_errors.py +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/django_spec_html/http/async_spec_view.py +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/django_spec_html/http/error_response.py +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/django_spec_html/http/request_arguments.py +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/django_spec_html/http/request_principal.py +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/django_spec_html/http/route_arguments.py +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/django_spec_html/http/spec_view.py +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/django_spec_html/http/unsupported_media_type.py +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/django_spec_html/py.typed +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/django_spec_html/types/__init__.py +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/django_spec_html/types/outcome.py +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/docs/__init__.py +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/docs/examples/__init__.py +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/docs/examples/htmx.py +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/docs/examples/http.py +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/scripts/check-changelog +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/scripts/release-publish.sh +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/tests/__init__.py +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/tests/adapter_app/__init__.py +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/tests/adapter_app/apps.py +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/tests/adapter_app/models.py +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/tests/conftest.py +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/tests/dispatch/__init__.py +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/tests/dispatch/utils.py +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/tests/dispatch_app/__init__.py +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/tests/dispatch_app/apps.py +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/tests/dispatch_app/models.py +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/tests/docs/__init__.py +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/tests/docs/test_http_examples.py +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/tests/http/__init__.py +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/tests/http/test_add_argument_errors.py +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/tests/http/test_error_response.py +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/tests/http/test_request_arguments.py +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/tests/http/test_request_principal.py +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/tests/http/test_route_arguments.py +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/tests/http/test_unsupported_media_type.py +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/tests/http/test_utils.py +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/tests/templates/spec_form.html +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/tests/templates/spec_form_available.html +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/tests/templates/spec_form_htmx.html +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/tests/templates/spec_fragment.html +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/tests/templates/spec_page.html +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/tests/types/__init__.py +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/tests/types/test_outcome.py +0 -0
- {django_spec_html-0.2.0 → django_spec_html-0.3.0}/tests/views/__init__.py +0 -0
|
@@ -107,9 +107,10 @@ jobs:
|
|
|
107
107
|
import django
|
|
108
108
|
from django.conf import settings
|
|
109
109
|
|
|
110
|
-
# The package defines no models and
|
|
111
|
-
#
|
|
112
|
-
#
|
|
110
|
+
# The package defines no models, and an app entry only lets the
|
|
111
|
+
# loader find its default templates: a project imports its views
|
|
112
|
+
# from a URLconf, after django.setup() against configured settings,
|
|
113
|
+
# so it is imported that way here.
|
|
113
114
|
settings.configure(
|
|
114
115
|
SECRET_KEY="x",
|
|
115
116
|
INSTALLED_APPS=[
|
|
@@ -7,6 +7,116 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.3.0] — 2026-10-26
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- **A page's template is optional.** `SpecFormView`, `SpecFormSetView` and
|
|
14
|
+
`SpecConfirmView` default `template_name` to a template this package ships:
|
|
15
|
+
`django_spec_html/spec_form.html`, `spec_form_set.html` and
|
|
16
|
+
`spec_confirm.html`, each extending `django_spec_html/base.html`. They are
|
|
17
|
+
plain, escaped documents with no stylesheet, script or htmx attribute. They
|
|
18
|
+
render the target pane, an unmet affordance's reason with the form disabled,
|
|
19
|
+
the form or formset with its errors, a question's message, a refusal's
|
|
20
|
+
`code`, and a submit button posting `commit_button`'s name. Each page's form
|
|
21
|
+
is a file of its own (`*_fragment.html`), which an htmx request is answered
|
|
22
|
+
with on every Django. The templates are found as any app's are, so list
|
|
23
|
+
`django_spec_html` in `INSTALLED_APPS` with `APP_DIRS` on; `as_view()` raises
|
|
24
|
+
`ImproperlyConfigured` when the view's engine finds no page or fragment it
|
|
25
|
+
would render. Override any of them the
|
|
26
|
+
Django way, or set `template_name` as before.
|
|
27
|
+
- **`SpecFormSetView` serves a `many` spec as a formset of its form**: each form
|
|
28
|
+
a row, sent as one list under `many_argument`, a form left blank sending no
|
|
29
|
+
row, and a refusal of row *i* placed on the form that sent it. The page shows
|
|
30
|
+
the spec's `many_min_length` forms, which are always sent, then `extra`
|
|
31
|
+
blank ones (1 by default), never past `many_max_length`; with
|
|
32
|
+
`commit_button` set, `add_button` names a second submit that re-renders the
|
|
33
|
+
formset with one more form and dispatches nothing. Its scope check is asked
|
|
34
|
+
of no target, on GET and before any post refused before dispatch reaches it
|
|
35
|
+
shows its forms - one the page's reading refuses, or a list the shape check
|
|
36
|
+
finds too long or too short - so a principal it refuses is denied, and
|
|
37
|
+
`as_view()` refuses a formset page displaying a target, an `extra` that is
|
|
38
|
+
not a non-negative int, and an `add_button` that is not a button's name.
|
|
39
|
+
- **`SpecConfirmView` serves a spec with no Validator** as a page showing its
|
|
40
|
+
target and a submit button, with nothing posted becoming an argument. A
|
|
41
|
+
refused post re-renders the confirmation page at the refusal's status, with
|
|
42
|
+
its messages as `errors`. A question is shown by its message, and is answered
|
|
43
|
+
on a form page instead. `as_view()` refuses a spec with a Validator, and a
|
|
44
|
+
required parameter that the route (named in `route_kwargs`), a declared seed,
|
|
45
|
+
a provider or the binding does not supply. `success_message` is formatted
|
|
46
|
+
with the target.
|
|
47
|
+
- **`SpecFormView` renders a service's `AdditionalInputRequired` as a
|
|
48
|
+
confirmation page.** The refusal's schema is checked first by the kernel's
|
|
49
|
+
`check_requested_input`, with the request's seeds, and a question no route
|
|
50
|
+
could hear answered raises `ImproperlyConfigured` on the page and in the
|
|
51
|
+
fragment alike. Otherwise the bound form is re-rendered with every value
|
|
52
|
+
posted, at 422 on the page and at 200 in place as the fragment, with no
|
|
53
|
+
`HX-Retarget` or `HX-Reswap`, and the context carries `requested_input`: the
|
|
54
|
+
message, the schema and the form's bound fields it names. The answer is a
|
|
55
|
+
field the spec's form declares, and the new `asked_fields` attribute, checked
|
|
56
|
+
at `as_view()`, holds those fields back from every GET and every other
|
|
57
|
+
refusal until a question names them, and shows them empty when asked. The
|
|
58
|
+
docs show the question landing in an out-of-band dialog, and say why it is no
|
|
59
|
+
gate on an agent route.
|
|
60
|
+
- **The page shows its target beside the form.** On GET and on every refused
|
|
61
|
+
post it re-renders, the context carries `target`: the row an instance
|
|
62
|
+
selector found, or the set a `collection_selector_spec` resolved. It is
|
|
63
|
+
absent for a create and for a missing row `allow_none` lets through.
|
|
64
|
+
- **A bulk page counts its set and says when.** `target_count` and
|
|
65
|
+
`target_counted_at` come from one `COUNT` on a fresh clone, never by reading
|
|
66
|
+
the rows, so a template says "117 rows selected, counted at 14:02" rather
|
|
67
|
+
than promising a number. An empty set is counted 0 and is no refusal; its
|
|
68
|
+
scope check is still asked. The confirming post re-runs the service on the
|
|
69
|
+
set it finds, and a successful post counts nothing.
|
|
70
|
+
- **`target_display`**, on a page that sets the new `display_target` (off by
|
|
71
|
+
default), is the target projected for a person by its Output's
|
|
72
|
+
`FieldMarking`s, presented through the spec's presenter with the context
|
|
73
|
+
dispatch hands it. `HIDDEN` and `HANDLE` fields are dropped, choices are
|
|
74
|
+
spoken as their displays, and the field marked `LABEL` names the row. A row
|
|
75
|
+
carries its `fields` and the same fields as `pairs`, the one a template loops
|
|
76
|
+
over, since `fields.items` reads a field named `items`. A set's
|
|
77
|
+
display covers at most `target_display_limit` rows (10 by default), read in
|
|
78
|
+
one bounded query. `as_view()` refuses a page displaying its target whose
|
|
79
|
+
spec has no Output, marks none of its own fields, or carries markings the
|
|
80
|
+
projection refuses, and a `target_display_limit` that is not a positive int.
|
|
81
|
+
- **A post that does not commit.** `commit_button` names the submit button
|
|
82
|
+
whose post commits; any other post - a dependent choice refreshed, a row
|
|
83
|
+
added - is the page again with its form bound to the post, built through
|
|
84
|
+
`form_kwargs`, with no dispatch, no validation and `refreshed` in the
|
|
85
|
+
context, at 200 on the page and in the fragment. Under htmx 2, an
|
|
86
|
+
`HX-Trigger-Name` naming another posted control does not commit either.
|
|
87
|
+
`None`, the default, commits every post as before; `commits(request)` is the
|
|
88
|
+
rule to override, and `as_view()` refuses a name that is not a button's.
|
|
89
|
+
- **`success_message`**, sent through `django.contrib.messages` on every
|
|
90
|
+
success - the redirect, `HX-Redirect` and the result fragment - formatted
|
|
91
|
+
with the form's cleaned data as Django's `SuccessMessageMixin` formats it,
|
|
92
|
+
through an overridable `get_success_message(result)`. Without the messages
|
|
93
|
+
middleware it is skipped, never raising `MessageFailure`; a refusal, a
|
|
94
|
+
confirmation page and a post that does not commit send none.
|
|
95
|
+
- **`SpecFormView` builds its form with the Validator's `form_kwargs`**,
|
|
96
|
+
through the kernel's `form_keywords`: the principal, the request's seeds, the
|
|
97
|
+
row and one call context per request, which dispatch is handed too. A form
|
|
98
|
+
whose `__init__` takes a keyword is served on GET and on POST.
|
|
99
|
+
|
|
100
|
+
### Changed
|
|
101
|
+
- **The kernel is floored at 0.17.0**, for `form_keywords` and a seeded
|
|
102
|
+
`authorize`.
|
|
103
|
+
- **A partial spec's page renders no HTML `required` attribute**, so a person
|
|
104
|
+
can post the subset the spec takes.
|
|
105
|
+
|
|
106
|
+
### Fixed
|
|
107
|
+
- **The page's class-level check is asked with the seeds it names**, through
|
|
108
|
+
`authorize(..., pool_seeds=...)`, instead of raising `TypeError`.
|
|
109
|
+
- **A refusal of the arguments shows every error in one post**: the page's form
|
|
110
|
+
is validated under `clean_held_to_their_columns` and its errors are merged
|
|
111
|
+
without duplicates, except on a partial page or a refused route.
|
|
112
|
+
- **The JSON views check a service's asked schema against the seeds the call
|
|
113
|
+
ran with.** `dispatch_request`, `adispatch_request` and so `SpecView` and
|
|
114
|
+
`AsyncSpecView` checked an `AdditionalInputRequired` schema with no pool
|
|
115
|
+
seeds, so a key a seed fills - one declared in `pool_seeds` or one
|
|
116
|
+
`get_pool_seeds(request)` adds - was written into a 422 body as a question
|
|
117
|
+
the client could not answer. It now raises `ImproperlyConfigured`, as the
|
|
118
|
+
page half already did.
|
|
119
|
+
|
|
10
120
|
## [0.2.0] — 2026-10-26
|
|
11
121
|
|
|
12
122
|
### Added
|
|
@@ -169,7 +279,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
169
279
|
so a refused post answers at the status a JSON client reads for the same
|
|
170
280
|
refusal.
|
|
171
281
|
|
|
172
|
-
[Unreleased]: https://github.com/Artui/django-spec-html/compare/v0.
|
|
282
|
+
[Unreleased]: https://github.com/Artui/django-spec-html/compare/v0.3.0...HEAD
|
|
283
|
+
[0.3.0]: https://github.com/Artui/django-spec-html/compare/v0.2.0...v0.3.0
|
|
173
284
|
[0.2.0]: https://github.com/Artui/django-spec-html/compare/v0.1.2...v0.2.0
|
|
174
285
|
[0.1.2]: https://github.com/Artui/django-spec-html/compare/v0.1.1...v0.1.2
|
|
175
286
|
[0.1.1]: https://github.com/Artui/django-spec-html/compare/v0.1.0...v0.1.1
|
|
@@ -58,7 +58,8 @@ Non-negotiable. They keep the package navigable, and they are the kernel's.
|
|
|
58
58
|
public surface in `__all__`. Internal modules import from leaf paths, never
|
|
59
59
|
from the package's `__init__`.
|
|
60
60
|
7. **The package root is a table of contents, not a drawer.** It holds
|
|
61
|
-
`__init__.py` and `version.py
|
|
61
|
+
`__init__.py` and `version.py`, and `templates/`, which Django's
|
|
62
|
+
app-directories loader finds only there. Everything else lives in a subpackage named
|
|
62
63
|
for a **concern**: `http/` (a spec as plain-Django JSON, and the request
|
|
63
64
|
readers both halves use) and `views/` (a spec as a page). `types/` is the
|
|
64
65
|
one standing subpackage, for value types, when there are any.
|
|
@@ -74,7 +75,8 @@ Non-negotiable. They keep the package navigable, and they are the kernel's.
|
|
|
74
75
|
|
|
75
76
|
| Subpackage | Holds |
|
|
76
77
|
| --- | --- |
|
|
77
|
-
| `views/` | `SpecFormView`, a spec served as the page its form is, and the private
|
|
78
|
+
| `views/` | `SpecFormView`, a spec served as the page its form is, with what only that page needs (the fields it holds back, the question it asks); `SpecFormSetView`, a `many` spec served as a formset of its form; `SpecConfirmView`, a spec with no Validator served as a target and a button; `utils.py` for `SpecPageBase`, the private base every page view subclasses (admission, the target and its display, dispatch, the refusal, the success and its message, the fragment wrapper, the commit rule), whose hooks a subclass supplies and `as_view()` refuses a class missing, and the form readers both form pages share (`form_values`, `without_errors`) |
|
|
79
|
+
| `templates/django_spec_html/` | the pages' default templates: `base.html`, which the three pages extend; `spec_form.html`, `spec_form_set.html` and `spec_confirm.html`, each including its form from a `*_fragment.html` of its own, which an htmx request is answered with on every Django; `target.html`, the target pane two of them share. Held by `tests/views/test_default_templates.py`, which mirrors no Python file |
|
|
78
80
|
| `types/` | `Outcome`, the ways a page's post ends; it imports nothing else in the package (rule 8) |
|
|
79
81
|
| `http/` | the JSON views (`SpecView`, `AsyncSpecView`, `dispatch_request`, `adispatch_request`), `error_response`, and the request readers both halves use: `request_arguments`, `route_arguments`, `request_principal`, `add_argument_errors`; `UnsupportedMediaType`, beside its raiser; `utils.py` for `SpecViewBase`, the helpers the entry points share, and `REFUSAL_STATUSES`, the status map the page reads too, with each refusal's `Outcome` |
|
|
80
82
|
|
|
@@ -173,7 +175,7 @@ configured and enforced. isort order is stdlib, third party, first party.
|
|
|
173
175
|
| --- | --- | --- |
|
|
174
176
|
| Python | 3.10 | 3.10 through 3.14 |
|
|
175
177
|
| Django | 4.2 | 4.2, 5.0, 5.1, 5.2, 6.0, 6.1 |
|
|
176
|
-
| django-service-specs | 0.
|
|
178
|
+
| django-service-specs | 0.17.0 | the newest release, and the floor in the `floor` job |
|
|
177
179
|
|
|
178
180
|
The Python and Django floors are the kernel's, and cannot sit below them.
|
|
179
181
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: django-spec-html
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: A django-service-specs spec as a server-rendered page, served as a plain form post, plus the plain-Django JSON views.
|
|
5
5
|
Project-URL: Homepage, https://github.com/Artui/django-spec-html
|
|
6
6
|
Project-URL: Repository, https://github.com/Artui/django-spec-html
|
|
@@ -30,7 +30,7 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
30
30
|
Classifier: Programming Language :: Python :: 3.14
|
|
31
31
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
32
32
|
Requires-Python: >=3.10
|
|
33
|
-
Requires-Dist: django-service-specs>=0.
|
|
33
|
+
Requires-Dist: django-service-specs>=0.17.0
|
|
34
34
|
Requires-Dist: django>=4.2
|
|
35
35
|
Description-Content-Type: text/markdown
|
|
36
36
|
|
|
@@ -71,8 +71,10 @@ longer ships these names: import them from `django_spec_html`.
|
|
|
71
71
|
pip install django-spec-html
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
-
Python 3.10 or later, Django 4.2 or later, and `django-service-specs` 0.
|
|
75
|
-
later, which it installs.
|
|
74
|
+
Python 3.10 or later, Django 4.2 or later, and `django-service-specs` 0.17.0 or
|
|
75
|
+
later, which it installs. The JSON views need no entry in `INSTALLED_APPS`; the
|
|
76
|
+
pages' default templates are found as any app's are, so list `django_spec_html`
|
|
77
|
+
there to use them, or give each page a `template_name` of its own.
|
|
76
78
|
|
|
77
79
|
## Quickstart
|
|
78
80
|
|
|
@@ -35,8 +35,10 @@ longer ships these names: import them from `django_spec_html`.
|
|
|
35
35
|
pip install django-spec-html
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
Python 3.10 or later, Django 4.2 or later, and `django-service-specs` 0.
|
|
39
|
-
later, which it installs.
|
|
38
|
+
Python 3.10 or later, Django 4.2 or later, and `django-service-specs` 0.17.0 or
|
|
39
|
+
later, which it installs. The JSON views need no entry in `INSTALLED_APPS`; the
|
|
40
|
+
pages' default templates are found as any app's are, so list `django_spec_html`
|
|
41
|
+
there to use them, or give each page a `template_name` of its own.
|
|
40
42
|
|
|
41
43
|
## Quickstart
|
|
42
44
|
|
|
@@ -18,11 +18,15 @@ from django_spec_html.http.spec_view import SpecView
|
|
|
18
18
|
from django_spec_html.http.unsupported_media_type import UnsupportedMediaType
|
|
19
19
|
from django_spec_html.types.outcome import Outcome
|
|
20
20
|
from django_spec_html.version import __version__
|
|
21
|
+
from django_spec_html.views.spec_confirm_view import SpecConfirmView
|
|
22
|
+
from django_spec_html.views.spec_form_set_view import SpecFormSetView
|
|
21
23
|
from django_spec_html.views.spec_form_view import SpecFormView
|
|
22
24
|
|
|
23
25
|
__all__ = [
|
|
24
26
|
"AsyncSpecView",
|
|
25
27
|
"Outcome",
|
|
28
|
+
"SpecConfirmView",
|
|
29
|
+
"SpecFormSetView",
|
|
26
30
|
"SpecFormView",
|
|
27
31
|
"SpecView",
|
|
28
32
|
"UnsupportedMediaType",
|
{django_spec_html-0.2.0 → django_spec_html-0.3.0}/django_spec_html/http/adispatch_request.py
RENAMED
|
@@ -81,7 +81,7 @@ async def adispatch_request(
|
|
|
81
81
|
return not_found_response()
|
|
82
82
|
return success_response(spec, await apresent(spec, result), success_status)
|
|
83
83
|
except (DispatchError, ServiceError) as refused:
|
|
84
|
-
check_asked_input(spec, refused)
|
|
84
|
+
check_asked_input(spec, refused, pool_seeds=pool_seeds)
|
|
85
85
|
return error_response(refused)
|
|
86
86
|
|
|
87
87
|
|
|
@@ -117,5 +117,5 @@ def dispatch_request(
|
|
|
117
117
|
return not_found_response()
|
|
118
118
|
return success_response(spec, present(spec, result), success_status)
|
|
119
119
|
except (DispatchError, ServiceError) as refused:
|
|
120
|
-
check_asked_input(spec, refused)
|
|
120
|
+
check_asked_input(spec, refused, pool_seeds=pool_seeds)
|
|
121
121
|
return error_response(refused)
|
|
@@ -131,17 +131,28 @@ def field_map(detail: Any) -> Mapping[Any, Any]:
|
|
|
131
131
|
return {NON_FIELD_ERRORS: [detail]}
|
|
132
132
|
|
|
133
133
|
|
|
134
|
-
def check_asked_input(
|
|
134
|
+
def check_asked_input(
|
|
135
|
+
spec: ServiceSpec | SelectorSpec | SpecSource, refused: Exception, *, pool_seeds: PoolSeeds
|
|
136
|
+
) -> None:
|
|
135
137
|
"""Refuse, as the service's own error, a request for input no route could hear answered.
|
|
136
138
|
|
|
137
139
|
A 422 body carries the schema a service asked under, and a client builds
|
|
138
140
|
its next call from it. A schema naming a key the closed argument set would
|
|
139
|
-
refuse, or a shape a transport cannot render, is
|
|
140
|
-
so it surfaces as the ``ImproperlyConfigured`` it
|
|
141
|
-
well-formed answer that cannot be answered. Anything
|
|
141
|
+
refuse, a key the server fills, or a shape a transport cannot render, is
|
|
142
|
+
not the caller's mistake, so it surfaces as the ``ImproperlyConfigured`` it
|
|
143
|
+
is rather than as a well-formed answer that cannot be answered. Anything
|
|
144
|
+
else passes.
|
|
145
|
+
|
|
146
|
+
``pool_seeds`` are the ones the call was dispatched with, declared and
|
|
147
|
+
per-request alike: a seed ``get_pool_seeds(request)`` supplies fills its
|
|
148
|
+
key as surely as one the view declares. It is required, because the
|
|
149
|
+
kernel's default is no seeds at all, so a caller leaving it out would check
|
|
150
|
+
against none. The tests holding it are
|
|
151
|
+
``test_a_schema_naming_a_key_the_requests_seeds_fill_is_the_services_error``,
|
|
152
|
+
in ``test_dispatch_request`` and ``test_adispatch_request``.
|
|
142
153
|
"""
|
|
143
154
|
if isinstance(refused, AdditionalInputRequired):
|
|
144
|
-
check_requested_input(spec, refused.schema)
|
|
155
|
+
check_requested_input(spec, refused.schema, pool_seeds=pool_seeds)
|
|
145
156
|
|
|
146
157
|
|
|
147
158
|
def not_found_response() -> JsonResponse:
|
|
@@ -426,7 +437,7 @@ def check_request_hooks(
|
|
|
426
437
|
check_server_arguments(
|
|
427
438
|
spec, server, pool_seeds=_configured(view_class, initkwargs, "pool_seeds")
|
|
428
439
|
)
|
|
429
|
-
filled = sorted(
|
|
440
|
+
filled = sorted(route_targets(route_kwargs) & server.names())
|
|
430
441
|
if filled:
|
|
431
442
|
raise ImproperlyConfigured(
|
|
432
443
|
f"{label}.route_kwargs fills {', '.join(filled)}, which server_arguments "
|
|
@@ -550,7 +561,7 @@ def _filled_by(
|
|
|
550
561
|
return name if name in route_kwargs else None
|
|
551
562
|
|
|
552
563
|
|
|
553
|
-
def
|
|
564
|
+
def route_targets(
|
|
554
565
|
route_kwargs: Mapping[str, str | None] | tuple[str, ...] | None,
|
|
555
566
|
) -> frozenset[str]:
|
|
556
567
|
"""Every parameter ``route_kwargs`` names a kwarg into: a mapping's targets, a tuple's names."""
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{% load i18n %}{% get_current_language as LANGUAGE_CODE %}<!DOCTYPE html>
|
|
2
|
+
{% comment %}
|
|
3
|
+
The document every page this package ships extends. Override this one file,
|
|
4
|
+
the Django way, to put all three pages inside a project's own layout: each
|
|
5
|
+
page fills ``content`` with its fragment and nothing else.
|
|
6
|
+
{% endcomment %}
|
|
7
|
+
<html lang="{{ LANGUAGE_CODE }}">
|
|
8
|
+
<head>
|
|
9
|
+
<meta charset="utf-8">
|
|
10
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
11
|
+
<title>{% block title %}{% endblock %}</title>
|
|
12
|
+
</head>
|
|
13
|
+
<body>
|
|
14
|
+
<main>
|
|
15
|
+
{% block content %}{% endblock %}
|
|
16
|
+
</main>
|
|
17
|
+
</body>
|
|
18
|
+
</html>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{% load i18n %}{% comment %}
|
|
2
|
+
The confirmation page's target and button, and what an htmx request for it
|
|
3
|
+
is answered with. There is no form to fill in, so the post carries the token
|
|
4
|
+
and the button alone. A question is shown by its message, which is the one
|
|
5
|
+
entry of ``errors`` it brings: the page builds no control from a schema.
|
|
6
|
+
{% endcomment %}{% include "django_spec_html/target.html" %}
|
|
7
|
+
{% if unavailable %}<p data-code="{{ unavailable.code }}">{{ unavailable.reason }}</p>{% endif %}
|
|
8
|
+
{% if requested_input %}<p>{{ requested_input.message }}</p>
|
|
9
|
+
{% elif errors %}<ul class="errorlist">{% for error in errors %}<li>{{ error }}</li>{% endfor %}</ul>
|
|
10
|
+
{% endif %}<form method="post"{% if code %} data-code="{{ code }}"{% endif %}>
|
|
11
|
+
{% csrf_token %}
|
|
12
|
+
<button type="submit"{% if view.commit_button %} name="{{ view.commit_button }}"{% endif %}{% if unavailable %} disabled{% endif %}>{% translate "Confirm" %}</button>
|
|
13
|
+
</form>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{% load i18n %}{% comment %}
|
|
2
|
+
The form page's form, and what an htmx request for it is answered with: a
|
|
3
|
+
file of its own rather than a ``partialdef``, so it renders on every
|
|
4
|
+
Django this package supports. ``as_div`` rather than ``{{ form }}``, which is a
|
|
5
|
+
table below Django 5.0. The form renders each field's own ``required``, which
|
|
6
|
+
a partial page's form has switched off; a question's message is the form's
|
|
7
|
+
non-field error and its asked field is in the form, so each is rendered once.
|
|
8
|
+
{% endcomment %}{% include "django_spec_html/target.html" %}
|
|
9
|
+
{% if unavailable %}<p data-code="{{ unavailable.code }}">{{ unavailable.reason }}</p>{% endif %}
|
|
10
|
+
{% if spec.partial %}<p>{% translate "A field left blank is left as it is." %}</p>{% endif %}
|
|
11
|
+
<form method="post"{% if form.is_multipart %} enctype="multipart/form-data"{% endif %}{% if code %} data-code="{{ code }}"{% endif %}>
|
|
12
|
+
{% csrf_token %}
|
|
13
|
+
<fieldset{% if unavailable %} disabled{% endif %}>
|
|
14
|
+
{{ form.as_div }}
|
|
15
|
+
<button type="submit"{% if view.commit_button %} name="{{ view.commit_button }}"{% endif %}>{% translate "Save" %}</button>
|
|
16
|
+
</fieldset>
|
|
17
|
+
</form>
|
django_spec_html-0.3.0/django_spec_html/templates/django_spec_html/spec_form_set_fragment.html
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{% load i18n %}{% comment %}
|
|
2
|
+
The many page's formset, and what an htmx request for it is answered with. No
|
|
3
|
+
target pane: a many spec declares no target. Each form is a fieldset of its
|
|
4
|
+
own, so a row's errors sit with its fields; a refusal of the list as a whole,
|
|
5
|
+
a question's message among them, is the formset's non-form errors. The
|
|
6
|
+
commit button comes first, so Enter in a field commits rather than adding a
|
|
7
|
+
row, and the add button skips the browser's checks, since its post commits
|
|
8
|
+
nothing.
|
|
9
|
+
{% endcomment %}{% if unavailable %}<p data-code="{{ unavailable.code }}">{{ unavailable.reason }}</p>{% endif %}
|
|
10
|
+
<form method="post"{% if formset.is_multipart %} enctype="multipart/form-data"{% endif %}{% if code %} data-code="{{ code }}"{% endif %}>
|
|
11
|
+
{% csrf_token %}
|
|
12
|
+
{{ formset.management_form }}
|
|
13
|
+
<fieldset{% if unavailable %} disabled{% endif %}>
|
|
14
|
+
{{ formset.non_form_errors }}
|
|
15
|
+
{% for form in formset %}<fieldset>
|
|
16
|
+
<legend>{% blocktranslate with number=forloop.counter trimmed %}Row {{ number }}{% endblocktranslate %}</legend>
|
|
17
|
+
{{ form.as_div }}
|
|
18
|
+
</fieldset>
|
|
19
|
+
{% endfor %}<button type="submit"{% if view.commit_button %} name="{{ view.commit_button }}"{% endif %}>{% translate "Save" %}</button>
|
|
20
|
+
{% if view.add_button %}<button type="submit" name="{{ view.add_button }}" formnovalidate>{% translate "Add another" %}</button>{% endif %}
|
|
21
|
+
</fieldset>
|
|
22
|
+
</form>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{% load i18n %}{% comment %}
|
|
2
|
+
The target pane the form page and the confirmation page share. A set is
|
|
3
|
+
counted whether or not its display is on, since a count and the time it was
|
|
4
|
+
taken say nothing about any row. Otherwise only ``target_display`` is shown,
|
|
5
|
+
the target as its Output marks it for a person: never ``target`` itself,
|
|
6
|
+
whose string may be anything its model's ``__str__`` returns.
|
|
7
|
+
{% endcomment %}{% if target_count is not None %}
|
|
8
|
+
<p>{% blocktranslate count counter=target_count with at=target_counted_at|time:"H:i" trimmed %}
|
|
9
|
+
{{ counter }} row selected, counted at {{ at }}.
|
|
10
|
+
{% plural %}
|
|
11
|
+
{{ counter }} rows selected, counted at {{ at }}.
|
|
12
|
+
{% endblocktranslate %}</p>
|
|
13
|
+
{% if target_display %}
|
|
14
|
+
<ul>
|
|
15
|
+
{% for row in target_display %}<li>{% if row.label %}{{ row.label }}{% else %}<dl>{% for name, value in row.pairs %}<dt>{{ name }}</dt><dd>{{ value }}</dd>{% endfor %}</dl>{% endif %}</li>
|
|
16
|
+
{% endfor %}</ul>
|
|
17
|
+
{% if target_count > target_display|length %}<p>{% blocktranslate count counter=target_display|length trimmed %}
|
|
18
|
+
The first row is shown.
|
|
19
|
+
{% plural %}
|
|
20
|
+
The first {{ counter }} rows are shown.
|
|
21
|
+
{% endblocktranslate %}</p>{% endif %}
|
|
22
|
+
{% endif %}
|
|
23
|
+
{% elif target_display %}
|
|
24
|
+
{% if target_display.label %}<p>{{ target_display.label }}</p>{% endif %}
|
|
25
|
+
<dl>{% for name, value in target_display.pairs %}<dt>{{ name }}</dt><dd>{{ value }}</dd>{% endfor %}</dl>
|
|
26
|
+
{% endif %}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"""A spec served as a server-rendered page."""
|
|
2
|
+
|
|
3
|
+
from django_spec_html.views.spec_confirm_view import SpecConfirmView
|
|
4
|
+
from django_spec_html.views.spec_form_set_view import SpecFormSetView
|
|
5
|
+
from django_spec_html.views.spec_form_view import SpecFormView
|
|
6
|
+
|
|
7
|
+
__all__ = ["SpecConfirmView", "SpecFormSetView", "SpecFormView"]
|