ggds-django 0.2.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.
- ggds_django-0.2.0/.gitignore +24 -0
- ggds_django-0.2.0/LICENSE +201 -0
- ggds_django-0.2.0/LICENSE.md +25 -0
- ggds_django-0.2.0/PKG-INFO +146 -0
- ggds_django-0.2.0/README.md +131 -0
- ggds_django-0.2.0/build.mjs +22 -0
- ggds_django-0.2.0/demo/render.py +79 -0
- ggds_django-0.2.0/demo/templates/demo/base.html +23 -0
- ggds_django-0.2.0/demo/templates/demo/form.html +9 -0
- ggds_django-0.2.0/demo/templates/demo/index.html +11 -0
- ggds_django-0.2.0/demo/templates/demo/list.html +9 -0
- ggds_django-0.2.0/pyproject.toml +23 -0
- ggds_django-0.2.0/src/ggds_django/__init__.py +3 -0
- ggds_django-0.2.0/src/ggds_django/admin_theme/__init__.py +8 -0
- ggds_django-0.2.0/src/ggds_django/admin_theme/apps.py +39 -0
- ggds_django-0.2.0/src/ggds_django/admin_theme/static/ggds_admin/admin.css +137 -0
- ggds_django-0.2.0/src/ggds_django/admin_theme/templates/admin/base_site.html +15 -0
- ggds_django-0.2.0/src/ggds_django/admin_theme/templates/admin/color_theme_toggle.html +1 -0
- ggds_django-0.2.0/src/ggds_django/admin_theme/templates/ggds_admin/branding.html +7 -0
- ggds_django-0.2.0/src/ggds_django/admin_theme/templatetags/__init__.py +0 -0
- ggds_django-0.2.0/src/ggds_django/admin_theme/templatetags/ggds_admin.py +37 -0
- ggds_django-0.2.0/src/ggds_django/apps.py +7 -0
- ggds_django-0.2.0/src/ggds_django/forms.py +107 -0
- ggds_django-0.2.0/src/ggds_django/icons.json +14 -0
- ggds_django-0.2.0/src/ggds_django/icons.py +23 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/components/banner.css +94 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/components/banner.min.css +2 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/components/button.css +90 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/components/button.min.css +2 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/components/card.css +191 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/components/card.min.css +2 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/components/date-input.css +32 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/components/date-input.min.css +2 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/components/disclosure.css +57 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/components/disclosure.min.css +2 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/components/error-summary.css +32 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/components/error-summary.min.css +2 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/components/field.css +156 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/components/field.min.css +2 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/components/footer.css +163 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/components/footer.min.css +2 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/components/header.css +302 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/components/header.min.css +2 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/components/hero.css +308 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/components/hero.min.css +2 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/components/navigation.css +113 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/components/navigation.min.css +2 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/components/notice.css +55 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/components/notice.min.css +2 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/components/panel.css +57 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/components/panel.min.css +2 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/components/prose.css +54 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/components/prose.min.css +2 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/components/skip-link.css +23 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/components/skip-link.min.css +2 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/components/summary-list.css +83 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/components/summary-list.min.css +2 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/components/tab-bar.css +71 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/components/tab-bar.min.css +2 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/components/table.css +40 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/components/table.min.css +2 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/components/tag.css +20 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/components/tag.min.css +2 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/core.css +267 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/core.min.css +2 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/ggds-components.css +2088 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/ggds-components.min.css +2 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/ggds.css +2191 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/ggds.min.css +2 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/js/auto.js +3 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/js/error-summary.js +28 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/js/index.js +14 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/js/menu.js +33 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/themes/csa.css +6 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/themes/dpc.css +6 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/themes/gdcl.css +6 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/themes/gdnr.css +6 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/themes/gi-kace.css +6 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/themes/gifec.css +6 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/themes/gmet.css +6 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/themes/gpcl.css +6 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/themes/mocdti.css +6 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/themes/nca.css +6 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/themes/nita.css +6 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/themes/pcsrc.css +6 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/themes/themes.css +85 -0
- ggds_django-0.2.0/src/ggds_django/static/ggds/tokens.css +103 -0
- ggds_django-0.2.0/src/ggds_django/templates/ggds/components/banner.html +10 -0
- ggds_django-0.2.0/src/ggds_django/templates/ggds/components/breadcrumbs.html +6 -0
- ggds_django-0.2.0/src/ggds_django/templates/ggds/components/footer.html +34 -0
- ggds_django-0.2.0/src/ggds_django/templates/ggds/components/header.html +20 -0
- ggds_django-0.2.0/src/ggds_django/templates/ggds/components/hero.html +24 -0
- ggds_django-0.2.0/src/ggds_django/templates/ggds/components/pagination.html +8 -0
- ggds_django-0.2.0/src/ggds_django/templates/ggds/components/panel.html +4 -0
- ggds_django-0.2.0/src/ggds_django/templates/ggds/components/skip_link.html +1 -0
- ggds_django-0.2.0/src/ggds_django/templates/ggds/components/summary_list.html +7 -0
- ggds_django-0.2.0/src/ggds_django/templates/ggds/components/tab_bar.html +6 -0
- ggds_django-0.2.0/src/ggds_django/templates/ggds/forms/error_summary.html +7 -0
- ggds_django-0.2.0/src/ggds_django/templates/ggds/forms/field.html +44 -0
- ggds_django-0.2.0/src/ggds_django/templates/ggds/forms/form.html +3 -0
- ggds_django-0.2.0/src/ggds_django/templatetags/__init__.py +0 -0
- ggds_django-0.2.0/src/ggds_django/templatetags/ggds.py +315 -0
- ggds_django-0.2.0/tests/__init__.py +0 -0
- ggds_django-0.2.0/tests/settings.py +18 -0
- ggds_django-0.2.0/tests/test_admin.py +89 -0
- ggds_django-0.2.0/tests/test_components.py +56 -0
- ggds_django-0.2.0/tests/test_date_summary_panel.py +117 -0
- ggds_django-0.2.0/tests/test_forms.py +60 -0
- ggds_django-0.2.0/tests/test_parity.py +75 -0
- ggds_django-0.2.0/tests/urls.py +4 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
node_modules/
|
|
2
|
+
dist/
|
|
3
|
+
site/
|
|
4
|
+
test-results/
|
|
5
|
+
playwright-report/
|
|
6
|
+
.DS_Store
|
|
7
|
+
|
|
8
|
+
# Copied into each package when it is packed (scripts/package-files.mjs)
|
|
9
|
+
packages/*/LICENSE
|
|
10
|
+
packages/*/LICENSE.md
|
|
11
|
+
|
|
12
|
+
# Release files (scripts/release.mjs)
|
|
13
|
+
release/
|
|
14
|
+
|
|
15
|
+
# ggds-django: its Python environment, and the files build.mjs copies in (pnpm run build)
|
|
16
|
+
packages/django/.venv/
|
|
17
|
+
packages/django/src/ggds_django/static/
|
|
18
|
+
packages/django/src/ggds_django/icons.json
|
|
19
|
+
__pycache__/
|
|
20
|
+
|
|
21
|
+
# ggds-wordpress: the files build.mjs copies in (pnpm run build)
|
|
22
|
+
packages/wordpress/ggds/assets/
|
|
23
|
+
packages/wordpress/ggds/LICENSE
|
|
24
|
+
packages/wordpress/ggds/LICENSE.md
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Licence
|
|
2
|
+
|
|
3
|
+
GGDS code is licensed under the **Apache License, Version 2.0**. The full text is in [`LICENSE`](LICENSE).
|
|
4
|
+
This was decided on 9 November 2026 (decision D-10 of the GGDS assessment).
|
|
5
|
+
|
|
6
|
+
"Code" means everything in this repository except the marks listed below: tokens, CSS, JavaScript, the reference
|
|
7
|
+
HTML, the documentation site and its build scripts, and the tests.
|
|
8
|
+
|
|
9
|
+
## Not covered by the licence
|
|
10
|
+
|
|
11
|
+
The Apache licence does **not** cover these. They are not licensed by this repository under any terms:
|
|
12
|
+
|
|
13
|
+
- the national flag of Ghana and its colours as a national symbol;
|
|
14
|
+
- the coat of arms of Ghana and other national emblems (Armed Forces Council, Coat of Arms and National Flag
|
|
15
|
+
Act, 1959 (No. 61); see decision D-03);
|
|
16
|
+
- the names, logos and other marks of MoCDTI and its agencies, including the logos shown on the agency theme
|
|
17
|
+
pages.
|
|
18
|
+
|
|
19
|
+
Using a GGDS theme does not give anyone the right to use an agency's name or logo, or to present a website as a
|
|
20
|
+
Government of Ghana website.
|
|
21
|
+
|
|
22
|
+
## Contributions
|
|
23
|
+
|
|
24
|
+
Contributions are accepted under the same licence, with a Developer Certificate of Origin sign-off on every
|
|
25
|
+
commit. See [`CONTRIBUTING.md`](CONTRIBUTING.md).
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: ggds-django
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Ghana Government Design System (GGDS) for Django: page parts as template tags, a form renderer, and the GGDS styles and script.
|
|
5
|
+
Project-URL: Documentation, https://github.com/ghana-gds/ggds
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
License-File: LICENSE.md
|
|
9
|
+
Classifier: Framework :: Django
|
|
10
|
+
Classifier: Framework :: Django :: 5.0
|
|
11
|
+
Classifier: Framework :: Django :: 6.0
|
|
12
|
+
Requires-Python: >=3.10
|
|
13
|
+
Requires-Dist: django>=5.0
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
# ggds-django
|
|
17
|
+
|
|
18
|
+
The [Ghana Government Design System](https://github.com/ghana-gds/ggds) (GGDS) for Django: the page parts as
|
|
19
|
+
template tags, a form renderer that turns any Django form into GGDS markup with correct error handling, the GGDS
|
|
20
|
+
styles, themes and script as static files, and GGDS colours and header for Django admin. Django 5.0 or later. Works
|
|
21
|
+
with Wagtail and other Django-based CMSs.
|
|
22
|
+
|
|
23
|
+
**Documentation:** [ghana-gds.github.io/ggds](https://ghana-gds.github.io/ggds/) · [Use it with Django](https://ghana-gds.github.io/ggds/get-started/developers.html#django) · [Versions and support](https://ghana-gds.github.io/ggds/versions.html)
|
|
24
|
+
|
|
25
|
+
## Set up
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
INSTALLED_APPS = [..., "django.contrib.staticfiles", "ggds_django"]
|
|
29
|
+
FORM_RENDERER = "ggds_django.forms.GGDSFormRenderer" # every form in GGDS markup
|
|
30
|
+
TEMPLATES = [{..., "OPTIONS": {"context_processors": [..., "django.template.context_processors.request"]}}]
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
To use GGDS for some forms only, leave `FORM_RENDERER` out and add `GGDSFormMixin` to those forms.
|
|
34
|
+
|
|
35
|
+
## A page
|
|
36
|
+
|
|
37
|
+
```django
|
|
38
|
+
{% load ggds %}<!doctype html>
|
|
39
|
+
<html lang="en-GB">
|
|
40
|
+
<head>
|
|
41
|
+
<meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
|
|
42
|
+
<title>{% ggds_error_title form "Make a complaint" %} | Example Agency</title>
|
|
43
|
+
{% ggds_assets theme="nca" %}
|
|
44
|
+
</head>
|
|
45
|
+
<body>
|
|
46
|
+
{% ggds_skip_link %}
|
|
47
|
+
{% ggds_banner short_name="NCA" host="nca.org.gh" official=is_official %}
|
|
48
|
+
{% ggds_header name="National Communications Authority" nav=nav %}
|
|
49
|
+
<main id="main" tabindex="-1" class="ggds-container ggds-main">
|
|
50
|
+
{% ggds_breadcrumbs crumbs %}
|
|
51
|
+
<h1>Make a complaint</h1>
|
|
52
|
+
<form method="post">{% csrf_token %}
|
|
53
|
+
{{ form }}
|
|
54
|
+
<button class="ggds-button">Send complaint</button>
|
|
55
|
+
</form>
|
|
56
|
+
</main>
|
|
57
|
+
{% ggds_footer name="National Communications Authority" sections=sections links=footer_links %}
|
|
58
|
+
{% ggds_tab_bar tabs %}
|
|
59
|
+
</body>
|
|
60
|
+
</html>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Links are dicts (`{"label": "Services", "href": "/services/"}`) or `("Services", "/services/")` pairs. The header
|
|
64
|
+
marks the section the page's address is in; the tab bar marks the current tab.
|
|
65
|
+
|
|
66
|
+
## Forms
|
|
67
|
+
|
|
68
|
+
With the renderer, `{{ form }}` shows an error summary after a failed submit (focused on load by the GGDS
|
|
69
|
+
script, each item linking to its field, a radio group's to its first option), then every field:
|
|
70
|
+
|
|
71
|
+
| Django widget | GGDS markup |
|
|
72
|
+
|---|---|
|
|
73
|
+
| Text, email, number, date… | `ggds-field` with label, hint (`help_text`), error and `ggds-input` |
|
|
74
|
+
| `Textarea`, `Select`, `FileInput` | the same with `ggds-textarea`, `ggds-select`, `ggds-file-upload` |
|
|
75
|
+
| `RadioSelect`, `CheckboxSelectMultiple` | a `ggds-fieldset` with a legend and `ggds-choices` |
|
|
76
|
+
| `CheckboxInput` | a single `ggds-choice` |
|
|
77
|
+
| `GGDSDateField` | a `ggds-fieldset` with day, month and year boxes (`ggds-date-input`) |
|
|
78
|
+
|
|
79
|
+
Each control gets `aria-describedby` (hint, then error) and, with an error, `aria-invalid="true"`. Errors start
|
|
80
|
+
with a hidden "Error:". Fields that are not required say "(optional)". Set `autocomplete` on personal details with
|
|
81
|
+
the widget's `attrs`. One field: `{{ form.phone.as_field_group }}`.
|
|
82
|
+
|
|
83
|
+
### Dates people know
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
from ggds_django.forms import GGDSDateField
|
|
87
|
+
|
|
88
|
+
class ApplicationForm(forms.Form):
|
|
89
|
+
date_of_birth = GGDSDateField(label="What is your date of birth?", name="date of birth", birthday=True,
|
|
90
|
+
help_text="For example, 27 3 1990")
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
`cleaned_data["date_of_birth"]` is a `datetime.date`. The month can be typed as 3, 03, March or Mar. Errors use
|
|
94
|
+
`name`: "Enter date of birth", "Date of birth must include a year", "Year must include 4 numbers", "Date of birth
|
|
95
|
+
must be a real date", and with `birthday=True` or `past=True`, "Date of birth must be in the past". Only the boxes
|
|
96
|
+
with the problem are marked invalid, and the error summary links to the first of them. `birthday=True` also adds
|
|
97
|
+
`autocomplete="bday-day"` and so on.
|
|
98
|
+
|
|
99
|
+
## Page parts
|
|
100
|
+
|
|
101
|
+
| Tag | |
|
|
102
|
+
|---|---|
|
|
103
|
+
| `{% ggds_assets theme="nca" %}` | Stylesheet, theme and optional script, in `<head>` |
|
|
104
|
+
| `{% ggds_skip_link %}` | First thing in `<body>` |
|
|
105
|
+
| `{% ggds_banner short_name host official %}` | Government website banner |
|
|
106
|
+
| `{% ggds_header name nav %}` | Logo or initials, name, sections, Search |
|
|
107
|
+
| `{% ggds_hero title purpose lede search_action tasks %}` | Homepage hero |
|
|
108
|
+
| `{% ggds_breadcrumbs crumbs %}` | Trail ending with the current page |
|
|
109
|
+
| `{% ggds_summary_list rows %}` | Check answers: rows of `{"key", "value", "href"}`; an empty value shows "Not given", and each Change link says what it changes. `plain=True` for no lines |
|
|
110
|
+
| `{% ggds_panel "Complaint sent" reference=ref %}` | Confirmation panel: the page's `<h1>` and the reference number |
|
|
111
|
+
| `{% ggds_pagination page_obj %}` | From Django's `Paginator`; keeps other query parameters |
|
|
112
|
+
| `{% ggds_footer name purpose address email phone sections links %}` | Footer |
|
|
113
|
+
| `{% ggds_tab_bar tabs %}` | Phone quick links: each tab has an `icon` |
|
|
114
|
+
| `{% ggds_error_summary form %}` | On its own, for forms you lay out yourself |
|
|
115
|
+
|
|
116
|
+
Everything else (buttons, notices, tags, cards, tables) is plain GGDS HTML: copy it from the documentation.
|
|
117
|
+
|
|
118
|
+
## Django admin
|
|
119
|
+
|
|
120
|
+
Admin keeps its own layout but takes GGDS's colours, type, focus style and header (the flag-colour rule and the
|
|
121
|
+
institution's logo or initials, name and country), from the GGDS tokens and your institution's theme:
|
|
122
|
+
|
|
123
|
+
```python
|
|
124
|
+
INSTALLED_APPS = [..., "ggds_django", "ggds_django.admin_theme", "django.contrib.admin", ...] # above admin
|
|
125
|
+
GGDS_ADMIN = {
|
|
126
|
+
"theme": "nca", # a file in ggds/themes/, as for {% ggds_assets %}
|
|
127
|
+
"name": "National Communications Authority", # default: the admin site's site_header
|
|
128
|
+
"initials": "NCA", # or "logo_url" and "logo_alt"
|
|
129
|
+
"country": "Republic of Ghana", # the default; "" for none
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
It loads the tokens on their own (`ggds/tokens.css`), never the GGDS base styles, which would restyle admin's
|
|
134
|
+
elements. Admin is shown light only: the dark palette and the theme toggle are left out. `manage.py check` warns if
|
|
135
|
+
the app is below `django.contrib.admin`, a key is misspelt or the theme does not exist.
|
|
136
|
+
|
|
137
|
+
## Content added after load
|
|
138
|
+
|
|
139
|
+
HTMX, fetch or a script that adds a GGDS menu or error summary should call `initAll(element)` from the GGDS script
|
|
140
|
+
(`ggds/js/index.js`) on the new content.
|
|
141
|
+
|
|
142
|
+
## Develop
|
|
143
|
+
|
|
144
|
+
From the GGDS repository: `pnpm run build` copies the tokens, styles, themes, script and icons into the app;
|
|
145
|
+
`pnpm run test:django` runs the tests (including a check that the markup matches the GGDS documentation) and renders
|
|
146
|
+
an example site into the documentation build, where the accessibility tests check it.
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# ggds-django
|
|
2
|
+
|
|
3
|
+
The [Ghana Government Design System](https://github.com/ghana-gds/ggds) (GGDS) for Django: the page parts as
|
|
4
|
+
template tags, a form renderer that turns any Django form into GGDS markup with correct error handling, the GGDS
|
|
5
|
+
styles, themes and script as static files, and GGDS colours and header for Django admin. Django 5.0 or later. Works
|
|
6
|
+
with Wagtail and other Django-based CMSs.
|
|
7
|
+
|
|
8
|
+
**Documentation:** [ghana-gds.github.io/ggds](https://ghana-gds.github.io/ggds/) · [Use it with Django](https://ghana-gds.github.io/ggds/get-started/developers.html#django) · [Versions and support](https://ghana-gds.github.io/ggds/versions.html)
|
|
9
|
+
|
|
10
|
+
## Set up
|
|
11
|
+
|
|
12
|
+
```python
|
|
13
|
+
INSTALLED_APPS = [..., "django.contrib.staticfiles", "ggds_django"]
|
|
14
|
+
FORM_RENDERER = "ggds_django.forms.GGDSFormRenderer" # every form in GGDS markup
|
|
15
|
+
TEMPLATES = [{..., "OPTIONS": {"context_processors": [..., "django.template.context_processors.request"]}}]
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
To use GGDS for some forms only, leave `FORM_RENDERER` out and add `GGDSFormMixin` to those forms.
|
|
19
|
+
|
|
20
|
+
## A page
|
|
21
|
+
|
|
22
|
+
```django
|
|
23
|
+
{% load ggds %}<!doctype html>
|
|
24
|
+
<html lang="en-GB">
|
|
25
|
+
<head>
|
|
26
|
+
<meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
|
|
27
|
+
<title>{% ggds_error_title form "Make a complaint" %} | Example Agency</title>
|
|
28
|
+
{% ggds_assets theme="nca" %}
|
|
29
|
+
</head>
|
|
30
|
+
<body>
|
|
31
|
+
{% ggds_skip_link %}
|
|
32
|
+
{% ggds_banner short_name="NCA" host="nca.org.gh" official=is_official %}
|
|
33
|
+
{% ggds_header name="National Communications Authority" nav=nav %}
|
|
34
|
+
<main id="main" tabindex="-1" class="ggds-container ggds-main">
|
|
35
|
+
{% ggds_breadcrumbs crumbs %}
|
|
36
|
+
<h1>Make a complaint</h1>
|
|
37
|
+
<form method="post">{% csrf_token %}
|
|
38
|
+
{{ form }}
|
|
39
|
+
<button class="ggds-button">Send complaint</button>
|
|
40
|
+
</form>
|
|
41
|
+
</main>
|
|
42
|
+
{% ggds_footer name="National Communications Authority" sections=sections links=footer_links %}
|
|
43
|
+
{% ggds_tab_bar tabs %}
|
|
44
|
+
</body>
|
|
45
|
+
</html>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Links are dicts (`{"label": "Services", "href": "/services/"}`) or `("Services", "/services/")` pairs. The header
|
|
49
|
+
marks the section the page's address is in; the tab bar marks the current tab.
|
|
50
|
+
|
|
51
|
+
## Forms
|
|
52
|
+
|
|
53
|
+
With the renderer, `{{ form }}` shows an error summary after a failed submit (focused on load by the GGDS
|
|
54
|
+
script, each item linking to its field, a radio group's to its first option), then every field:
|
|
55
|
+
|
|
56
|
+
| Django widget | GGDS markup |
|
|
57
|
+
|---|---|
|
|
58
|
+
| Text, email, number, date… | `ggds-field` with label, hint (`help_text`), error and `ggds-input` |
|
|
59
|
+
| `Textarea`, `Select`, `FileInput` | the same with `ggds-textarea`, `ggds-select`, `ggds-file-upload` |
|
|
60
|
+
| `RadioSelect`, `CheckboxSelectMultiple` | a `ggds-fieldset` with a legend and `ggds-choices` |
|
|
61
|
+
| `CheckboxInput` | a single `ggds-choice` |
|
|
62
|
+
| `GGDSDateField` | a `ggds-fieldset` with day, month and year boxes (`ggds-date-input`) |
|
|
63
|
+
|
|
64
|
+
Each control gets `aria-describedby` (hint, then error) and, with an error, `aria-invalid="true"`. Errors start
|
|
65
|
+
with a hidden "Error:". Fields that are not required say "(optional)". Set `autocomplete` on personal details with
|
|
66
|
+
the widget's `attrs`. One field: `{{ form.phone.as_field_group }}`.
|
|
67
|
+
|
|
68
|
+
### Dates people know
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
from ggds_django.forms import GGDSDateField
|
|
72
|
+
|
|
73
|
+
class ApplicationForm(forms.Form):
|
|
74
|
+
date_of_birth = GGDSDateField(label="What is your date of birth?", name="date of birth", birthday=True,
|
|
75
|
+
help_text="For example, 27 3 1990")
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
`cleaned_data["date_of_birth"]` is a `datetime.date`. The month can be typed as 3, 03, March or Mar. Errors use
|
|
79
|
+
`name`: "Enter date of birth", "Date of birth must include a year", "Year must include 4 numbers", "Date of birth
|
|
80
|
+
must be a real date", and with `birthday=True` or `past=True`, "Date of birth must be in the past". Only the boxes
|
|
81
|
+
with the problem are marked invalid, and the error summary links to the first of them. `birthday=True` also adds
|
|
82
|
+
`autocomplete="bday-day"` and so on.
|
|
83
|
+
|
|
84
|
+
## Page parts
|
|
85
|
+
|
|
86
|
+
| Tag | |
|
|
87
|
+
|---|---|
|
|
88
|
+
| `{% ggds_assets theme="nca" %}` | Stylesheet, theme and optional script, in `<head>` |
|
|
89
|
+
| `{% ggds_skip_link %}` | First thing in `<body>` |
|
|
90
|
+
| `{% ggds_banner short_name host official %}` | Government website banner |
|
|
91
|
+
| `{% ggds_header name nav %}` | Logo or initials, name, sections, Search |
|
|
92
|
+
| `{% ggds_hero title purpose lede search_action tasks %}` | Homepage hero |
|
|
93
|
+
| `{% ggds_breadcrumbs crumbs %}` | Trail ending with the current page |
|
|
94
|
+
| `{% ggds_summary_list rows %}` | Check answers: rows of `{"key", "value", "href"}`; an empty value shows "Not given", and each Change link says what it changes. `plain=True` for no lines |
|
|
95
|
+
| `{% ggds_panel "Complaint sent" reference=ref %}` | Confirmation panel: the page's `<h1>` and the reference number |
|
|
96
|
+
| `{% ggds_pagination page_obj %}` | From Django's `Paginator`; keeps other query parameters |
|
|
97
|
+
| `{% ggds_footer name purpose address email phone sections links %}` | Footer |
|
|
98
|
+
| `{% ggds_tab_bar tabs %}` | Phone quick links: each tab has an `icon` |
|
|
99
|
+
| `{% ggds_error_summary form %}` | On its own, for forms you lay out yourself |
|
|
100
|
+
|
|
101
|
+
Everything else (buttons, notices, tags, cards, tables) is plain GGDS HTML: copy it from the documentation.
|
|
102
|
+
|
|
103
|
+
## Django admin
|
|
104
|
+
|
|
105
|
+
Admin keeps its own layout but takes GGDS's colours, type, focus style and header (the flag-colour rule and the
|
|
106
|
+
institution's logo or initials, name and country), from the GGDS tokens and your institution's theme:
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
INSTALLED_APPS = [..., "ggds_django", "ggds_django.admin_theme", "django.contrib.admin", ...] # above admin
|
|
110
|
+
GGDS_ADMIN = {
|
|
111
|
+
"theme": "nca", # a file in ggds/themes/, as for {% ggds_assets %}
|
|
112
|
+
"name": "National Communications Authority", # default: the admin site's site_header
|
|
113
|
+
"initials": "NCA", # or "logo_url" and "logo_alt"
|
|
114
|
+
"country": "Republic of Ghana", # the default; "" for none
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
It loads the tokens on their own (`ggds/tokens.css`), never the GGDS base styles, which would restyle admin's
|
|
119
|
+
elements. Admin is shown light only: the dark palette and the theme toggle are left out. `manage.py check` warns if
|
|
120
|
+
the app is below `django.contrib.admin`, a key is misspelt or the theme does not exist.
|
|
121
|
+
|
|
122
|
+
## Content added after load
|
|
123
|
+
|
|
124
|
+
HTMX, fetch or a script that adds a GGDS menu or error summary should call `initAll(element)` from the GGDS script
|
|
125
|
+
(`ggds/js/index.js`) on the new content.
|
|
126
|
+
|
|
127
|
+
## Develop
|
|
128
|
+
|
|
129
|
+
From the GGDS repository: `pnpm run build` copies the tokens, styles, themes, script and icons into the app;
|
|
130
|
+
`pnpm run test:django` runs the tests (including a check that the markup matches the GGDS documentation) and renders
|
|
131
|
+
an example site into the documentation build, where the accessibility tests check it.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Copies the built GGDS tokens, styles, themes and script into the Django app's static files, and the shared icons into
|
|
2
|
+
// icons.json, so the Django package serves exactly what the other GGDS packages do. Run after the CSS, theme and
|
|
3
|
+
// JavaScript builds (pnpm run build does).
|
|
4
|
+
import { cpSync, mkdirSync, rmSync, writeFileSync } from 'node:fs';
|
|
5
|
+
import { dirname, join } from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
import { ICONS } from '../astro/icons.mjs';
|
|
8
|
+
|
|
9
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
const app = join(here, 'src', 'ggds_django');
|
|
11
|
+
const out = join(app, 'static', 'ggds');
|
|
12
|
+
const packages = join(here, '..');
|
|
13
|
+
|
|
14
|
+
rmSync(out, { recursive: true, force: true });
|
|
15
|
+
mkdirSync(out, { recursive: true });
|
|
16
|
+
cpSync(join(packages, 'css', 'dist'), out, { recursive: true });
|
|
17
|
+
// The tokens on their own, with no element styles: for pages GGDS does not lay out, such as Django admin.
|
|
18
|
+
cpSync(join(packages, 'tokens', 'dist', 'tokens.css'), join(out, 'tokens.css'));
|
|
19
|
+
cpSync(join(packages, 'themes', 'dist'), join(out, 'themes'), { recursive: true, filter: (f) => !f.endsWith('.json') });
|
|
20
|
+
cpSync(join(packages, 'js', 'dist'), join(out, 'js'), { recursive: true, filter: (f) => !f.endsWith('.d.ts') });
|
|
21
|
+
writeFileSync(join(app, 'icons.json'), `${JSON.stringify(ICONS, null, 1)}\n`);
|
|
22
|
+
console.log(`django: static files and icons → ${app}`);
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"""Renders a small example site with ggds-django into the documentation build (site/django/), where the
|
|
2
|
+
accessibility, Content Security Policy and layout tests check it like every other page.
|
|
3
|
+
|
|
4
|
+
python demo/render.py <site directory>
|
|
5
|
+
"""
|
|
6
|
+
import shutil
|
|
7
|
+
import sys
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
import django
|
|
11
|
+
from django.conf import settings
|
|
12
|
+
|
|
13
|
+
HERE = Path(__file__).parent
|
|
14
|
+
settings.configure(
|
|
15
|
+
INSTALLED_APPS=["django.contrib.staticfiles", "ggds_django"],
|
|
16
|
+
TEMPLATES=[{"BACKEND": "django.template.backends.django.DjangoTemplates", "DIRS": [HERE / "templates"], "APP_DIRS": True,
|
|
17
|
+
"OPTIONS": {"context_processors": ["django.template.context_processors.request"]}}],
|
|
18
|
+
FORM_RENDERER="ggds_django.forms.GGDSFormRenderer",
|
|
19
|
+
STATIC_URL="/django/static/", # the example site is served from site/django/
|
|
20
|
+
ALLOWED_HOSTS=["*"],
|
|
21
|
+
)
|
|
22
|
+
django.setup()
|
|
23
|
+
|
|
24
|
+
from django import forms # noqa: E402
|
|
25
|
+
from django.core.paginator import Paginator # noqa: E402
|
|
26
|
+
from django.template.loader import render_to_string # noqa: E402
|
|
27
|
+
from django.test import RequestFactory # noqa: E402
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class ComplaintForm(forms.Form):
|
|
31
|
+
name = forms.CharField(label="Full name", help_text="As on your Ghana Card",
|
|
32
|
+
widget=forms.TextInput(attrs={"autocomplete": "name", "spellcheck": "false"}))
|
|
33
|
+
phone = forms.CharField(label="Phone number", help_text="We call or text you about this only",
|
|
34
|
+
widget=forms.TextInput(attrs={"type": "tel", "autocomplete": "tel"}))
|
|
35
|
+
email = forms.EmailField(label="Email address", required=False, widget=forms.EmailInput(attrs={"autocomplete": "email"}))
|
|
36
|
+
provider = forms.ChoiceField(label="Which provider is it about?", choices=[("", "Choose a provider"), ("a", "Provider A"), ("b", "Provider B")])
|
|
37
|
+
contact = forms.ChoiceField(label="How should we contact you?", widget=forms.RadioSelect,
|
|
38
|
+
choices=[("call", "Phone call"), ("sms", "SMS"), ("email", "Email")])
|
|
39
|
+
topics = forms.MultipleChoiceField(label="What is it about?", required=False, widget=forms.CheckboxSelectMultiple,
|
|
40
|
+
choices=[("net", "Internet"), ("calls", "Calls"), ("sms", "SMS")])
|
|
41
|
+
details = forms.CharField(label="What happened?", help_text="Include dates. Do not include your PIN or passwords.", widget=forms.Textarea(attrs={"rows": 5}))
|
|
42
|
+
agree = forms.BooleanField(label="I confirm the details are true")
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
NAV = [{"label": "Services", "href": "form.html"}, {"label": "Search", "href": "search.html"}, {"label": "About", "href": "index.html#main"}]
|
|
46
|
+
CONTEXT = {
|
|
47
|
+
"nav": NAV,
|
|
48
|
+
"tasks": [{"label": "Make a complaint", "href": "form.html"}, {"label": "See search results", "href": "search.html"}],
|
|
49
|
+
"sections": [{"label": "Services", "href": "form.html", "links": [{"label": "Make a complaint", "href": "form.html"}]},
|
|
50
|
+
{"label": "Search", "href": "search.html", "links": [{"label": "Search results", "href": "search.html"}]}],
|
|
51
|
+
"bar": [{"label": "Accessibility", "href": "index.html"}, {"label": "Privacy", "href": "index.html"}],
|
|
52
|
+
"tabs": [{"label": "Home", "href": "index.html", "icon": "home"}, {"label": "Services", "href": "form.html", "icon": "services"},
|
|
53
|
+
{"label": "Search", "href": "search.html", "icon": "search"}],
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def render(out: Path, name: str, template: str, path: str, **extra):
|
|
58
|
+
request = RequestFactory().get(path)
|
|
59
|
+
html = render_to_string(template, {**CONTEXT, **extra}, request=request)
|
|
60
|
+
(out / name).write_text(html)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def main(site: str):
|
|
64
|
+
out = Path(site) / "django"
|
|
65
|
+
shutil.rmtree(out, ignore_errors=True)
|
|
66
|
+
out.mkdir(parents=True)
|
|
67
|
+
shutil.copytree(HERE.parent / "src" / "ggds_django" / "static", out / "static")
|
|
68
|
+
crumbs = lambda label: [("Home", "index.html"), (label, "")] # noqa: E731
|
|
69
|
+
render(out, "index.html", "demo/index.html", "/", title="Home")
|
|
70
|
+
render(out, "form.html", "demo/form.html", "/services/", title="Make a complaint", form=ComplaintForm(), crumbs=crumbs("Make a complaint"))
|
|
71
|
+
bad = ComplaintForm(data={"email": "not-an-email", "provider": ""})
|
|
72
|
+
render(out, "form-errors.html", "demo/form.html", "/services/", title="Error: Make a complaint", form=bad, crumbs=crumbs("Make a complaint"))
|
|
73
|
+
page = Paginator(list(range(1, 101)), 10).page(5)
|
|
74
|
+
render(out, "search.html", "demo/list.html", "/search/?q=licence&page=5", title="Search results", page_obj=page, crumbs=crumbs("Search results"))
|
|
75
|
+
print(f"django: example site → {out}")
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
if __name__ == "__main__":
|
|
79
|
+
main(sys.argv[1])
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{% load ggds %}<!doctype html>
|
|
2
|
+
<html lang="en-GB">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
<title>{{ title }} | Example Agency (Django example)</title>
|
|
7
|
+
<meta name="robots" content="noindex, nofollow">
|
|
8
|
+
{% ggds_assets theme="nca" %}
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
{% ggds_skip_link %}
|
|
12
|
+
{% ggds_banner short_name="Example Agency" host="example.gov.gh" register_href="../register.html" %}
|
|
13
|
+
{% ggds_header name="Example Agency" nav=nav search_url="search.html" home="index.html" %}
|
|
14
|
+
<main id="main" tabindex="-1">
|
|
15
|
+
{% block hero %}{% endblock %}
|
|
16
|
+
<div class="ggds-container ggds-main">
|
|
17
|
+
{% block content %}{% endblock %}
|
|
18
|
+
</div>
|
|
19
|
+
</main>
|
|
20
|
+
{% ggds_footer name="Example Agency" purpose="An example site rendered by Django with ggds-django." sections=sections links=bar contact_url="form.html" %}
|
|
21
|
+
{% ggds_tab_bar tabs %}
|
|
22
|
+
</body>
|
|
23
|
+
</html>
|