|
|
from django.contrib import admin
|
|
|
from boards.models import Post, Tag, Ban, Thread, KeyPair
|
|
|
|
|
|
|
|
|
@admin.register(Post)
|
|
|
class PostAdmin(admin.ModelAdmin):
|
|
|
|
|
|
list_display = ('id', 'title', 'text')
|
|
|
list_filter = ('pub_time', 'thread_new')
|
|
|
search_fields = ('id', 'title', 'text')
|
|
|
exclude = ('referenced_posts', 'refmap')
|
|
|
readonly_fields = ('poster_ip', 'thread_new')
|
|
|
|
|
|
|
|
|
@admin.register(Tag)
|
|
|
class TagAdmin(admin.ModelAdmin):
|
|
|
|
|
|
def thread_count(self, obj: Tag) -> int:
|
|
|
return obj.get_thread_count()
|
|
|
|
|
|
list_display = ('name', 'thread_count')
|
|
|
search_fields = ('name',)
|
|
|
|
|
|
|
|
|
@admin.register(Thread)
|
|
|
class ThreadAdmin(admin.ModelAdmin):
|
|
|
|
|
|
def title(self, obj: Thread) -> str:
|
|
|
return obj.get_opening_post().get_title()
|
|
|
|
|
|
def reply_count(self, obj: Thread) -> int:
|
|
|
return obj.get_reply_count()
|
|
|
|
|
|
def ip(self, obj: Thread):
|
|
|
return obj.get_opening_post().poster_ip
|
|
|
|
|
|
list_display = ('id', 'title', 'reply_count', 'archived', 'ip')
|
|
|
list_filter = ('bump_time', 'archived', 'bumpable')
|
|
|
search_fields = ('id', 'title')
|
|
|
filter_horizontal = ('tags',)
|
|
|
|
|
|
|
|
|
@admin.register(KeyPair)
|
|
|
class KeyPairAdmin(admin.ModelAdmin):
|
|
|
list_display = ('public_key', 'primary')
|
|
|
list_filter = ('primary',)
|
|
|
search_fields = ('public_key',)
|
|
|
|
|
|
|
|
|
@admin.register(Ban)
|
|
|
class BanAdmin(admin.ModelAdmin):
|
|
|
list_display = ('ip', 'can_read')
|
|
|
list_filter = ('can_read',)
|
|
|
search_fields = ('ip',)
|
|
|
|