Skip to content

Commit

Permalink
Move admin etc into staff directory
Browse files Browse the repository at this point in the history
  • Loading branch information
davegaeddert committed Jun 21, 2024
1 parent f96e11f commit f13d777
Show file tree
Hide file tree
Showing 89 changed files with 45 additions and 87 deletions.
4 changes: 2 additions & 2 deletions bolt-cache/bolt/cache/admin.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from bolt.admin.views import (
from bolt.cache.models import CachedItem
from bolt.staff.admin.views import (
AdminModelDetailView,
AdminModelListView,
AdminModelViewset,
register_viewset,
)
from bolt.cache.models import CachedItem


@register_viewset
Expand Down
6 changes: 3 additions & 3 deletions bolt-flags/bolt/flags/admin.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from functools import cached_property

from bolt.admin.cards import Card
from bolt.admin.views import (
from bolt.db.forms import ModelForm
from bolt.staff.admin.cards import Card
from bolt.staff.admin.views import (
AdminModelDetailView,
AdminModelListView,
AdminModelUpdateView,
AdminModelViewset,
register_viewset,
)
from bolt.db.forms import ModelForm

from .models import Flag, FlagResult

Expand Down
6 changes: 3 additions & 3 deletions bolt-oauth/bolt/oauth/admin.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from bolt.admin.cards import ChartCard
from bolt.admin.views import (
from bolt.db.models import Count
from bolt.staff.admin.cards import ChartCard
from bolt.staff.admin.views import (
AdminModelDetailView,
AdminModelListView,
AdminModelViewset,
register_viewset,
)
from bolt.db.models import Count

from .models import OAuthConnection

Expand Down
2 changes: 1 addition & 1 deletion bolt-oauth/tests/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from bolt import admin
from bolt.auth.views import AuthViewMixin, LogoutView
from bolt.oauth.providers import get_provider_keys
from bolt.staff import admin
from bolt.urls import include, path
from bolt.views import TemplateView

Expand Down
3 changes: 3 additions & 0 deletions bolt-pages/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<!-- This file is compiled from bolt-pages/bolt/pages/README.md. Do not edit this file directly. -->

# Pages
1 change: 1 addition & 0 deletions bolt-pages/bolt/pages/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Pages
47 changes: 2 additions & 45 deletions bolt-staff/README.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,3 @@
<!-- This file is compiled from bolt-staff/bolt/impersonate/README.md. Do not edit this file directly. -->
<!-- This file is compiled from bolt-staff/bolt/staff/README.md. Do not edit this file directly. -->

# bolt-impersonate

See what your users see.

A key feature for providing customer support is to be able to view the site through their account.
With `impersonate` installed, you can impersonate a user by finding them in the Django admin and clicking the "Impersonate" button.

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

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

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

## Installation

To impersonate users, you need the app, middleware, and URLs:

```python
# settings.py
INSTALLED_PACKAGES = INSTALLED_PACKAGES + [
"bolt.impersonate",
]

MIDDLEWARE = MIDDLEWARE + [
"bolt.impersonate.ImpersonateMiddleware",
]
```

```python
# urls.py
urlpatterns = [
# ...
path("impersonate/", include("bolt.impersonate.urls")),
]
```

## Settings

By default, all staff users can impersonate other users.

```python
# settings.py
IMPERSONATE_ALLOWED = lambda user: user.is_staff
```
# Staff
Binary file removed bolt-staff/bolt/admin/templates/.DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions bolt-staff/bolt/staff/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Staff
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ in addition to models.

## Installation

- install bolt.staff and bolt.htmx, add bolt.admin and bolt.htmx to installed packages
- install bolt.staff and bolt.htmx, add bolt.staff.admin and bolt.htmx to installed packages
- add url

## Models in the admin
Expand Down Expand Up @@ -238,19 +238,19 @@ To impersonate users, you need the app, middleware, and URLs:
```python
# settings.py
INSTALLED_PACKAGES = INSTALLED_PACKAGES + [
"bolt.impersonate",
"bolt.staff.impersonate",
]

MIDDLEWARE = MIDDLEWARE + [
"bolt.impersonate.ImpersonateMiddleware",
"bolt.staff.impersonate.ImpersonateMiddleware",
]
```

```python
# urls.py
urlpatterns = [
# ...
path("impersonate/", include("bolt.impersonate.urls")),
path("impersonate/", include("bolt.staff.impersonate.urls")),
]
```

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from enum import Enum

from bolt.admin.dates import DatetimeRange, DatetimeRangeAliases
from bolt.http import HttpRequest
from bolt.staff.admin.dates import DatetimeRange, DatetimeRangeAliases
from bolt.templates import Template
from bolt.utils.text import slugify
from bolt.views import View
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class BoltAdminConfig(PackageConfig):
name = "bolt.admin"
name = "bolt.staff.admin"
label = "boltadmin"

def ready(self):
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from typing import TYPE_CHECKING

from bolt.admin.dates import DatetimeRange, DatetimeRangeAliases
from bolt.auth.views import AuthViewMixin
from bolt.db import models
from bolt.htmx.views import HTMXViewMixin
from bolt.http import Response, ResponseRedirect
from bolt.paginator import Paginator
from bolt.staff.admin.dates import DatetimeRange, DatetimeRangeAliases
from bolt.urls import reverse
from bolt.utils import timezone
from bolt.utils.text import slugify
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ def get_searchable_views(self):
return views

def get_model_detail_url(self, instance):
from bolt.admin.views.base import URL_NAMESPACE
from bolt.admin.views.models import AdminModelDetailView
from bolt.staff.admin.views.base import URL_NAMESPACE
from bolt.staff.admin.views.models import AdminModelDetailView

if not instance.pk:
# Has to actually be in the db
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ To impersonate users, you need the app, middleware, and URLs:
```python
# settings.py
INSTALLED_PACKAGES = INSTALLED_PACKAGES + [
"bolt.impersonate",
"bolt.staff.impersonate",
]

MIDDLEWARE = MIDDLEWARE + [
"bolt.impersonate.ImpersonateMiddleware",
"bolt.staff.impersonate.ImpersonateMiddleware",
]
```

```python
# urls.py
urlpatterns = [
# ...
path("impersonate/", include("bolt.impersonate.urls")),
path("impersonate/", include("bolt.staff.impersonate.urls")),
]
```

Expand Down
File renamed without changes.
File renamed without changes.
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions bolt-staff/bolt/staff/toolbar/default_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TOOLBAR_CLASS = "bolt.staff.toolbar.Toolbar"
File renamed without changes.
1 change: 0 additions & 1 deletion bolt-staff/bolt/toolbar/default_settings.py

This file was deleted.

4 changes: 2 additions & 2 deletions bolt-staff/tests_impersonate/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
INSTALLED_PACKAGES = [
"bolt.auth",
"bolt.sessions",
"bolt.impersonate",
"bolt.staff.impersonate",
]

MIDDLEWARE = [
Expand All @@ -19,7 +19,7 @@
"bolt.csrf.middleware.CsrfViewMiddleware",
"bolt.auth.middleware.AuthenticationMiddleware",
"bolt.middleware.clickjacking.XFrameOptionsMiddleware",
"bolt.impersonate.middleware.ImpersonateMiddleware",
"bolt.staff.impersonate.middleware.ImpersonateMiddleware",
]

DATABASES = {
Expand Down
12 changes: 6 additions & 6 deletions bolt-worker/bolt/worker/admin.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
from datetime import timedelta

from bolt.admin.cards import Card
from bolt.admin.dates import DatetimeRangeAliases
from bolt.admin.views import (
from bolt.db import models
from bolt.http import ResponseRedirect
from bolt.runtime import settings
from bolt.staff.admin.cards import Card
from bolt.staff.admin.dates import DatetimeRangeAliases
from bolt.staff.admin.views import (
AdminModelDetailView,
AdminModelListView,
AdminModelViewset,
register_viewset,
)
from bolt.db import models
from bolt.http import ResponseRedirect
from bolt.runtime import settings

from .models import Job, JobRequest, JobResult

Expand Down
6 changes: 3 additions & 3 deletions bolt/bolt/packages/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ class PackageConfig:
migrations_module = "migrations"

def __init__(self, package_name, package_module):
# Full Python path to the application e.g. 'bolt.admin.admin'.
# Full Python path to the application e.g. 'bolt.staff.admin.admin'.
self.name = package_name

# Root module for the application e.g. <module 'bolt.admin.admin'
# Root module for the application e.g. <module 'bolt.staff.admin.admin'
# from 'admin/__init__.py'>.
self.module = package_module

Expand All @@ -43,7 +43,7 @@ def __init__(self, package_name, package_module):
if not hasattr(self, "path"):
self.path = self._path_from_module(package_module)

# Module containing models e.g. <module 'bolt.admin.models'
# Module containing models e.g. <module 'bolt.staff.admin.models'
# from 'admin/models.py'>. Set by import_models().
# None if the application doesn't have a models module.
self.models_module = None
Expand Down
2 changes: 1 addition & 1 deletion bolt/bolt/packages/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def is_installed(self, package_name):
"""
Check whether an application with this name exists in the registry.
package_name is the full name of the app e.g. 'bolt.admin'.
package_name is the full name of the app e.g. 'bolt.staff.admin'.
"""
self.check_packages_ready()
return any(ac.name == package_name for ac in self.package_configs.values())
Expand Down
12 changes: 4 additions & 8 deletions scripts/compile-readmes
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,8 @@ compile_readme "bolt/README.md" "bolt/bolt/README.md"

# Now do the same for every bolt-* package and the README.md found at bolt-<pkg>/bolt/*/README.md
for package_dir in bolt-*; do
# if [ -d "$package_dir/bolt" ]; then
# Find the README.md in $package_dir/bolt/*/README.md
find "$package_dir/bolt" -name "README.md" | while read -r code_readme; do
package_readme="$package_dir/README.md"
compile_readme "$package_readme" "$code_readme"
done
# compile_readme "$package_dir/README.md" "$package_dir/bolt/README.md"
# fi
package_name=$(echo "$package_dir" | sed -e "s/^bolt-//")
package_readme="$package_dir/README.md"
code_readme="$package_dir/bolt/$package_name/README.md"
compile_readme "$package_readme" "$code_readme"
done

0 comments on commit f13d777

Please sign in to comment.