Show More
@@ -6,6 +6,8 b' from django.utils import timezone' | |||
|
6 | 6 | from boards import utils |
|
7 | 7 | from boards.models import Ban |
|
8 | 8 | |
|
9 | PATH_BANNED = '/banned/' | |
|
10 | ||
|
9 | 11 | SESSION_TIMEZONE = 'django_timezone' |
|
10 | 12 | |
|
11 | 13 | RESPONSE_CONTENT_TYPE = 'Content-Type' |
@@ -25,14 +27,15 b' class BanMiddleware:' | |||
|
25 | 27 | def __call__(self, request): |
|
26 | 28 | response = self.get_response(request) |
|
27 | 29 | |
|
28 |
if request.path != |
|
|
30 | if request.path != PATH_BANNED: | |
|
29 | 31 | ip = utils.get_client_ip(request) |
|
30 | bans = Ban.objects.filter(ip=ip) | |
|
32 | try: | |
|
33 | ban = Ban.objects.get(ip=ip) | |
|
31 | 34 | |
|
32 | if bans.exists(): | |
|
33 | ban = bans[0] | |
|
34 | 35 | if not ban.can_read: |
|
35 | 36 | return redirect('banned') |
|
37 | except Ban.DoesNotExist: | |
|
38 | pass | |
|
36 | 39 | |
|
37 | 40 | return response |
|
38 | 41 |
General Comments 0
You need to be logged in to leave comments.
Login now