Skip to content

Commit

Permalink
#100 add a snippet view to be able to do crud on tags
Browse files Browse the repository at this point in the history
  • Loading branch information
ephes committed Aug 29, 2023
1 parent 81e571a commit eb296f0
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions cast/wagtail_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
from django.urls import include, path, reverse
from django.utils.html import format_html
from django.utils.translation import gettext_lazy as _
from taggit.models import Tag
from wagtail import hooks
from wagtail.admin.menu import MenuItem
from wagtail.admin.panels import FieldPanel
from wagtail.permission_policies.collections import CollectionOwnershipPermissionPolicy
from wagtail.snippets.models import register_snippet
from wagtail.snippets.views.snippets import SnippetViewSet

from .admin_urls import audio, video
from .models import Audio, Video
Expand Down Expand Up @@ -74,3 +78,22 @@ def editor_js_audio() -> str:
""",
reverse("castaudio:chooser"),
)


class TagsSnippetViewSet(SnippetViewSet):
"""
This is a snippet viewset for the taggit Tag model. It is used to
be able to do crud operations on tags from the admin menu.
"""

panels = [FieldPanel("name")] # only show the name field
model = Tag
icon = "tag" # change as required
add_to_admin_menu = True
menu_label = "Tags"
menu_order = 200 # will put in 3rd place (000 being 1st, 100 2nd)
list_display = ["name", "slug"]
search_fields = ("name",)


register_snippet(TagsSnippetViewSet)

0 comments on commit eb296f0

Please sign in to comment.