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 <alekratz@gmail.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
from django.utils.safestring import mark_safe
|
||||||
from board.models import Board, Post, ReportReason, Report
|
from board.models import Board, Post, ReportReason, Report
|
||||||
|
|
||||||
|
|
||||||
@@ -20,4 +21,17 @@ class ReportReasonAdmin(admin.ModelAdmin):
|
|||||||
@admin.register(Report)
|
@admin.register(Report)
|
||||||
class ReportAdmin(admin.ModelAdmin):
|
class ReportAdmin(admin.ModelAdmin):
|
||||||
readonly_fields = ("post", "reason", "ip")
|
readonly_fields = ("post", "reason", "ip")
|
||||||
|
list_display = ("_post_thumbnail", "_post_subject", "_post_body")
|
||||||
save_as = False
|
save_as = False
|
||||||
|
|
||||||
|
def _post_thumbnail(self, obj):
|
||||||
|
if obj.post.thumbnail:
|
||||||
|
return mark_safe(f'<img src="{obj.post.thumbnail.url}" />')
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
def _post_subject(self, obj):
|
||||||
|
return obj.post.subject
|
||||||
|
|
||||||
|
def _post_body(self, obj):
|
||||||
|
return obj.post.text
|
||||||
|
|||||||
Reference in New Issue
Block a user