admin.py
42 lines
| 1.1 KiB
| text/x-python
|
PythonLexer
/ boards / admin.py
neko259
|
r0 | from django.contrib import admin | |
neko259
|
r728 | from boards.models import Post, Tag, Ban, Thread | |
neko259
|
r0 | ||
neko259
|
r333 | ||
neko259
|
r906 | @admin.register(Post) | |
neko259
|
r305 | class PostAdmin(admin.ModelAdmin): | |
list_display = ('id', 'title', 'text') | |||
neko259
|
r398 | list_filter = ('pub_time', 'thread_new') | |
neko259
|
r305 | search_fields = ('id', 'title', 'text') | |
neko259
|
r906 | exclude = ('referenced_posts', 'refmap') | |
readonly_fields = ('poster_ip', 'thread_new') | |||
neko259
|
r305 | ||
neko259
|
r333 | ||
neko259
|
r906 | @admin.register(Tag) | |
neko259
|
r305 | class TagAdmin(admin.ModelAdmin): | |
neko259
|
r740 | list_display = ('name',) | |
neko259
|
r906 | search_fields = ('name',) | |
neko259
|
r305 | ||
neko259
|
r883 | ||
neko259
|
r906 | @admin.register(Thread) | |
neko259
|
r604 | class ThreadAdmin(admin.ModelAdmin): | |
def title(self, obj): | |||
neko259
|
r883 | return obj.get_opening_post().get_title() | |
neko259
|
r604 | ||
def reply_count(self, obj): | |||
return obj.get_reply_count() | |||
neko259
|
r906 | def ip(self, obj): | |
return obj.get_opening_post().poster_ip | |||
list_display = ('id', 'title', 'reply_count', 'archived', 'ip') | |||
list_filter = ('bump_time', 'archived', 'bumpable') | |||
neko259
|
r604 | search_fields = ('id', 'title') | |
neko259
|
r883 | ||
neko259
|
r906 | @admin.register(Ban) | |
neko259
|
r804 | class BanAdmin(admin.ModelAdmin): | |
list_display = ('ip', 'can_read') | |||
list_filter = ('can_read',) | |||
neko259
|
r906 | search_fields = ('ip',) |