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