django-nifty-layout 0.1.1__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_nifty_layout-0.1.1/LICENSE +21 -0
- django_nifty_layout-0.1.1/MANIFEST.in +12 -0
- django_nifty_layout-0.1.1/PKG-INFO +236 -0
- django_nifty_layout-0.1.1/README.md +175 -0
- django_nifty_layout-0.1.1/django_nifty_layout.egg-info/PKG-INFO +236 -0
- django_nifty_layout-0.1.1/django_nifty_layout.egg-info/SOURCES.txt +17 -0
- django_nifty_layout-0.1.1/django_nifty_layout.egg-info/dependency_links.txt +1 -0
- django_nifty_layout-0.1.1/django_nifty_layout.egg-info/entry_points.txt +2 -0
- django_nifty_layout-0.1.1/django_nifty_layout.egg-info/requires.txt +25 -0
- django_nifty_layout-0.1.1/django_nifty_layout.egg-info/top_level.txt +1 -0
- django_nifty_layout-0.1.1/nifty_layout/__init__.py +1 -0
- django_nifty_layout-0.1.1/nifty_layout/accessor.py +285 -0
- django_nifty_layout-0.1.1/nifty_layout/apps.py +5 -0
- django_nifty_layout-0.1.1/nifty_layout/components.py +382 -0
- django_nifty_layout-0.1.1/pyproject.toml +89 -0
- django_nifty_layout-0.1.1/setup.cfg +4 -0
- django_nifty_layout-0.1.1/tests/__init__.py +1 -0
- django_nifty_layout-0.1.1/tests/settings.py +15 -0
- django_nifty_layout-0.1.1/tests/test_components.py +95 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2025 Joseph
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
@@ -0,0 +1,12 @@
|
|
1
|
+
include README.md
|
2
|
+
include LICENSE
|
3
|
+
|
4
|
+
recursive-include tests *
|
5
|
+
recursive-include nifty_layout/templates *
|
6
|
+
recursive-include nifty_layout/static *
|
7
|
+
|
8
|
+
recursive-exclude docs *
|
9
|
+
recursive-exclude tasks *
|
10
|
+
|
11
|
+
recursive-exclude * __pycache__
|
12
|
+
recursive-exclude * *.py[cod]
|
@@ -0,0 +1,236 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: django-nifty-layout
|
3
|
+
Version: 0.1.1
|
4
|
+
Summary: A flexible data composition tool to simplify writing templates.
|
5
|
+
Author-email: J Fall <email@example.com>
|
6
|
+
License: MIT License
|
7
|
+
|
8
|
+
Copyright (c) 2025 Joseph
|
9
|
+
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
12
|
+
in the Software without restriction, including without limitation the rights
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
15
|
+
furnished to do so, subject to the following conditions:
|
16
|
+
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
18
|
+
copies or substantial portions of the Software.
|
19
|
+
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
26
|
+
SOFTWARE.
|
27
|
+
|
28
|
+
Project-URL: Homepage, https://github.com/powderflask/django-nifty-layout
|
29
|
+
Project-URL: Repository, https://github.com/powderflask/django-nifty-layout
|
30
|
+
Keywords: django-nifty-layout,nifty_layout
|
31
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
32
|
+
Classifier: License :: OSI Approved :: MIT License
|
33
|
+
Classifier: Intended Audience :: Developers
|
34
|
+
Classifier: Natural Language :: English
|
35
|
+
Classifier: Programming Language :: Python :: 3
|
36
|
+
Classifier: Framework :: Django
|
37
|
+
Requires-Python: <4.0,>=3.10
|
38
|
+
Description-Content-Type: text/markdown
|
39
|
+
License-File: LICENSE
|
40
|
+
Requires-Dist: django
|
41
|
+
Provides-Extra: format
|
42
|
+
Requires-Dist: black; extra == "format"
|
43
|
+
Requires-Dist: isort; extra == "format"
|
44
|
+
Provides-Extra: lint
|
45
|
+
Requires-Dist: flake8; extra == "lint"
|
46
|
+
Requires-Dist: flake8-bugbear; extra == "lint"
|
47
|
+
Provides-Extra: test
|
48
|
+
Requires-Dist: pytest; extra == "test"
|
49
|
+
Requires-Dist: pytest-django; extra == "test"
|
50
|
+
Requires-Dist: pytest-cov; extra == "test"
|
51
|
+
Requires-Dist: pytest-sugar; extra == "test"
|
52
|
+
Provides-Extra: utils
|
53
|
+
Requires-Dist: tox; extra == "utils"
|
54
|
+
Requires-Dist: invoke; extra == "utils"
|
55
|
+
Requires-Dist: bumpver; extra == "utils"
|
56
|
+
Requires-Dist: pip-tools; extra == "utils"
|
57
|
+
Provides-Extra: build
|
58
|
+
Requires-Dist: build; extra == "build"
|
59
|
+
Requires-Dist: twine; extra == "build"
|
60
|
+
Dynamic: license-file
|
61
|
+
|
62
|
+
# django-nifty-layout
|
63
|
+
|
64
|
+
[](https://pypi.python.org/pypi/django-nifty-layout)  [](https://github.com/powderflask/django-nifty-layout)
|
65
|
+
|
66
|
+
Version: 0.1.1
|
67
|
+
|
68
|
+
A simple but flexible layout tool for composing and transforming data for structured template components.
|
69
|
+
Inspired by `crispy-forms` Layout, but without the forms.
|
70
|
+
|
71
|
+
django-nifty-layout is free software distributed under the MIT License.
|
72
|
+
|
73
|
+
|
74
|
+
## Quick Start
|
75
|
+
|
76
|
+
1. Install the `django-nifty-layout` package from PyPI
|
77
|
+
```bash
|
78
|
+
$ pip install django-nifty-layout
|
79
|
+
```
|
80
|
+
|
81
|
+
2. Go grab a drink, you are all done!
|
82
|
+
|
83
|
+
|
84
|
+
## Sample Usage
|
85
|
+
layout.py
|
86
|
+
```
|
87
|
+
from django.utils.formats import date_format
|
88
|
+
|
89
|
+
from nifty_layout.components import (
|
90
|
+
DictCompositeNode as Dct,
|
91
|
+
FieldNode as Fld,
|
92
|
+
Seq,
|
93
|
+
)
|
94
|
+
|
95
|
+
# ----- Safe Date Formatter ----- #
|
96
|
+
date_formatter = lambda val: None if val is None else date_format(val, SHORT_DATE_FORMAT)
|
97
|
+
|
98
|
+
layout = Dct(
|
99
|
+
dict(
|
100
|
+
overview=Seq(
|
101
|
+
"title",
|
102
|
+
Fld("date", formatter=date_formatter),
|
103
|
+
report_type",
|
104
|
+
"location",
|
105
|
+
labeller="Overview",
|
106
|
+
),
|
107
|
+
contacts=Seq(
|
108
|
+
Dct(
|
109
|
+
dict(
|
110
|
+
name="contact_name",
|
111
|
+
contact_methods=Seq("contact_email"),
|
112
|
+
),
|
113
|
+
dict(
|
114
|
+
name="reported_by_name",
|
115
|
+
contact_methods=Seq("reported_by_phone_num", "reported_by_email"),
|
116
|
+
),
|
117
|
+
)
|
118
|
+
),
|
119
|
+
labeller="Contacts",
|
120
|
+
),
|
121
|
+
...
|
122
|
+
)
|
123
|
+
)
|
124
|
+
```
|
125
|
+
|
126
|
+
views.py
|
127
|
+
```
|
128
|
+
def report_view(request, pk):
|
129
|
+
...
|
130
|
+
obj = Report.objects.get(pk=pk)
|
131
|
+
...
|
132
|
+
return render(request, "template.html", dict(report=layout.bind(obj)))
|
133
|
+
```
|
134
|
+
|
135
|
+
template.html
|
136
|
+
```
|
137
|
+
...
|
138
|
+
<div class="report>
|
139
|
+
<h2>report.overview.label</h2>
|
140
|
+
{% for node in report.overview.children %}
|
141
|
+
<div class="row">
|
142
|
+
<div class="col label">{{ node.label }}</div>
|
143
|
+
<div class="col value">{{ node.value|default:"" }}</div>
|
144
|
+
{% endfor %}
|
145
|
+
</div>
|
146
|
+
{% endfor %}
|
147
|
+
<div class="row">
|
148
|
+
{% for contact in report.contacts.children %}
|
149
|
+
<div class="col">
|
150
|
+
{% include "contact_card.html" %}
|
151
|
+
</div>
|
152
|
+
{% endfor %}
|
153
|
+
</div>
|
154
|
+
...
|
155
|
+
</div>
|
156
|
+
```
|
157
|
+
|
158
|
+
## Get Me Some of That
|
159
|
+
* [Source Code](https://github.com/powderflask/django-nifty-layout)
|
160
|
+
|
161
|
+
* [Issues](https://github.com/powderflask/django-nifty-layout/issues)
|
162
|
+
* [PyPI](https://pypi.org/project/django-nifty-layout)
|
163
|
+
|
164
|
+
[MIT License](https://github.com/powderflask/django-nifty-layout/blob/master/LICENSE)
|
165
|
+
|
166
|
+
### Check Out the Demo App ** coming soon **
|
167
|
+
|
168
|
+
1. `pip install -e git+https://github.com/powderflask/django-nifty-layout.git#egg=django-nifty-layout`
|
169
|
+
1. `python django-nifty-layout/manage.py install_demo`
|
170
|
+
1. `python django-nifty-layout/manage.py runserver`
|
171
|
+
|
172
|
+
|
173
|
+
### Acknowledgments
|
174
|
+
This project would be impossible to maintain without the help of our generous [contributors](https://github.com/powderflask/django-nifty-layout/graphs/contributors)
|
175
|
+
|
176
|
+
#### Technology Colophon
|
177
|
+
|
178
|
+
Without django and the django dev team, the universe would have fewer rainbows and ponies.
|
179
|
+
|
180
|
+
This package was originally created with [`cookiecutter`](https://www.cookiecutter.io/)
|
181
|
+
and the [`cookiecutter-powder-pypackage`](https://github.com/JacobTumak/CookiePowder) project template.
|
182
|
+
|
183
|
+
|
184
|
+
## For Developers
|
185
|
+
Install `invoke`, `pip-tools`, `tox` for all the CLI goodness
|
186
|
+
```bash
|
187
|
+
pip install invoke pip-tools tox
|
188
|
+
```
|
189
|
+
|
190
|
+
Initialise the development environment using the invoke task
|
191
|
+
```bash
|
192
|
+
inv tox.venv
|
193
|
+
```
|
194
|
+
Or create it with tox directly
|
195
|
+
```bash
|
196
|
+
tox d -e dev .venv
|
197
|
+
```
|
198
|
+
Or build and install the dev requirements with pip
|
199
|
+
```bash
|
200
|
+
inv deps.compile-dev
|
201
|
+
pip install -r requirements_dev.txt
|
202
|
+
```
|
203
|
+
|
204
|
+
### Tests
|
205
|
+
```bash
|
206
|
+
pytest
|
207
|
+
```
|
208
|
+
or
|
209
|
+
```bash
|
210
|
+
tox r
|
211
|
+
```
|
212
|
+
or run tox environments in parallel using
|
213
|
+
```bash
|
214
|
+
tox p
|
215
|
+
```
|
216
|
+
|
217
|
+
### Code Style / Linting
|
218
|
+
```bash
|
219
|
+
$ isort
|
220
|
+
$ black
|
221
|
+
$ flake8
|
222
|
+
```
|
223
|
+
|
224
|
+
### Versioning
|
225
|
+
* [Semantic Versioning](https://semver.org/)
|
226
|
+
```bash
|
227
|
+
$ bumpver show
|
228
|
+
```
|
229
|
+
|
230
|
+
### Build / Deploy Automation
|
231
|
+
* [invoke](https://www.pyinvoke.org/)
|
232
|
+
```bash
|
233
|
+
$ invoke -l
|
234
|
+
```
|
235
|
+
* [GitHub Actions](https://docs.github.com/en/actions) (see [.github/workflows](https://github.com/powderflask/django-nifty-layout/tree/master/.github/workflows))
|
236
|
+
* [GitHub Webhooks](https://docs.github.com/en/webhooks) (see [settings/hooks](https://github.com/powderflask/django-nifty-layout/settings/hooks))
|
@@ -0,0 +1,175 @@
|
|
1
|
+
# django-nifty-layout
|
2
|
+
|
3
|
+
[](https://pypi.python.org/pypi/django-nifty-layout)  [](https://github.com/powderflask/django-nifty-layout)
|
4
|
+
|
5
|
+
Version: 0.1.1
|
6
|
+
|
7
|
+
A simple but flexible layout tool for composing and transforming data for structured template components.
|
8
|
+
Inspired by `crispy-forms` Layout, but without the forms.
|
9
|
+
|
10
|
+
django-nifty-layout is free software distributed under the MIT License.
|
11
|
+
|
12
|
+
|
13
|
+
## Quick Start
|
14
|
+
|
15
|
+
1. Install the `django-nifty-layout` package from PyPI
|
16
|
+
```bash
|
17
|
+
$ pip install django-nifty-layout
|
18
|
+
```
|
19
|
+
|
20
|
+
2. Go grab a drink, you are all done!
|
21
|
+
|
22
|
+
|
23
|
+
## Sample Usage
|
24
|
+
layout.py
|
25
|
+
```
|
26
|
+
from django.utils.formats import date_format
|
27
|
+
|
28
|
+
from nifty_layout.components import (
|
29
|
+
DictCompositeNode as Dct,
|
30
|
+
FieldNode as Fld,
|
31
|
+
Seq,
|
32
|
+
)
|
33
|
+
|
34
|
+
# ----- Safe Date Formatter ----- #
|
35
|
+
date_formatter = lambda val: None if val is None else date_format(val, SHORT_DATE_FORMAT)
|
36
|
+
|
37
|
+
layout = Dct(
|
38
|
+
dict(
|
39
|
+
overview=Seq(
|
40
|
+
"title",
|
41
|
+
Fld("date", formatter=date_formatter),
|
42
|
+
report_type",
|
43
|
+
"location",
|
44
|
+
labeller="Overview",
|
45
|
+
),
|
46
|
+
contacts=Seq(
|
47
|
+
Dct(
|
48
|
+
dict(
|
49
|
+
name="contact_name",
|
50
|
+
contact_methods=Seq("contact_email"),
|
51
|
+
),
|
52
|
+
dict(
|
53
|
+
name="reported_by_name",
|
54
|
+
contact_methods=Seq("reported_by_phone_num", "reported_by_email"),
|
55
|
+
),
|
56
|
+
)
|
57
|
+
),
|
58
|
+
labeller="Contacts",
|
59
|
+
),
|
60
|
+
...
|
61
|
+
)
|
62
|
+
)
|
63
|
+
```
|
64
|
+
|
65
|
+
views.py
|
66
|
+
```
|
67
|
+
def report_view(request, pk):
|
68
|
+
...
|
69
|
+
obj = Report.objects.get(pk=pk)
|
70
|
+
...
|
71
|
+
return render(request, "template.html", dict(report=layout.bind(obj)))
|
72
|
+
```
|
73
|
+
|
74
|
+
template.html
|
75
|
+
```
|
76
|
+
...
|
77
|
+
<div class="report>
|
78
|
+
<h2>report.overview.label</h2>
|
79
|
+
{% for node in report.overview.children %}
|
80
|
+
<div class="row">
|
81
|
+
<div class="col label">{{ node.label }}</div>
|
82
|
+
<div class="col value">{{ node.value|default:"" }}</div>
|
83
|
+
{% endfor %}
|
84
|
+
</div>
|
85
|
+
{% endfor %}
|
86
|
+
<div class="row">
|
87
|
+
{% for contact in report.contacts.children %}
|
88
|
+
<div class="col">
|
89
|
+
{% include "contact_card.html" %}
|
90
|
+
</div>
|
91
|
+
{% endfor %}
|
92
|
+
</div>
|
93
|
+
...
|
94
|
+
</div>
|
95
|
+
```
|
96
|
+
|
97
|
+
## Get Me Some of That
|
98
|
+
* [Source Code](https://github.com/powderflask/django-nifty-layout)
|
99
|
+
|
100
|
+
* [Issues](https://github.com/powderflask/django-nifty-layout/issues)
|
101
|
+
* [PyPI](https://pypi.org/project/django-nifty-layout)
|
102
|
+
|
103
|
+
[MIT License](https://github.com/powderflask/django-nifty-layout/blob/master/LICENSE)
|
104
|
+
|
105
|
+
### Check Out the Demo App ** coming soon **
|
106
|
+
|
107
|
+
1. `pip install -e git+https://github.com/powderflask/django-nifty-layout.git#egg=django-nifty-layout`
|
108
|
+
1. `python django-nifty-layout/manage.py install_demo`
|
109
|
+
1. `python django-nifty-layout/manage.py runserver`
|
110
|
+
|
111
|
+
|
112
|
+
### Acknowledgments
|
113
|
+
This project would be impossible to maintain without the help of our generous [contributors](https://github.com/powderflask/django-nifty-layout/graphs/contributors)
|
114
|
+
|
115
|
+
#### Technology Colophon
|
116
|
+
|
117
|
+
Without django and the django dev team, the universe would have fewer rainbows and ponies.
|
118
|
+
|
119
|
+
This package was originally created with [`cookiecutter`](https://www.cookiecutter.io/)
|
120
|
+
and the [`cookiecutter-powder-pypackage`](https://github.com/JacobTumak/CookiePowder) project template.
|
121
|
+
|
122
|
+
|
123
|
+
## For Developers
|
124
|
+
Install `invoke`, `pip-tools`, `tox` for all the CLI goodness
|
125
|
+
```bash
|
126
|
+
pip install invoke pip-tools tox
|
127
|
+
```
|
128
|
+
|
129
|
+
Initialise the development environment using the invoke task
|
130
|
+
```bash
|
131
|
+
inv tox.venv
|
132
|
+
```
|
133
|
+
Or create it with tox directly
|
134
|
+
```bash
|
135
|
+
tox d -e dev .venv
|
136
|
+
```
|
137
|
+
Or build and install the dev requirements with pip
|
138
|
+
```bash
|
139
|
+
inv deps.compile-dev
|
140
|
+
pip install -r requirements_dev.txt
|
141
|
+
```
|
142
|
+
|
143
|
+
### Tests
|
144
|
+
```bash
|
145
|
+
pytest
|
146
|
+
```
|
147
|
+
or
|
148
|
+
```bash
|
149
|
+
tox r
|
150
|
+
```
|
151
|
+
or run tox environments in parallel using
|
152
|
+
```bash
|
153
|
+
tox p
|
154
|
+
```
|
155
|
+
|
156
|
+
### Code Style / Linting
|
157
|
+
```bash
|
158
|
+
$ isort
|
159
|
+
$ black
|
160
|
+
$ flake8
|
161
|
+
```
|
162
|
+
|
163
|
+
### Versioning
|
164
|
+
* [Semantic Versioning](https://semver.org/)
|
165
|
+
```bash
|
166
|
+
$ bumpver show
|
167
|
+
```
|
168
|
+
|
169
|
+
### Build / Deploy Automation
|
170
|
+
* [invoke](https://www.pyinvoke.org/)
|
171
|
+
```bash
|
172
|
+
$ invoke -l
|
173
|
+
```
|
174
|
+
* [GitHub Actions](https://docs.github.com/en/actions) (see [.github/workflows](https://github.com/powderflask/django-nifty-layout/tree/master/.github/workflows))
|
175
|
+
* [GitHub Webhooks](https://docs.github.com/en/webhooks) (see [settings/hooks](https://github.com/powderflask/django-nifty-layout/settings/hooks))
|
@@ -0,0 +1,236 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: django-nifty-layout
|
3
|
+
Version: 0.1.1
|
4
|
+
Summary: A flexible data composition tool to simplify writing templates.
|
5
|
+
Author-email: J Fall <email@example.com>
|
6
|
+
License: MIT License
|
7
|
+
|
8
|
+
Copyright (c) 2025 Joseph
|
9
|
+
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
12
|
+
in the Software without restriction, including without limitation the rights
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
15
|
+
furnished to do so, subject to the following conditions:
|
16
|
+
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
18
|
+
copies or substantial portions of the Software.
|
19
|
+
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
26
|
+
SOFTWARE.
|
27
|
+
|
28
|
+
Project-URL: Homepage, https://github.com/powderflask/django-nifty-layout
|
29
|
+
Project-URL: Repository, https://github.com/powderflask/django-nifty-layout
|
30
|
+
Keywords: django-nifty-layout,nifty_layout
|
31
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
32
|
+
Classifier: License :: OSI Approved :: MIT License
|
33
|
+
Classifier: Intended Audience :: Developers
|
34
|
+
Classifier: Natural Language :: English
|
35
|
+
Classifier: Programming Language :: Python :: 3
|
36
|
+
Classifier: Framework :: Django
|
37
|
+
Requires-Python: <4.0,>=3.10
|
38
|
+
Description-Content-Type: text/markdown
|
39
|
+
License-File: LICENSE
|
40
|
+
Requires-Dist: django
|
41
|
+
Provides-Extra: format
|
42
|
+
Requires-Dist: black; extra == "format"
|
43
|
+
Requires-Dist: isort; extra == "format"
|
44
|
+
Provides-Extra: lint
|
45
|
+
Requires-Dist: flake8; extra == "lint"
|
46
|
+
Requires-Dist: flake8-bugbear; extra == "lint"
|
47
|
+
Provides-Extra: test
|
48
|
+
Requires-Dist: pytest; extra == "test"
|
49
|
+
Requires-Dist: pytest-django; extra == "test"
|
50
|
+
Requires-Dist: pytest-cov; extra == "test"
|
51
|
+
Requires-Dist: pytest-sugar; extra == "test"
|
52
|
+
Provides-Extra: utils
|
53
|
+
Requires-Dist: tox; extra == "utils"
|
54
|
+
Requires-Dist: invoke; extra == "utils"
|
55
|
+
Requires-Dist: bumpver; extra == "utils"
|
56
|
+
Requires-Dist: pip-tools; extra == "utils"
|
57
|
+
Provides-Extra: build
|
58
|
+
Requires-Dist: build; extra == "build"
|
59
|
+
Requires-Dist: twine; extra == "build"
|
60
|
+
Dynamic: license-file
|
61
|
+
|
62
|
+
# django-nifty-layout
|
63
|
+
|
64
|
+
[](https://pypi.python.org/pypi/django-nifty-layout)  [](https://github.com/powderflask/django-nifty-layout)
|
65
|
+
|
66
|
+
Version: 0.1.1
|
67
|
+
|
68
|
+
A simple but flexible layout tool for composing and transforming data for structured template components.
|
69
|
+
Inspired by `crispy-forms` Layout, but without the forms.
|
70
|
+
|
71
|
+
django-nifty-layout is free software distributed under the MIT License.
|
72
|
+
|
73
|
+
|
74
|
+
## Quick Start
|
75
|
+
|
76
|
+
1. Install the `django-nifty-layout` package from PyPI
|
77
|
+
```bash
|
78
|
+
$ pip install django-nifty-layout
|
79
|
+
```
|
80
|
+
|
81
|
+
2. Go grab a drink, you are all done!
|
82
|
+
|
83
|
+
|
84
|
+
## Sample Usage
|
85
|
+
layout.py
|
86
|
+
```
|
87
|
+
from django.utils.formats import date_format
|
88
|
+
|
89
|
+
from nifty_layout.components import (
|
90
|
+
DictCompositeNode as Dct,
|
91
|
+
FieldNode as Fld,
|
92
|
+
Seq,
|
93
|
+
)
|
94
|
+
|
95
|
+
# ----- Safe Date Formatter ----- #
|
96
|
+
date_formatter = lambda val: None if val is None else date_format(val, SHORT_DATE_FORMAT)
|
97
|
+
|
98
|
+
layout = Dct(
|
99
|
+
dict(
|
100
|
+
overview=Seq(
|
101
|
+
"title",
|
102
|
+
Fld("date", formatter=date_formatter),
|
103
|
+
report_type",
|
104
|
+
"location",
|
105
|
+
labeller="Overview",
|
106
|
+
),
|
107
|
+
contacts=Seq(
|
108
|
+
Dct(
|
109
|
+
dict(
|
110
|
+
name="contact_name",
|
111
|
+
contact_methods=Seq("contact_email"),
|
112
|
+
),
|
113
|
+
dict(
|
114
|
+
name="reported_by_name",
|
115
|
+
contact_methods=Seq("reported_by_phone_num", "reported_by_email"),
|
116
|
+
),
|
117
|
+
)
|
118
|
+
),
|
119
|
+
labeller="Contacts",
|
120
|
+
),
|
121
|
+
...
|
122
|
+
)
|
123
|
+
)
|
124
|
+
```
|
125
|
+
|
126
|
+
views.py
|
127
|
+
```
|
128
|
+
def report_view(request, pk):
|
129
|
+
...
|
130
|
+
obj = Report.objects.get(pk=pk)
|
131
|
+
...
|
132
|
+
return render(request, "template.html", dict(report=layout.bind(obj)))
|
133
|
+
```
|
134
|
+
|
135
|
+
template.html
|
136
|
+
```
|
137
|
+
...
|
138
|
+
<div class="report>
|
139
|
+
<h2>report.overview.label</h2>
|
140
|
+
{% for node in report.overview.children %}
|
141
|
+
<div class="row">
|
142
|
+
<div class="col label">{{ node.label }}</div>
|
143
|
+
<div class="col value">{{ node.value|default:"" }}</div>
|
144
|
+
{% endfor %}
|
145
|
+
</div>
|
146
|
+
{% endfor %}
|
147
|
+
<div class="row">
|
148
|
+
{% for contact in report.contacts.children %}
|
149
|
+
<div class="col">
|
150
|
+
{% include "contact_card.html" %}
|
151
|
+
</div>
|
152
|
+
{% endfor %}
|
153
|
+
</div>
|
154
|
+
...
|
155
|
+
</div>
|
156
|
+
```
|
157
|
+
|
158
|
+
## Get Me Some of That
|
159
|
+
* [Source Code](https://github.com/powderflask/django-nifty-layout)
|
160
|
+
|
161
|
+
* [Issues](https://github.com/powderflask/django-nifty-layout/issues)
|
162
|
+
* [PyPI](https://pypi.org/project/django-nifty-layout)
|
163
|
+
|
164
|
+
[MIT License](https://github.com/powderflask/django-nifty-layout/blob/master/LICENSE)
|
165
|
+
|
166
|
+
### Check Out the Demo App ** coming soon **
|
167
|
+
|
168
|
+
1. `pip install -e git+https://github.com/powderflask/django-nifty-layout.git#egg=django-nifty-layout`
|
169
|
+
1. `python django-nifty-layout/manage.py install_demo`
|
170
|
+
1. `python django-nifty-layout/manage.py runserver`
|
171
|
+
|
172
|
+
|
173
|
+
### Acknowledgments
|
174
|
+
This project would be impossible to maintain without the help of our generous [contributors](https://github.com/powderflask/django-nifty-layout/graphs/contributors)
|
175
|
+
|
176
|
+
#### Technology Colophon
|
177
|
+
|
178
|
+
Without django and the django dev team, the universe would have fewer rainbows and ponies.
|
179
|
+
|
180
|
+
This package was originally created with [`cookiecutter`](https://www.cookiecutter.io/)
|
181
|
+
and the [`cookiecutter-powder-pypackage`](https://github.com/JacobTumak/CookiePowder) project template.
|
182
|
+
|
183
|
+
|
184
|
+
## For Developers
|
185
|
+
Install `invoke`, `pip-tools`, `tox` for all the CLI goodness
|
186
|
+
```bash
|
187
|
+
pip install invoke pip-tools tox
|
188
|
+
```
|
189
|
+
|
190
|
+
Initialise the development environment using the invoke task
|
191
|
+
```bash
|
192
|
+
inv tox.venv
|
193
|
+
```
|
194
|
+
Or create it with tox directly
|
195
|
+
```bash
|
196
|
+
tox d -e dev .venv
|
197
|
+
```
|
198
|
+
Or build and install the dev requirements with pip
|
199
|
+
```bash
|
200
|
+
inv deps.compile-dev
|
201
|
+
pip install -r requirements_dev.txt
|
202
|
+
```
|
203
|
+
|
204
|
+
### Tests
|
205
|
+
```bash
|
206
|
+
pytest
|
207
|
+
```
|
208
|
+
or
|
209
|
+
```bash
|
210
|
+
tox r
|
211
|
+
```
|
212
|
+
or run tox environments in parallel using
|
213
|
+
```bash
|
214
|
+
tox p
|
215
|
+
```
|
216
|
+
|
217
|
+
### Code Style / Linting
|
218
|
+
```bash
|
219
|
+
$ isort
|
220
|
+
$ black
|
221
|
+
$ flake8
|
222
|
+
```
|
223
|
+
|
224
|
+
### Versioning
|
225
|
+
* [Semantic Versioning](https://semver.org/)
|
226
|
+
```bash
|
227
|
+
$ bumpver show
|
228
|
+
```
|
229
|
+
|
230
|
+
### Build / Deploy Automation
|
231
|
+
* [invoke](https://www.pyinvoke.org/)
|
232
|
+
```bash
|
233
|
+
$ invoke -l
|
234
|
+
```
|
235
|
+
* [GitHub Actions](https://docs.github.com/en/actions) (see [.github/workflows](https://github.com/powderflask/django-nifty-layout/tree/master/.github/workflows))
|
236
|
+
* [GitHub Webhooks](https://docs.github.com/en/webhooks) (see [settings/hooks](https://github.com/powderflask/django-nifty-layout/settings/hooks))
|
@@ -0,0 +1,17 @@
|
|
1
|
+
LICENSE
|
2
|
+
MANIFEST.in
|
3
|
+
README.md
|
4
|
+
pyproject.toml
|
5
|
+
django_nifty_layout.egg-info/PKG-INFO
|
6
|
+
django_nifty_layout.egg-info/SOURCES.txt
|
7
|
+
django_nifty_layout.egg-info/dependency_links.txt
|
8
|
+
django_nifty_layout.egg-info/entry_points.txt
|
9
|
+
django_nifty_layout.egg-info/requires.txt
|
10
|
+
django_nifty_layout.egg-info/top_level.txt
|
11
|
+
nifty_layout/__init__.py
|
12
|
+
nifty_layout/accessor.py
|
13
|
+
nifty_layout/apps.py
|
14
|
+
nifty_layout/components.py
|
15
|
+
tests/__init__.py
|
16
|
+
tests/settings.py
|
17
|
+
tests/test_components.py
|
@@ -0,0 +1 @@
|
|
1
|
+
|