Big upheaval of how the reports system works
* There are now Reports and ReportRecords. * Reports coordinate to what moderators see, and ReportRecords coordinate with the reports that are created by individual users. * Reports keep track of the report reason and the creating user. * ReportRecords keep track of the total weight and whether this report requires urgent attention or not. * ReportRecord keeps track of its own weight and urgency because then we can sort by weight and urgency in the admin view. Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
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, ReportRecord
|
||||
|
||||
|
||||
@admin.register(Board)
|
||||
@@ -18,9 +18,13 @@ class ReportReasonAdmin(admin.ModelAdmin):
|
||||
pass
|
||||
|
||||
|
||||
@admin.register(Report)
|
||||
class ReportAdmin(admin.ModelAdmin):
|
||||
readonly_fields = ("post", "reason", "ip")
|
||||
@admin.register(ReportRecord)
|
||||
class ReportRecordAdmin(admin.ModelAdmin):
|
||||
ordering = (
|
||||
"-urgent",
|
||||
"-weight",
|
||||
)
|
||||
readonly_fields = ("post",)
|
||||
list_display = ("post_thumbnail", "post_body")
|
||||
save_as = False
|
||||
|
||||
@@ -32,7 +36,12 @@ class ReportAdmin(admin.ModelAdmin):
|
||||
|
||||
def post_body(self, obj):
|
||||
html = ""
|
||||
if obj.urgent:
|
||||
html += '<div class="urgent">'
|
||||
else:
|
||||
html += "<div>"
|
||||
if obj.post.subject:
|
||||
html += f"<strong>{obj.post.subject}</strong>"
|
||||
html += f"<p>{obj.post.text}</p>"
|
||||
html += "</div>"
|
||||
return mark_safe(html)
|
||||
|
||||
Reference in New Issue
Block a user