Skip to content

Commit 17b4038

Browse files
committed
Rename plain-staff to plain-admin
1 parent 98cac87 commit 17b4038

File tree

118 files changed

+401
-400
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+401
-400
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
strategy:
1010
matrix:
1111
python-version: ["3.11", "3.12", "3.13"]
12-
package: ["plain", "plain-worker", "plain-flags", "plain-sessions", "plain-staff", "plain-oauth", "plain-models"]
12+
package: ["plain", "plain-worker", "plain-flags", "plain-sessions", "plain-admin", "plain-oauth", "plain-models"]
1313

1414
steps:
1515
- uses: actions/checkout@v4

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ With the official Plain ecosystem packages you can:
2828
- Add [OAuth login](https://plainframework.com/docs/plain-oauth/) and API access
2929
- Run tests with [pytest](https://plainframework.com/docs/plain-test/)
3030
- Run a [background job worker](https://plainframework.com/docs/plain-worker/)
31-
- Build [staff tooling and admin dashboards](https://plainframework.com/docs/plain-staff/)
31+
- Build [admin dashboard and tools](https://plainframework.com/docs/plain-admin/)
3232

3333
Learn more at [plainframework.com](https://plainframework.com).
File renamed without changes.

plain-admin/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
plain/admin/README.md

plain-staff/plain/staff/README.md renamed to plain-admin/plain/admin/README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Staff
1+
# Admin
22

3-
An admin interface for staff users.
3+
An admin interface for admin users.
44

5-
The Plain Staff is a new packages built from the ground up.
5+
The Plain Admin is a new package built from the ground up.
66
It leverages class-based views and standard URLs and templates to provide a flexible admin where
77
you can quickly create your own pages and cards,
88
in addition to models.
@@ -14,7 +14,7 @@ in addition to models.
1414

1515
## Installation
1616

17-
- install plain.staff and plain.htmx, add plain.staff.admin and plain.htmx to installed packages
17+
- install plain.admin and plain.htmx, add plain.admin.admin and plain.htmx to installed packages
1818
- add url
1919

2020
## Models in the admin
@@ -45,14 +45,14 @@ which can typically be removed by using `select_related`,
4545
# settings.py
4646
INSTALLED_PACKAGES = [
4747
# ...
48-
"plain.staff.querystats",
48+
"plain.admin.querystats",
4949
]
5050
5151
MIDDLEWARE = [
5252
"plain.sessions.middleware.SessionMiddleware",
5353
"plain.auth.middleware.AuthenticationMiddleware",
5454
55-
"plain.staff.querystats.QueryStatsMiddleware",
55+
"plain.admin.querystats.QueryStatsMiddleware",
5656
# Put additional middleware below querystats
5757
# ...
5858
]
@@ -66,7 +66,7 @@ you can add the querystats to your frontend templates with this include:
6666
{% include "querystats/button.html" %}
6767
```
6868
69-
*Note that you will likely want to surround this with an if `DEBUG` or `is_staff` check.*
69+
*Note that you will likely want to surround this with an if `DEBUG` or `is_admin` check.*
7070
7171
To view querystats you need to send a POST request to `?querystats=store` (i.e. via a `<form>`),
7272
and the template include is the easiest way to do that.
@@ -95,9 +95,9 @@ If you aren't using Tailwind, and don't intend to, open an issue to discuss othe
9595
9696
# plain.toolbar
9797
98-
The staff toolbar is enabled for every user who `is_staff`.
98+
The admin toolbar is enabled for every user who `is_admin`.
9999
100-
![Plain staff toolbar](https://user-images.githubusercontent.com/649496/213781915-a2094f54-99b8-4a05-a36e-dee107405229.png)
100+
![Plain Admin toolbar](https://user-images.githubusercontent.com/649496/213781915-a2094f54-99b8-4a05-a36e-dee107405229.png)
101101
102102
## Installation
103103
@@ -187,7 +187,7 @@ The default settings can be customized if needed:
187187
DEV_REQUESTS_IGNORE_PATHS = [
188188
"/sw.js",
189189
"/favicon.ico",
190-
"/staff/jsi18n/",
190+
"/admin/jsi18n/",
191191
]
192192
DEV_REQUESTS_MAX = 50
193193
```
@@ -223,7 +223,7 @@ With `impersonate` installed, you can impersonate a user by finding them in the
223223

224224
![](/docs/img/impersonate-admin.png)
225225

226-
Then with the [staff toolbar](/docs/plain-toolbar/) enabled, you'll get a notice of the impersonation and a button to exit:
226+
Then with the [admin toolbar](/docs/plain-toolbar/) enabled, you'll get a notice of the impersonation and a button to exit:
227227

228228
![](/docs/img/impersonate-bar.png)
229229

@@ -234,27 +234,27 @@ To impersonate users, you need the app, middleware, and URLs:
234234
```python
235235
# settings.py
236236
INSTALLED_PACKAGES = INSTALLED_PACKAGES + [
237-
"plain.staff.impersonate",
237+
"plain.admin.impersonate",
238238
]
239239

240240
MIDDLEWARE = MIDDLEWARE + [
241-
"plain.staff.impersonate.ImpersonateMiddleware",
241+
"plain.admin.impersonate.ImpersonateMiddleware",
242242
]
243243
```
244244

245245
```python
246246
# urls.py
247247
urlpatterns = [
248248
# ...
249-
path("impersonate/", include("plain.staff.impersonate.urls")),
249+
path("impersonate/", include("plain.admin.impersonate.urls")),
250250
]
251251
```
252252

253253
## Settings
254254

255-
By default, all staff users can impersonate other users.
255+
By default, all admin users can impersonate other users.
256256

257257
```python
258258
# settings.py
259-
IMPERSONATE_ALLOWED = lambda user: user.is_staff
259+
IMPERSONATE_ALLOWED = lambda user: user.is_admin
260260
``` -->

plain-admin/plain/admin/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from .middleware import AdminMiddleware
2+
3+
__all__ = [
4+
"AdminMiddleware",
5+
]

plain-staff/plain/staff/assets/toolbar/toolbar.js renamed to plain-admin/plain/admin/assets/toolbar/toolbar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ if (plainToolbar.shouldHide()) {
4242

4343
window.addEventListener("load", function () {
4444
document.querySelector('[data-plaintoolbar-hide]').addEventListener('click', function() {
45-
console.log("Hiding staff toolbar for 1 hour");
45+
console.log("Hiding admin toolbar for 1 hour");
4646
plainToolbar.hideUntil(Date.now() + 3600000);
4747
});
4848
document.querySelector('[data-plaintoolbar-expand]').addEventListener('click', function() {

plain-staff/plain/staff/cards/base.py renamed to plain-admin/plain/admin/cards/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Sizes(Enum):
1414
LARGE = 3
1515
FULL = 4
1616

17-
template_name = "staff/cards/card.html"
17+
template_name = "admin/cards/card.html"
1818
size: Sizes = Sizes.SMALL
1919
# unique_id: str # Use for tying to dashboards, require it
2020

plain-staff/plain/staff/cards/charts.py renamed to plain-admin/plain/admin/cards/charts.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
from collections import defaultdict
22

3+
from plain.admin.dates import DatetimeRangeAliases
34
from plain.models import Count
45
from plain.models.functions import (
56
TruncDate,
67
TruncMonth,
78
)
8-
from plain.staff.dates import DatetimeRangeAliases
99

1010
from .base import Card
1111

1212

1313
class ChartCard(Card):
14-
template_name = "staff/cards/chart.html"
14+
template_name = "admin/cards/chart.html"
1515

1616
def get_template_context(self):
1717
context = super().get_template_context()

plain-staff/plain/staff/cards/tables.py renamed to plain-admin/plain/admin/cards/tables.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
class TableCard(Card):
5-
template_name = "staff/cards/table.html"
5+
template_name = "admin/cards/table.html"
66
size = Card.Sizes.FULL
77

88
headers = []

plain-staff/plain/staff/config.py renamed to plain-admin/plain/admin/config.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33

44
from plain.packages import PackageConfig, packages
55

6-
MODULE_NAME = "staff"
7-
86

97
class Config(PackageConfig):
10-
name = "plain.staff"
11-
label = "plainstaff"
8+
name = "plain.admin"
9+
label = "plainadmin"
1210

1311
def ready(self):
1412
def _import_if_exists(module_name):
@@ -17,7 +15,7 @@ def _import_if_exists(module_name):
1715

1816
# Trigger register calls to fire by importing the modules
1917
for package_config in packages.get_package_configs():
20-
_import_if_exists(f"{package_config.name}.{MODULE_NAME}")
18+
_import_if_exists(f"{package_config.name}.admin")
2119

22-
# Also trigger for the root app/staff.py module
23-
_import_if_exists(f"app.{MODULE_NAME}")
20+
# Also trigger for the root app/admin.py module
21+
_import_if_exists("app.admin")
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
TOOLBAR_CLASS = "plain.staff.toolbar.Toolbar"
1+
TOOLBAR_CLASS = "plain.admin.toolbar.Toolbar"
22
TOOLBAR_VERSION: str = "dev"
33

44
QUERYSTATS_IGNORE_URLS: list[str] = ["/assets/.*"]

plain-staff/plain/staff/impersonate/README.md renamed to plain-admin/plain/admin/impersonate/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ With `impersonate` installed, you can impersonate a user by finding them in the
77

88
![](/docs/img/impersonate-admin.png)
99

10-
Then with the [staff toolbar](/docs/plain-toolbar/) enabled, you'll get a notice of the impersonation and a button to exit:
10+
Then with the [admin toolbar](/docs/plain-toolbar/) enabled, you'll get a notice of the impersonation and a button to exit:
1111

1212
![](/docs/img/impersonate-bar.png)
1313

@@ -18,27 +18,27 @@ To impersonate users, you need the app, middleware, and URLs:
1818
```python
1919
# settings.py
2020
INSTALLED_PACKAGES = INSTALLED_PACKAGES + [
21-
"plain.staff.impersonate",
21+
"plain.admin.impersonate",
2222
]
2323

2424
MIDDLEWARE = MIDDLEWARE + [
25-
"plain.staff.impersonate.ImpersonateMiddleware",
25+
"plain.admin.impersonate.ImpersonateMiddleware",
2626
]
2727
```
2828

2929
```python
3030
# urls.py
3131
urlpatterns = [
3232
# ...
33-
path("impersonate/", include("plain.staff.impersonate.urls")),
33+
path("impersonate/", include("plain.admin.impersonate.urls")),
3434
]
3535
```
3636

3737
## Settings
3838

39-
By default, all staff users can impersonate other users.
39+
By default, all admin users can impersonate other users.
4040

4141
```python
4242
# settings.py
43-
IMPERSONATE_ALLOWED = lambda user: user.is_staff
43+
IMPERSONATE_ALLOWED = lambda user: user.is_admin
4444
```

plain-staff/plain/staff/impersonate/permissions.py renamed to plain-admin/plain/admin/impersonate/permissions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ def can_impersonate_user(impersonator, target_user):
99
if not can_be_impersonator(impersonator):
1010
return False
1111

12-
# You can't impersonate staff users
13-
if target_user.is_staff:
12+
# You can't impersonate admin users
13+
if target_user.is_admin:
1414
return False
1515

1616
return True

plain-staff/plain/staff/impersonate/settings.py renamed to plain-admin/plain/admin/impersonate/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ def IMPERSONATE_ALLOWED(user):
55
if hasattr(settings, "IMPERSONATE_ALLOWED"):
66
return settings.IMPERSONATE_ALLOWED(user)
77

8-
return user.is_staff
8+
return user.is_admin

plain-staff/plain/staff/middleware.py renamed to plain-admin/plain/admin/middleware.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
from .querystats.middleware import QueryStatsMiddleware
33

44

5-
class StaffMiddleware:
6-
"""All staff-related middleware in a single class."""
5+
class AdminMiddleware:
6+
"""All admin-related middleware in a single class."""
77

88
def __init__(self, get_response):
99
self.get_response = get_response

plain-staff/plain/staff/querystats/README.md renamed to plain-admin/plain/admin/querystats/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ which can typically be removed by using `select_related`,
2222
# settings.py
2323
INSTALLED_PACKAGES = [
2424
# ...
25-
"plain.staff.querystats",
25+
"plain.admin.querystats",
2626
]
2727

2828
MIDDLEWARE = [
2929
"plain.sessions.middleware.SessionMiddleware",
3030
"plain.auth.middleware.AuthenticationMiddleware",
3131

32-
"plain.staff.querystats.QueryStatsMiddleware",
32+
"plain.admin.querystats.QueryStatsMiddleware",
3333
# Put additional middleware below querystats
3434
# ...
3535
]
@@ -43,7 +43,7 @@ you can add the querystats to your frontend templates with this include:
4343
{% include "querystats/button.html" %}
4444
```
4545

46-
*Note that you will likely want to surround this with an if `DEBUG` or `is_staff` check.*
46+
*Note that you will likely want to surround this with an if `DEBUG` or `is_admin` check.*
4747

4848
To view querystats you need to send a POST request to `?querystats=store` (i.e. via a `<form>`),
4949
and the template include is the easiest way to do that.
@@ -72,9 +72,9 @@ If you aren't using Tailwind, and don't intend to, open an issue to discuss othe
7272

7373
# plain.toolbar
7474

75-
The staff toolbar is enabled for every user who `is_staff`.
75+
The admin toolbar is enabled for every user who `is_admin`.
7676

77-
![Plain staff toolbar](https://user-images.githubusercontent.com/649496/213781915-a2094f54-99b8-4a05-a36e-dee107405229.png)
77+
![Plain admin toolbar](https://user-images.githubusercontent.com/649496/213781915-a2094f54-99b8-4a05-a36e-dee107405229.png)
7878

7979
## Installation
8080

@@ -164,7 +164,7 @@ The default settings can be customized if needed:
164164
DEV_REQUESTS_IGNORE_PATHS = [
165165
"/sw.js",
166166
"/favicon.ico",
167-
"/staff/jsi18n/",
167+
"/admin/jsi18n/",
168168
]
169169
DEV_REQUESTS_MAX = 50
170170
```

plain-staff/plain/staff/querystats/middleware.py renamed to plain-admin/plain/admin/querystats/middleware.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ def __call__(self, request):
5959

6060
with connection.execute_wrapper(querystats):
6161
# Have to wrap this first call so it is included in the querystats,
62-
# but we don't have to wrap everything else unless we are staff or debug
63-
is_staff = self.is_staff_request(request)
62+
# but we don't have to wrap everything else unless we are admin or debug
63+
is_admin = self.is_admin_request(request)
6464

65-
if (settings.DEBUG or is_staff) and not self.should_ignore_request(request):
65+
if (settings.DEBUG or is_admin) and not self.should_ignore_request(request):
6666
# Persist it on the thread
6767
_local.querystats = querystats
6868

@@ -91,9 +91,9 @@ def __call__(self, request):
9191
return self.get_response(request)
9292

9393
@staticmethod
94-
def is_staff_request(request):
94+
def is_admin_request(request):
9595
if getattr(request, "impersonator", None):
96-
# Support for impersonation (still want the real staff user to see the querystats)
97-
return request.impersonator and request.impersonator.is_staff
96+
# Support for impersonation (still want the real admin user to see the querystats)
97+
return request.impersonator and request.impersonator.is_admin
9898

99-
return hasattr(request, "user") and request.user and request.user.is_staff
99+
return hasattr(request, "user") and request.user and request.user.is_admin

plain-staff/plain/staff/querystats/views.py renamed to plain-admin/plain/admin/querystats/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class QuerystatsView(AuthViewMixin, TemplateView):
88
template_name = "querystats/querystats.html"
9-
staff_required = True # allow impersonator?
9+
admin_required = True # allow impersonator?
1010

1111
def get_template_context(self):
1212
context = super().get_template_context()

0 commit comments

Comments
 (0)