Show More
@@ -1,43 +1,46 b'' | |||
|
1 | 1 | from django.contrib import admin |
|
2 | 2 | from boards.models import Post, Tag, Ban, Thread |
|
3 | 3 | |
|
4 | 4 | |
|
5 | 5 | @admin.register(Post) |
|
6 | 6 | class PostAdmin(admin.ModelAdmin): |
|
7 | 7 | |
|
8 | 8 | list_display = ('id', 'title', 'text') |
|
9 | 9 | list_filter = ('pub_time', 'thread_new') |
|
10 | 10 | search_fields = ('id', 'title', 'text') |
|
11 | 11 | exclude = ('referenced_posts', 'refmap') |
|
12 | 12 | readonly_fields = ('poster_ip', 'thread_new') |
|
13 | 13 | |
|
14 | 14 | |
|
15 | 15 | @admin.register(Tag) |
|
16 | 16 | class TagAdmin(admin.ModelAdmin): |
|
17 | 17 | |
|
18 | list_display = ('name',) | |
|
18 | def thread_count(self, obj: Tag) -> int: | |
|
19 | return obj.get_thread_count() | |
|
20 | ||
|
21 | list_display = ('name', 'thread_count') | |
|
19 | 22 | search_fields = ('name',) |
|
20 | 23 | |
|
21 | 24 | |
|
22 | 25 | @admin.register(Thread) |
|
23 | 26 | class ThreadAdmin(admin.ModelAdmin): |
|
24 | 27 | |
|
25 | def title(self, obj): | |
|
28 | def title(self, obj: Thread) -> str: | |
|
26 | 29 | return obj.get_opening_post().get_title() |
|
27 | 30 | |
|
28 | def reply_count(self, obj): | |
|
31 | def reply_count(self, obj: Thread) -> int: | |
|
29 | 32 | return obj.get_reply_count() |
|
30 | 33 | |
|
31 | def ip(self, obj): | |
|
34 | def ip(self, obj: Thread): | |
|
32 | 35 | return obj.get_opening_post().poster_ip |
|
33 | 36 | |
|
34 | 37 | list_display = ('id', 'title', 'reply_count', 'archived', 'ip') |
|
35 | 38 | list_filter = ('bump_time', 'archived', 'bumpable') |
|
36 | 39 | search_fields = ('id', 'title') |
|
37 | 40 | |
|
38 | 41 | |
|
39 | 42 | @admin.register(Ban) |
|
40 | 43 | class BanAdmin(admin.ModelAdmin): |
|
41 | 44 | list_display = ('ip', 'can_read') |
|
42 | 45 | list_filter = ('can_read',) |
|
43 | 46 | search_fields = ('ip',) No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now