##// END OF EJS Templates
Don't list all threads to filter posts by
neko259 -
r969:783c920b default
parent child Browse files
Show More
@@ -1,59 +1,59 b''
1 1 from django.contrib import admin
2 2 from boards.models import Post, Tag, Ban, Thread
3 3 from django.utils.translation import ugettext_lazy as _
4 4
5 5
6 6 @admin.register(Post)
7 7 class PostAdmin(admin.ModelAdmin):
8 8
9 9 list_display = ('id', 'title', 'text')
10 list_filter = ('pub_time', 'thread_new')
10 list_filter = ('pub_time',)
11 11 search_fields = ('id', 'title', 'text')
12 12 exclude = ('referenced_posts', 'refmap')
13 13 readonly_fields = ('poster_ip', 'thread_new')
14 14
15 15 def ban_poster(self, request, queryset):
16 16 bans = 0
17 17 for post in queryset:
18 18 poster_ip = post.poster_ip
19 19 ban, created = Ban.objects.get_or_create(ip=poster_ip)
20 20 if created:
21 21 bans += 1
22 22 self.message_user(request, _('{} posters were banned').format(bans))
23 23
24 24 actions = ['ban_poster']
25 25
26 26
27 27 @admin.register(Tag)
28 28 class TagAdmin(admin.ModelAdmin):
29 29
30 30 def thread_count(self, obj: Tag) -> int:
31 31 return obj.get_thread_count()
32 32
33 33 list_display = ('name', 'thread_count')
34 34 search_fields = ('name',)
35 35
36 36
37 37 @admin.register(Thread)
38 38 class ThreadAdmin(admin.ModelAdmin):
39 39
40 40 def title(self, obj: Thread) -> str:
41 41 return obj.get_opening_post().get_title()
42 42
43 43 def reply_count(self, obj: Thread) -> int:
44 44 return obj.get_reply_count()
45 45
46 46 def ip(self, obj: Thread):
47 47 return obj.get_opening_post().poster_ip
48 48
49 49 list_display = ('id', 'title', 'reply_count', 'archived', 'ip')
50 50 list_filter = ('bump_time', 'archived', 'bumpable')
51 51 search_fields = ('id', 'title')
52 52 filter_horizontal = ('tags',)
53 53
54 54
55 55 @admin.register(Ban)
56 56 class BanAdmin(admin.ModelAdmin):
57 57 list_display = ('ip', 'can_read')
58 58 list_filter = ('can_read',)
59 59 search_fields = ('ip',)
General Comments 0
You need to be logged in to leave comments. Login now