https://github.com/webu/wagtail-neuralyzer
Port django neuralyzer to wagtail
https://github.com/webu/wagtail-neuralyzer
anonymizer wagtail
Last synced: 5 months ago
JSON representation
Port django neuralyzer to wagtail
- Host: GitHub
- URL: https://github.com/webu/wagtail-neuralyzer
- Owner: webu
- License: mit
- Created: 2025-03-14T15:22:05.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-12-10T13:07:46.000Z (8 months ago)
- Last Synced: 2025-12-10T19:56:49.355Z (7 months ago)
- Topics: anonymizer, wagtail
- Language: Python
- Homepage:
- Size: 44.9 KB
- Stars: 2
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# wagtail-neuralyzer
Pairs with [django-neuralyzer](https://github.com/webu/django-neuralyzer/), with wagtail support.
## Install
```
pip install wagtail-neuralyzer
```
## Register a model to have neuralyze action
Add `wagtail_neuralyzer` to your `INSTALLED_APP`:
```py
INSTALLED_APP = [
...
"django_neuralyzer",
"wagtail_neuralyzer",
...
]
```
### Add item action
Add the `NeuralyzeSnippetViewSetMixin` to your snippet class:
```py
from wagtail_neuralyzer.views import NeuralyzeSnippetViewSetMixin
from wagtail_neuralyzer.views import NeuralyzeView
from my_app.neuralyzers import PersonNeuralyzer
# Create a new view that handle url and action as well as neuralyzer class
class OperatorNeuralyzeView(NeuralyzeView):
neuralyzer_class = OperatorNeuralyzer
# inherit NeuralyzeSnippetViewSetMixin to register new url and neuralyze view
class PersonSnippetViewSet(NeuralyzeSnippetViewSetMixin, SnippetViewSet):
model = Person
neuralyze_view_class = OperatorNeuralyzeView
...
```
and finally register the new action:
```py
from wagtail import hooks
from wagtail_neuralyzer.menu_item import NeuralyzeMenuItem
@hooks.register("register_snippet_action_menu_item")
def register_anonymize_menu_item(model):
if model == Person:
return NeuralyzeMenuItem()
```
And _Tada_, your model should have an "Anonymize" action together with save/delete/publish/...
### Add bulk action
You can also add bulk action to the index view by registering wagtail hook
```py
from wagtail import hooks
from wagtail_neuralyzer.action import NeuralyzeBulkAction
from my_app.models import Person
from my_app.neuralyzers import StudentNeuralyzer
@hooks.register("register_bulk_action")
class PersonNeuralyzerBulkAction(NeuralyzeBulkAction):
models = [Person] # specify model here
neuralyzer_class = PersonNeuralyzer # and neuralyzer to use here
```