##// END OF EJS Templates
Added admin action to ban user that posted given messages
neko259 -
r968:29fca307 default
parent child Browse files
Show More
@@ -1,5 +1,6 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 from django.utils.translation import ugettext_lazy as _
3
4
4
5
5 @admin.register(Post)
6 @admin.register(Post)
@@ -11,6 +12,17 b' class PostAdmin(admin.ModelAdmin):'
11 exclude = ('referenced_posts', 'refmap')
12 exclude = ('referenced_posts', 'refmap')
12 readonly_fields = ('poster_ip', 'thread_new')
13 readonly_fields = ('poster_ip', 'thread_new')
13
14
15 def ban_poster(self, request, queryset):
16 bans = 0
17 for post in queryset:
18 poster_ip = post.poster_ip
19 ban, created = Ban.objects.get_or_create(ip=poster_ip)
20 if created:
21 bans += 1
22 self.message_user(request, _('{} posters were banned').format(bans))
23
24 actions = ['ban_poster']
25
14
26
15 @admin.register(Tag)
27 @admin.register(Tag)
16 class TagAdmin(admin.ModelAdmin):
28 class TagAdmin(admin.ModelAdmin):
@@ -1,5 +1,4 b''
1 from django.db import transaction
1 from django.db import transaction
2 from django.template import RequestContext
3 from django.views.generic import View
2 from django.views.generic import View
4
3
5 from boards import utils
4 from boards import utils
General Comments 0
You need to be logged in to leave comments. Login now