From 5a2d6efbe1407c634fee43b60fcea5ac9565a789 Mon Sep 17 00:00:00 2001 From: Alek Ratzloff Date: Sun, 19 Jun 2022 18:12:02 -0700 Subject: [PATCH] Add list_display customization to the reports view This allows us to access the reported post's body, subject, etc for in-line display. It ain't perfect, but it definitely is better than nothing. Signed-off-by: Alek Ratzloff --- board/admin.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/board/admin.py b/board/admin.py index 7b4bb44..61b22f4 100644 --- a/board/admin.py +++ b/board/admin.py @@ -1,4 +1,5 @@ from django.contrib import admin +from django.utils.safestring import mark_safe from board.models import Board, Post, ReportReason, Report @@ -20,4 +21,17 @@ class ReportReasonAdmin(admin.ModelAdmin): @admin.register(Report) class ReportAdmin(admin.ModelAdmin): readonly_fields = ("post", "reason", "ip") + list_display = ("_post_thumbnail", "_post_subject", "_post_body") save_as = False + + def _post_thumbnail(self, obj): + if obj.post.thumbnail: + return mark_safe(f'') + else: + return None + + def _post_subject(self, obj): + return obj.post.subject + + def _post_body(self, obj): + return obj.post.text