plain.admin 0.14.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.
Files changed (86) hide show
  1. plain_admin-0.14.1/.gitignore +16 -0
  2. plain_admin-0.14.1/LICENSE +28 -0
  3. plain_admin-0.14.1/PKG-INFO +275 -0
  4. plain_admin-0.14.1/README.md +1 -0
  5. plain_admin-0.14.1/plain/admin/README.md +260 -0
  6. plain_admin-0.14.1/plain/admin/__init__.py +5 -0
  7. plain_admin-0.14.1/plain/admin/assets/admin/admin.css +108 -0
  8. plain_admin-0.14.1/plain/admin/assets/admin/admin.js +79 -0
  9. plain_admin-0.14.1/plain/admin/assets/admin/chart.js +19 -0
  10. plain_admin-0.14.1/plain/admin/assets/admin/jquery-3.6.1.slim.min.js +2 -0
  11. plain_admin-0.14.1/plain/admin/assets/admin/list.js +57 -0
  12. plain_admin-0.14.1/plain/admin/assets/admin/popper.min.js +5 -0
  13. plain_admin-0.14.1/plain/admin/assets/admin/tippy-bundle.umd.min.js +1 -0
  14. plain_admin-0.14.1/plain/admin/assets/toolbar/toolbar.js +51 -0
  15. plain_admin-0.14.1/plain/admin/cards/__init__.py +10 -0
  16. plain_admin-0.14.1/plain/admin/cards/base.py +86 -0
  17. plain_admin-0.14.1/plain/admin/cards/charts.py +153 -0
  18. plain_admin-0.14.1/plain/admin/cards/tables.py +26 -0
  19. plain_admin-0.14.1/plain/admin/config.py +21 -0
  20. plain_admin-0.14.1/plain/admin/dates.py +254 -0
  21. plain_admin-0.14.1/plain/admin/default_settings.py +4 -0
  22. plain_admin-0.14.1/plain/admin/impersonate/README.md +44 -0
  23. plain_admin-0.14.1/plain/admin/impersonate/__init__.py +3 -0
  24. plain_admin-0.14.1/plain/admin/impersonate/middleware.py +38 -0
  25. plain_admin-0.14.1/plain/admin/impersonate/models.py +0 -0
  26. plain_admin-0.14.1/plain/admin/impersonate/permissions.py +16 -0
  27. plain_admin-0.14.1/plain/admin/impersonate/settings.py +8 -0
  28. plain_admin-0.14.1/plain/admin/impersonate/urls.py +10 -0
  29. plain_admin-0.14.1/plain/admin/impersonate/views.py +23 -0
  30. plain_admin-0.14.1/plain/admin/middleware.py +12 -0
  31. plain_admin-0.14.1/plain/admin/querystats/README.md +191 -0
  32. plain_admin-0.14.1/plain/admin/querystats/__init__.py +3 -0
  33. plain_admin-0.14.1/plain/admin/querystats/core.py +153 -0
  34. plain_admin-0.14.1/plain/admin/querystats/middleware.py +99 -0
  35. plain_admin-0.14.1/plain/admin/querystats/urls.py +9 -0
  36. plain_admin-0.14.1/plain/admin/querystats/views.py +27 -0
  37. plain_admin-0.14.1/plain/admin/templates/admin/base.html +160 -0
  38. plain_admin-0.14.1/plain/admin/templates/admin/cards/base.html +30 -0
  39. plain_admin-0.14.1/plain/admin/templates/admin/cards/card.html +17 -0
  40. plain_admin-0.14.1/plain/admin/templates/admin/cards/chart.html +25 -0
  41. plain_admin-0.14.1/plain/admin/templates/admin/cards/table.html +35 -0
  42. plain_admin-0.14.1/plain/admin/templates/admin/delete.html +17 -0
  43. plain_admin-0.14.1/plain/admin/templates/admin/detail.html +24 -0
  44. plain_admin-0.14.1/plain/admin/templates/admin/form.html +13 -0
  45. plain_admin-0.14.1/plain/admin/templates/admin/index.html +5 -0
  46. plain_admin-0.14.1/plain/admin/templates/admin/list.html +194 -0
  47. plain_admin-0.14.1/plain/admin/templates/admin/page.html +3 -0
  48. plain_admin-0.14.1/plain/admin/templates/admin/search.html +27 -0
  49. plain_admin-0.14.1/plain/admin/templates/admin/values/UUID.html +1 -0
  50. plain_admin-0.14.1/plain/admin/templates/admin/values/bool.html +9 -0
  51. plain_admin-0.14.1/plain/admin/templates/admin/values/datetime.html +1 -0
  52. plain_admin-0.14.1/plain/admin/templates/admin/values/default.html +5 -0
  53. plain_admin-0.14.1/plain/admin/templates/admin/values/dict.html +1 -0
  54. plain_admin-0.14.1/plain/admin/templates/admin/values/get_display.html +1 -0
  55. plain_admin-0.14.1/plain/admin/templates/admin/values/img.html +4 -0
  56. plain_admin-0.14.1/plain/admin/templates/admin/values/list.html +1 -0
  57. plain_admin-0.14.1/plain/admin/templates/admin/values/model.html +15 -0
  58. plain_admin-0.14.1/plain/admin/templates/admin/values/queryset.html +7 -0
  59. plain_admin-0.14.1/plain/admin/templates/elements/admin/Checkbox.html +8 -0
  60. plain_admin-0.14.1/plain/admin/templates/elements/admin/CheckboxField.html +7 -0
  61. plain_admin-0.14.1/plain/admin/templates/elements/admin/FieldErrors.html +5 -0
  62. plain_admin-0.14.1/plain/admin/templates/elements/admin/Input.html +9 -0
  63. plain_admin-0.14.1/plain/admin/templates/elements/admin/InputField.html +5 -0
  64. plain_admin-0.14.1/plain/admin/templates/elements/admin/Label.html +3 -0
  65. plain_admin-0.14.1/plain/admin/templates/elements/admin/Select.html +11 -0
  66. plain_admin-0.14.1/plain/admin/templates/elements/admin/SelectField.html +5 -0
  67. plain_admin-0.14.1/plain/admin/templates/elements/admin/Submit.html +6 -0
  68. plain_admin-0.14.1/plain/admin/templates/querystats/querystats.html +78 -0
  69. plain_admin-0.14.1/plain/admin/templates/querystats/toolbar.html +79 -0
  70. plain_admin-0.14.1/plain/admin/templates/toolbar/toolbar.html +91 -0
  71. plain_admin-0.14.1/plain/admin/templates.py +25 -0
  72. plain_admin-0.14.1/plain/admin/toolbar.py +36 -0
  73. plain_admin-0.14.1/plain/admin/urls.py +45 -0
  74. plain_admin-0.14.1/plain/admin/views/__init__.py +41 -0
  75. plain_admin-0.14.1/plain/admin/views/base.py +140 -0
  76. plain_admin-0.14.1/plain/admin/views/models.py +254 -0
  77. plain_admin-0.14.1/plain/admin/views/objects.py +399 -0
  78. plain_admin-0.14.1/plain/admin/views/registry.py +117 -0
  79. plain_admin-0.14.1/plain/admin/views/types.py +6 -0
  80. plain_admin-0.14.1/plain/admin/views/viewsets.py +54 -0
  81. plain_admin-0.14.1/pyproject.toml +31 -0
  82. plain_admin-0.14.1/tests/app/settings.py +23 -0
  83. plain_admin-0.14.1/tests/app/urls.py +22 -0
  84. plain_admin-0.14.1/tests/app/users/models.py +6 -0
  85. plain_admin-0.14.1/tests/test_admin.py +18 -0
  86. plain_admin-0.14.1/uv.lock +378 -0
