Users can be banned by IP address now, either by singular IP or in an IP range. If they are banned and attempt to post, they will be met with a "you are banned until X date" screen. There are a few loose threads with this, and IP bans may be obsolete if I decide to go the accounts-required-for-posting route. But I think this is a good start for 4chan style posting. Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
58 lines
1.3 KiB
Python
58 lines
1.3 KiB
Python
from django.contrib import admin
|
|
from django.utils.safestring import mark_safe
|
|
from board.models import Ban, Board, Post, RangeBan, ReportReason, ReportRecord
|
|
|
|
|
|
@admin.register(Board)
|
|
class BoardAdmin(admin.ModelAdmin):
|
|
pass
|
|
|
|
|
|
@admin.register(Post)
|
|
class PostAdmin(admin.ModelAdmin):
|
|
pass
|
|
|
|
|
|
@admin.register(ReportReason)
|
|
class ReportReasonAdmin(admin.ModelAdmin):
|
|
pass
|
|
|
|
|
|
@admin.register(ReportRecord)
|
|
class ReportRecordAdmin(admin.ModelAdmin):
|
|
ordering = (
|
|
"-urgent",
|
|
"-weight",
|
|
)
|
|
readonly_fields = ("post",)
|
|
list_display = ("post_thumbnail", "post_body")
|
|
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_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)
|
|
|
|
|
|
@admin.register(RangeBan)
|
|
class RangeBanAdmin(admin.ModelAdmin):
|
|
pass
|
|
|
|
|
|
@admin.register(Ban)
|
|
class BanAdmin(admin.ModelAdmin):
|
|
pass
|