admin.py
38 lines
| 930 B
| text/x-python
|
PythonLexer
/ boards / admin.py
|
r0 | from django.contrib import admin | ||
|
r728 | from boards.models import Post, Tag, Ban, Thread | ||
|
r0 | |||
|
r333 | |||
|
r305 | class PostAdmin(admin.ModelAdmin): | ||
list_display = ('id', 'title', 'text') | ||||
|
r398 | list_filter = ('pub_time', 'thread_new') | ||
|
r305 | search_fields = ('id', 'title', 'text') | ||
|
r333 | |||
|
r305 | class TagAdmin(admin.ModelAdmin): | ||
|
r740 | list_display = ('name',) | ||
|
r305 | |||
|
r883 | |||
|
r604 | class ThreadAdmin(admin.ModelAdmin): | ||
def title(self, obj): | ||||
|
r883 | return obj.get_opening_post().get_title() | ||
|
r604 | |||
def reply_count(self, obj): | ||||
return obj.get_reply_count() | ||||
list_display = ('id', 'title', 'reply_count', 'archived') | ||||
list_filter = ('bump_time', 'archived') | ||||
search_fields = ('id', 'title') | ||||
|
r883 | |||
|
r804 | class BanAdmin(admin.ModelAdmin): | ||
list_display = ('ip', 'can_read') | ||||
list_filter = ('can_read',) | ||||
search_fields = ('ip',) | ||||
|
r305 | admin.site.register(Post, PostAdmin) | ||
admin.site.register(Tag, TagAdmin) | ||||
|
r804 | admin.site.register(Ban, BanAdmin) | ||
|
r604 | admin.site.register(Thread, ThreadAdmin) | ||