Scaffold containerized Django/Wagtail app with core features
This commit is contained in:
20
apps/comments/wagtail_hooks.py
Normal file
20
apps/comments/wagtail_hooks.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from wagtail.admin.ui.tables import BooleanColumn
|
||||
from wagtail.snippets.models import register_snippet
|
||||
from wagtail.snippets.views.snippets import SnippetViewSet
|
||||
|
||||
from apps.comments.models import Comment
|
||||
|
||||
|
||||
class CommentViewSet(SnippetViewSet):
|
||||
model = Comment
|
||||
icon = "comment"
|
||||
list_display = ["author_name", "article", BooleanColumn("is_approved"), "created_at"]
|
||||
list_filter = ["is_approved"]
|
||||
search_fields = ["author_name", "body"]
|
||||
add_to_admin_menu = True
|
||||
|
||||
def get_queryset(self, request):
|
||||
return super().get_queryset(request).select_related("article", "parent")
|
||||
|
||||
|
||||
register_snippet(CommentViewSet)
|
||||
Reference in New Issue
Block a user