##// END OF EJS Templates
Do not allow banning users by not a moderator. Show 403 error when posting as a banned user, not 500
neko259 -
r1902:fa079980 default
parent child Browse files
Show More
1 NO CONTENT: modified file, binary diff hidden
@@ -590,3 +590,6 b' msgstr "\xd0\x9d\xd0\xb5\xd0\xba\xd0\xbe\xd1\x82\xd0\xbe\xd1\x80\xd1\x8b\xd0\xb5 \xd1\x84\xd0\xb0\xd0\xb9\xd0\xbb\xd1\x8b \xd1\x83\xd0\xb6\xd0\xb5 \xd0\xbf\xd1\x80\xd0\xb8\xd1\x81\xd1\x83\xd1\x82\xd1\x81\xd1\x82\xd0\xb2\xd1\x83\xd1\x8e\xd1\x82 \xd0\xbd\xd0\xb0 \xd0\xb1\xd0\xbe\xd1\x80\xd0\xb4\xd0\xb5."'
590 590 msgid "Do not download URLs"
591 591 msgstr "Не загружать ссылки"
592 592
593 msgid "Ban and delete"
594 msgstr "Забанить и удалить"
595
@@ -7,6 +7,7 b' from boards.abstracts.exceptions import '
7 7 from django.db import models, transaction
8 8 from django.utils import timezone
9 9 from django.dispatch import Signal
10 from django.core.exceptions import PermissionDenied
10 11
11 12 import boards
12 13
@@ -43,7 +44,7 b' class PostManager(models.Manager):'
43 44 is_banned = False
44 45
45 46 if is_banned:
46 raise BannedException("This user is banned")
47 raise PermissionDenied()
47 48
48 49 if not tags:
49 50 tags = []
@@ -100,7 +100,7 b''
100 100 visible: {% if post.global_id_id %}true{% else %}false{% endif %}
101 101 },
102 102 banAndDelete: {
103 name: 'Ban and delete',
103 name: '{% trans "Ban and delete" %}',
104 104 callback: function(key, opt) {
105 105 window.location = '{% url 'utils' %}?method=ban_and_delete&post_id={{ post.id }}';
106 106 },
@@ -1,6 +1,8 b''
1 1 from django.shortcuts import redirect
2 2 from django.utils.decorators import method_decorator
3 3 from django.views.decorators.csrf import csrf_protect
4 from django.contrib.auth.decorators import permission_required
5
4 6 from boards.views.base import BaseBoardView, CONTEXT_FORM
5 7 from boards.views.mixins import DispatcherMixin, PARAMETER_METHOD
6 8 from boards.models import Post, Ban
@@ -13,7 +15,7 b' class UtilsView(BaseBoardView, Dispatche'
13 15
14 16 return redirect('index')
15 17
16
18 @permission_required('boards.delete_post')
17 19 def ban_and_delete(self, request):
18 20 post = Post.objects.get(id=request.GET['post_id'])
19 21 Ban.objects.get_or_create(ip=post.poster_ip)
General Comments 0
You need to be logged in to leave comments. Login now