##// END OF EJS Templates
Added anonymous mode in which the board does not save poster IP addresses
neko259 -
r1362:9b48eb30 default
parent child Browse files
Show More
@@ -17,6 +17,7 b' LimitPostingSpeed = false'
17 MaxPostsPerThread = 10
17 MaxPostsPerThread = 10
18 # Old posts will be archived or deleted if this value is reached
18 # Old posts will be archived or deleted if this value is reached
19 MaxThreadCount = 5
19 MaxThreadCount = 5
20 AnonymousMode = false
20
21
21 [View]
22 [View]
22 DefaultTheme = md
23 DefaultTheme = md
@@ -35,7 +35,8 b' class PostManager(models.Manager):'
35 Creates new post
35 Creates new post
36 """
36 """
37
37
38 is_banned = Ban.objects.filter(ip=ip).exists()
38 if not utils.is_anonymous_mode():
39 is_banned = Ban.objects.filter(ip=ip).exists()
39
40
40 # TODO Raise specific exception and catch it in the views
41 # TODO Raise specific exception and catch it in the views
41 if is_banned:
42 if is_banned:
@@ -11,7 +11,9 b' from django import forms'
11
11
12 from django.utils import timezone
12 from django.utils import timezone
13 from django.utils.translation import ugettext_lazy as _
13 from django.utils.translation import ugettext_lazy as _
14
14 import boards
15 import boards
16 from boards.settings import get_bool
15
17
16 from neboard import settings
18 from neboard import settings
17
19
@@ -19,12 +21,28 b' from neboard import settings'
19 CACHE_KEY_DELIMITER = '_'
21 CACHE_KEY_DELIMITER = '_'
20 PERMISSION_MODERATE = 'moderation'
22 PERMISSION_MODERATE = 'moderation'
21
23
24 HTTP_FORWARDED = 'HTTP_X_FORWARDED_FOR'
25 META_REMOTE_ADDR = 'REMOTE_ADDR'
26
27 SETTING_MESSAGES = 'Messages'
28 SETTING_ANON_MODE = 'AnonymousMode'
29
30 ANON_IP = '127.0.0.1'
31
32
33 def is_anonymous_mode():
34 return get_bool(SETTING_MESSAGES, SETTING_ANON_MODE)
35
36
22 def get_client_ip(request):
37 def get_client_ip(request):
23 x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
38 if is_anonymous_mode():
24 if x_forwarded_for:
39 ip = ANON_IP
25 ip = x_forwarded_for.split(',')[-1].strip()
26 else:
40 else:
27 ip = request.META.get('REMOTE_ADDR')
41 x_forwarded_for = request.META.get(HTTP_FORWARDED)
42 if x_forwarded_for:
43 ip = x_forwarded_for.split(',')[-1].strip()
44 else:
45 ip = request.META.get(META_REMOTE_ADDR)
28 return ip
46 return ip
29
47
30
48
General Comments 0
You need to be logged in to leave comments. Login now