@@ -0,0 +1,16 @@
1
+ .venv
2
+ .env
3
+ *.egg-info
4
+ *.py[co]
5
+ __pycache__
6
+ *.DS_Store
7
+ .coverage
8
+
9
+ # Build files from publish
10
+ plain*/dist/
11
+
12
+ # Test apps
13
+ plain*/tests/.plain
14
+
15
+ # Ottobot
16
+ .aider*
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2023, Dropseed, LLC
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,275 @@
1
+ Metadata-Version: 2.4
2
+ Name: plain.admin
3
+ Version: 0.14.1
4
+ Summary: Admin dashboard and tools for Plain.
5
+ Author-email: Dave Gaeddert <dave.gaeddert@dropseed.dev>
6
+ License-Expression: BSD-3-Clause
7
+ License-File: LICENSE
8
+ Requires-Python: >=3.11
9
+ Requires-Dist: plain-auth<1.0.0
10
+ Requires-Dist: plain-htmx<1.0.0
11
+ Requires-Dist: plain-tailwind<1.0.0
12
+ Requires-Dist: plain<1.0.0
13
+ Requires-Dist: sqlparse>=0.2.2
14
+ Description-Content-Type: text/markdown
15
+
16
+ # Admin
17
+
18
+ An admin interface for admin users.
19
+
20
+ The Plain Admin is a new package built from the ground up.
21
+ It leverages class-based views and standard URLs and templates to provide a flexible admin where
22
+ you can quickly create your own pages and cards,
23
+ in addition to models.
24
+
25
+ - cards
26
+ - dashboards
27
+ - diy forms
28
+ - detached from login (do your own login (oauth, passkeys, etc))
29
+
30
+ ## Installation
31
+
32
+ - install plain.admin and plain.htmx, add plain.admin.admin and plain.htmx to installed packages
33
+ - add url
34
+
35
+ ## Models in the admin
36
+
37
+ ## Dashboards
38
+
39
+ <!-- # plain.querystats
40
+
41
+ On-page database query stats in development and production.
42
+
43
+ On each page, the query stats will display how many database queries were performed and how long they took.
44
+
45
+ [Watch on YouTube](https://www.youtube.com/watch?v=NX8VXxVJm08)
46
+
47
+ Clicking the stats in the toolbar will show the full SQL query log with tracebacks and timings.
48
+ This is even designed to work in production,
49
+ making it much easier to discover and debug performance issues on production data!
50
+
51
+ ![Django query stats](https://user-images.githubusercontent.com/649496/213781593-54197bb6-36a8-4c9d-8294-5b43bd86a4c9.png)
52
+
53
+ It will also point out duplicate queries,
54
+ which can typically be removed by using `select_related`,
55
+ `prefetch_related`, or otherwise refactoring your code.
56
+
57
+ ## Installation
58
+
59
+ ```python
60
+ # settings.py
61
+ INSTALLED_PACKAGES = [
62
+ # ...
63
+ "plain.admin.querystats",
64
+ ]
65
+
66
+ MIDDLEWARE = [
67
+ "plain.sessions.middleware.SessionMiddleware",
68
+ "plain.auth.middleware.AuthenticationMiddleware",
69
+
70
+ "plain.admin.querystats.QueryStatsMiddleware",
71
+ # Put additional middleware below querystats
72
+ # ...
73
+ ]
74
+ ```
75
+
76
+ We strongly recommend using the plain-toolbar along with this,
77
+ but if you aren't,
78
+ you can add the querystats to your frontend templates with this include:
79
+
80
+ ```html
81
+ {% include "querystats/button.html" %}
82
+ ```
83
+
84
+ *Note that you will likely want to surround this with an if `DEBUG` or `is_admin` check.*
85
+
86
+ To view querystats you need to send a POST request to `?querystats=store` (i.e. via a `<form>`),
87
+ and the template include is the easiest way to do that.
88
+
89
+ ## Tailwind CSS
90
+
91
+ This package is styled with [Tailwind CSS](https://tailwindcss.com/),
92
+ and pairs well with [`plain-tailwind`](https://github.com/plainpackages/plain-tailwind).
93
+
94
+ If you are using your own Tailwind implementation,
95
+ you can modify the "content" in your Tailwind config to include any Plain packages:
96
+
97
+ ```js
98
+ // tailwind.config.js
99
+ module.exports = {
100
+ content: [
101
+ // ...
102
+ ".venv/lib/python*/site-packages/plain*/**/*.{html,js}",
103
+ ],
104
+ // ...
105
+ }
106
+ ```
107
+
108
+ If you aren't using Tailwind, and don't intend to, open an issue to discuss other options.
109
+
110
+
111
+ # plain.toolbar
112
+
113
+ The admin toolbar is enabled for every user who `is_admin`.
114
+
115
+ ![Plain Admin toolbar](https://user-images.githubusercontent.com/649496/213781915-a2094f54-99b8-4a05-a36e-dee107405229.png)
116
+
117
+ ## Installation
118
+
119
+ Add `plaintoolbar` to your `INSTALLED_PACKAGES`,
120
+ and the `{% toolbar %}` to your base template:
121
+
122
+ ```python
123
+ # settings.py
124
+ INSTALLED_PACKAGES += [
125
+ "plaintoolbar",
126
+ ]
127
+ ```
128
+
129
+ ```html
130
+ <!-- base.template.html -->
131
+ {% load toolbar %}
132
+ <!doctype html>
133
+ <html lang="en">
134
+ <head>
135
+ ...
136
+ </head>
137
+ <body>
138
+ {% toolbar %}
139
+ ...
140
+ </body>
141
+ ```
142
+
143
+ More specific settings can be found below.
144
+
145
+ ## Tailwind CSS
146
+
147
+ This package is styled with [Tailwind CSS](https://tailwindcss.com/),
148
+ and pairs well with [`plain-tailwind`](https://github.com/plainpackages/plain-tailwind).
149
+
150
+ If you are using your own Tailwind implementation,
151
+ you can modify the "content" in your Tailwind config to include any Plain packages:
152
+
153
+ ```js
154
+ // tailwind.config.js
155
+ module.exports = {
156
+ content: [
157
+ // ...
158
+ ".venv/lib/python*/site-packages/plain*/**/*.{html,js}",
159
+ ],
160
+ // ...
161
+ }
162
+ ```
163
+
164
+ If you aren't using Tailwind, and don't intend to, open an issue to discuss other options.
165
+
166
+
167
+ # plain.requestlog
168
+
169
+ The request log stores a local history of HTTP requests and responses during `plain work` (Django runserver).
170
+
171
+ The request history will make it easy to see redirects,
172
+ 400 and 500 level errors,
173
+ form submissions,
174
+ API calls,
175
+ webhooks,
176
+ and more.
177
+
178
+ [Watch on YouTube](https://www.youtube.com/watch?v=AwI7Pt5oZnM)
179
+
180
+ Requests can be re-submitted by clicking the "replay" button.
181
+
182
+ [![Django request log](https://user-images.githubusercontent.com/649496/213781414-417ad043-de67-4836-9ef1-2b91404336c3.png)](https://user-images.githubusercontent.com/649496/213781414-417ad043-de67-4836-9ef1-2b91404336c3.png)
183
+
184
+ ## Installation
185
+
186
+ ```python
187
+ # settings.py
188
+ INSTALLED_PACKAGES += [
189
+ "plainrequestlog",
190
+ ]
191
+
192
+ MIDDLEWARE = MIDDLEWARE + [
193
+ # ...
194
+ "plainrequestlog.RequestLogMiddleware",
195
+ ]
196
+ ```
197
+
198
+ The default settings can be customized if needed:
199
+
200
+ ```python
201
+ # settings.py
202
+ DEV_REQUESTS_IGNORE_PATHS = [
203
+ "/sw.js",
204
+ "/favicon.ico",
205
+ "/admin/jsi18n/",
206
+ ]
207
+ DEV_REQUESTS_MAX = 50
208
+ ```
209
+
210
+ ## Tailwind CSS
211
+
212
+ This package is styled with [Tailwind CSS](https://tailwindcss.com/),
213
+ and pairs well with [`plain-tailwind`](https://github.com/plainpackages/plain-tailwind).
214
+
215
+ If you are using your own Tailwind implementation,
216
+ you can modify the "content" in your Tailwind config to include any Plain packages:
217
+
218
+ ```js
219
+ // tailwind.config.js
220
+ module.exports = {
221
+ content: [
222
+ // ...
223
+ ".venv/lib/python*/site-packages/plain*/**/*.{html,js}",
224
+ ],
225
+ // ...
226
+ }
227
+ ```
228
+
229
+ If you aren't using Tailwind, and don't intend to, open an issue to discuss other options.
230
+
231
+
232
+ # plain.impersonate
233
+
234
+ See what your users see.
235
+
236
+ A key feature for providing customer support is to be able to view the site through their account.
237
+ With `impersonate` installed, you can impersonate a user by finding them in the Django admin and clicking the "Impersonate" button.
238
+
239
+ ![](/docs/img/impersonate-admin.png)
240
+
241
+ Then with the [admin toolbar](/docs/plain-toolbar/) enabled, you'll get a notice of the impersonation and a button to exit:
242
+
243
+ ![](/docs/img/impersonate-bar.png)
244
+
245
+ ## Installation
246
+
247
+ To impersonate users, you need the app, middleware, and URLs:
248
+
249
+ ```python
250
+ # settings.py
251
+ INSTALLED_PACKAGES = INSTALLED_PACKAGES + [
252
+ "plain.admin.impersonate",
253
+ ]
254
+
255
+ MIDDLEWARE = MIDDLEWARE + [
256
+ "plain.admin.impersonate.ImpersonateMiddleware",
257
+ ]
258
+ ```
259
+
260
+ ```python
261
+ # urls.py
262
+ urlpatterns = [
263
+ # ...
264
+ path("impersonate/", include("plain.admin.impersonate.urls")),
265
+ ]
266
+ ```
267
+
268
+ ## Settings
269
+
270
+ By default, all admin users can impersonate other users.
271
+
272
+ ```python
273
+ # settings.py
274
+ IMPERSONATE_ALLOWED = lambda user: user.is_admin
275
+ ``` -->
@@ -0,0 +1 @@
1
+ plain/admin/README.md
@@ -0,0 +1,260 @@
1
+ # Admin
2
+
3
+ An admin interface for admin users.
4
+
5
+ The Plain Admin is a new package built from the ground up.
6
+ It leverages class-based views and standard URLs and templates to provide a flexible admin where
7
+ you can quickly create your own pages and cards,
8
+ in addition to models.
9
+
10
+ - cards
11
+ - dashboards
12
+ - diy forms
13
+ - detached from login (do your own login (oauth, passkeys, etc))
14
+
15
+ ## Installation
16
+
17
+ - install plain.admin and plain.htmx, add plain.admin.admin and plain.htmx to installed packages
18
+ - add url
19
+
20
+ ## Models in the admin
21
+
22
+ ## Dashboards
23
+
24
+ <!-- # plain.querystats
25
+
26
+ On-page database query stats in development and production.
27
+
28
+ On each page, the query stats will display how many database queries were performed and how long they took.
29
+
30
+ [Watch on YouTube](https://www.youtube.com/watch?v=NX8VXxVJm08)
31
+
32
+ Clicking the stats in the toolbar will show the full SQL query log with tracebacks and timings.
33
+ This is even designed to work in production,
34
+ making it much easier to discover and debug performance issues on production data!
35
+
36
+ ![Django query stats](https://user-images.githubusercontent.com/649496/213781593-54197bb6-36a8-4c9d-8294-5b43bd86a4c9.png)
37
+
38
+ It will also point out duplicate queries,
39
+ which can typically be removed by using `select_related`,
40
+ `prefetch_related`, or otherwise refactoring your code.
41
+
42
+ ## Installation
43
+
44
+ ```python
45
+ # settings.py
46
+ INSTALLED_PACKAGES = [
47
+ # ...
48
+ "plain.admin.querystats",
49
+ ]
50
+
51
+ MIDDLEWARE = [
52
+ "plain.sessions.middleware.SessionMiddleware",
53
+ "plain.auth.middleware.AuthenticationMiddleware",
54
+
55
+ "plain.admin.querystats.QueryStatsMiddleware",
56
+ # Put additional middleware below querystats
57
+ # ...
58
+ ]
59
+ ```
60
+
61
+ We strongly recommend using the plain-toolbar along with this,
62
+ but if you aren't,
63
+ you can add the querystats to your frontend templates with this include:
64
+
65
+ ```html
66
+ {% include "querystats/button.html" %}
67
+ ```
68
+
69
+ *Note that you will likely want to surround this with an if `DEBUG` or `is_admin` check.*
70
+
71
+ To view querystats you need to send a POST request to `?querystats=store` (i.e. via a `<form>`),
72
+ and the template include is the easiest way to do that.
73
+
74
+ ## Tailwind CSS
75
+
76
+ This package is styled with [Tailwind CSS](https://tailwindcss.com/),
77
+ and pairs well with [`plain-tailwind`](https://github.com/plainpackages/plain-tailwind).
78
+
79
+ If you are using your own Tailwind implementation,
80
+ you can modify the "content" in your Tailwind config to include any Plain packages:
81
+
82
+ ```js
83
+ // tailwind.config.js
84
+ module.exports = {
85
+ content: [
86
+ // ...
87
+ ".venv/lib/python*/site-packages/plain*/**/*.{html,js}",
88
+ ],
89
+ // ...
90
+ }
91
+ ```
92
+
93
+ If you aren't using Tailwind, and don't intend to, open an issue to discuss other options.
94
+
95
+
96
+ # plain.toolbar
97
+
98
+ The admin toolbar is enabled for every user who `is_admin`.
99
+
100
+ ![Plain Admin toolbar](https://user-images.githubusercontent.com/649496/213781915-a2094f54-99b8-4a05-a36e-dee107405229.png)
101
+
102
+ ## Installation
103
+
104
+ Add `plaintoolbar` to your `INSTALLED_PACKAGES`,
105
+ and the `{% toolbar %}` to your base template:
106
+
107
+ ```python
108
+ # settings.py
109
+ INSTALLED_PACKAGES += [
110
+ "plaintoolbar",
111
+ ]
112
+ ```
113
+
114
+ ```html
115
+ <!-- base.template.html -->
116
+ {% load toolbar %}
117
+ <!doctype html>
118
+ <html lang="en">
119
+ <head>
120
+ ...
121
+ </head>
122
+ <body>
123
+ {% toolbar %}
124
+ ...
125
+ </body>
126
+ ```
127
+
128
+ More specific settings can be found below.
129
+
130
+ ## Tailwind CSS
131
+
132
+ This package is styled with [Tailwind CSS](https://tailwindcss.com/),
133
+ and pairs well with [`plain-tailwind`](https://github.com/plainpackages/plain-tailwind).
134
+
135
+ If you are using your own Tailwind implementation,
136
+ you can modify the "content" in your Tailwind config to include any Plain packages:
137
+
138
+ ```js
139
+ // tailwind.config.js
140
+ module.exports = {
141
+ content: [
142
+ // ...
143
+ ".venv/lib/python*/site-packages/plain*/**/*.{html,js}",
144
+ ],
145
+ // ...
146
+ }
147
+ ```
148
+
149
+ If you aren't using Tailwind, and don't intend to, open an issue to discuss other options.
150
+
151
+
152
+ # plain.requestlog
153
+
154
+ The request log stores a local history of HTTP requests and responses during `plain work` (Django runserver).
155
+
156
+ The request history will make it easy to see redirects,
157
+ 400 and 500 level errors,
158
+ form submissions,
159
+ API calls,
160
+ webhooks,
161
+ and more.
162
+
163
+ [Watch on YouTube](https://www.youtube.com/watch?v=AwI7Pt5oZnM)
164
+
165
+ Requests can be re-submitted by clicking the "replay" button.
166
+
167
+ [![Django request log](https://user-images.githubusercontent.com/649496/213781414-417ad043-de67-4836-9ef1-2b91404336c3.png)](https://user-images.githubusercontent.com/649496/213781414-417ad043-de67-4836-9ef1-2b91404336c3.png)
168
+
169
+ ## Installation
170
+
171
+ ```python
172
+ # settings.py
173
+ INSTALLED_PACKAGES += [
174
+ "plainrequestlog",
175
+ ]
176
+
177
+ MIDDLEWARE = MIDDLEWARE + [
178
+ # ...
179
+ "plainrequestlog.RequestLogMiddleware",
180
+ ]
181
+ ```
182
+
183
+ The default settings can be customized if needed:
184
+
185
+ ```python
186
+ # settings.py
187
+ DEV_REQUESTS_IGNORE_PATHS = [
188
+ "/sw.js",
189
+ "/favicon.ico",
190
+ "/admin/jsi18n/",
191
+ ]
192
+ DEV_REQUESTS_MAX = 50
193
+ ```
194
+
195
+ ## Tailwind CSS
196
+
197
+ This package is styled with [Tailwind CSS](https://tailwindcss.com/),
198
+ and pairs well with [`plain-tailwind`](https://github.com/plainpackages/plain-tailwind).
199
+
200
+ If you are using your own Tailwind implementation,
201
+ you can modify the "content" in your Tailwind config to include any Plain packages:
202
+
203
+ ```js
204
+ // tailwind.config.js
205
+ module.exports = {
206
+ content: [
207
+ // ...
208
+ ".venv/lib/python*/site-packages/plain*/**/*.{html,js}",
209
+ ],
210
+ // ...
211
+ }
212
+ ```
213
+
214
+ If you aren't using Tailwind, and don't intend to, open an issue to discuss other options.
215
+
216
+
217
+ # plain.impersonate
218
+
219
+ See what your users see.
220
+
221
+ A key feature for providing customer support is to be able to view the site through their account.
222
+ With `impersonate` installed, you can impersonate a user by finding them in the Django admin and clicking the "Impersonate" button.
223
+
224
+ ![](/docs/img/impersonate-admin.png)
225
+
226
+ Then with the [admin toolbar](/docs/plain-toolbar/) enabled, you'll get a notice of the impersonation and a button to exit:
227
+
228
+ ![](/docs/img/impersonate-bar.png)
229
+
230
+ ## Installation
231
+
232
+ To impersonate users, you need the app, middleware, and URLs:
233
+
234
+ ```python
235
+ # settings.py
236
+ INSTALLED_PACKAGES = INSTALLED_PACKAGES + [
237
+ "plain.admin.impersonate",
238
+ ]
239
+
240
+ MIDDLEWARE = MIDDLEWARE + [
241
+ "plain.admin.impersonate.ImpersonateMiddleware",
242
+ ]
243
+ ```
244
+
245
+ ```python
246
+ # urls.py
247
+ urlpatterns = [
248
+ # ...
249
+ path("impersonate/", include("plain.admin.impersonate.urls")),
250
+ ]
251
+ ```
252
+
253
+ ## Settings
254
+
255
+ By default, all admin users can impersonate other users.
256
+
257
+ ```python
258
+ # settings.py
259
+ IMPERSONATE_ALLOWED = lambda user: user.is_admin
260
+ ``` -->
@@ -0,0 +1,5 @@
1
+ from .middleware import AdminMiddleware
2
+
3
+ __all__ = [
4
+ "AdminMiddleware",
5
+ ]
@@ -0,0 +1,108 @@
1
+ /*
2
+ These standard CSS rules are intended to make it easier for the
3
+ end-user to drop in HTML elements and have a decent, consistent starting point.
4
+
5
+ We shouldn't use many custom classes in here (like .btn) because the user
6
+ could unintentionally overwrite those since our CSS is combined.
7
+ */
8
+ table {
9
+ width: 100%;
10
+ font-size: .875rem;
11
+ line-height: 1.25rem;
12
+ table-layout: auto;
13
+ }
14
+
15
+ th {
16
+ text-align: left;
17
+ padding: 0 0.5rem;
18
+ color: rgb(55, 65, 81);
19
+ }
20
+
21
+ table th a {
22
+ color: rgb(55, 65, 81);
23
+ }
24
+
25
+ tbody tr:hover {
26
+ background-color: rgb(255, 255, 255, 0.1);
27
+ }
28
+
29
+ td {
30
+ padding: 0.5rem 0.5rem;
31
+ white-space: nowrap;
32
+ border-bottom: 1px solid rgb(255, 255, 255, 0.1);
33
+ }
34
+ tr:last-child td {
35
+ border-bottom: none;
36
+ }
37
+
38
+ table img {
39
+ height: 1.2rem;
40
+ border-radius: 2px;
41
+ }
42
+
43
+ main a {
44
+ color: rgb(37, 99, 235);
45
+ }
46
+
47
+ main a:hover {
48
+ text-decoration: underline;
49
+ }
50
+
51
+ .actions a, .actions button, main button {
52
+ display: inline-block;
53
+ padding: 8px 16px;
54
+ font-size: 14px;
55
+ font-weight: 500;
56
+ color: #ffffff;
57
+ text-align: center;
58
+ text-decoration: none;
59
+ background-color: #2a2826;
60
+ border: 1px solid #3f3d3b;
61
+ border-radius: 6px;
62
+ transition: background-color 0.2s, border-color 0.2s, transform 0.2s;
63
+ cursor: pointer;
64
+
65
+ &:hover {
66
+ background-color: #2a2928;
67
+ border-color: #504e4c;
68
+ transform: translateY(-1px);
69
+ }
70
+
71
+ &:active {
72
+ background-color: #141312;
73
+ border-color: #3f3d3b;
74
+ transform: translateY(0);
75
+ }
76
+
77
+ &:focus {
78
+ outline: 2px solid #e5e7eb;
79
+ outline-offset: 2px;
80
+ }
81
+ }
82
+
83
+ /* Cards use these? */
84
+ section {
85
+ border: rgba(255, 255, 255, 0.1) 1px solid;
86
+ border-radius: 0.275rem;
87
+ overflow: auto;
88
+ background-color: rgba(255, 255, 255, 0.05);
89
+ color: rgba(255, 255, 255, 0.8);
90
+ display: flex;
91
+ flex-direction: column;
92
+ }
93
+
94
+ section > header {
95
+ padding: 0.5rem;
96
+ /* background-color: #FFFCF0; */
97
+ border-bottom: rgba(255, 255, 255, 0.05) 1px solid;
98
+ }
99
+
100
+ section > div {
101
+ padding: 0.75rem 0.5rem;
102
+ flex-grow: 1;
103
+ display: flex;
104
+ flex-direction: column;
105
+ align-items: center;
106
+ justify-content: center;
107
+ overflow: auto;
108
+ }