##// END OF EJS Templates
Start using cached properties (not everywhere yet, still)
Start using cached properties (not everywhere yet, still)

File last commit:

r903:0de4b802 default
r948:a37f5ca1 default
Show More
utils.py
42 lines | 1.1 KiB | text/x-python | PythonLexer
Ilyas
Added django-simple-capthca support...
r78 """
This module contains helper functions and helper classes.
"""
neko259
Moved imageboard settings to the boards settings module. Added setting to disable archive
r716 import time
neko259
Added centrifuge (websocket) support for thread autoupdate. Only websocket version is supported for now
r853 import hmac
neko259
Moved imageboard settings to the boards settings module. Added setting to disable archive
r716
neko259
Rewriting views to class-based
r542 from django.utils import timezone
wnc_21
Added captcha support
r95
neko259
Fixed captcha design. Added setting to enable or disable captcha. This refs #39
r81 from neboard import settings
Ilyas
Added django-simple-capthca support...
r78
wnc_21
Added captcha support
r95 KEY_CAPTCHA_FAILS = 'key_captcha_fails'
KEY_CAPTCHA_DELAY_TIME = 'key_captcha_delay_time'
KEY_CAPTCHA_LAST_ACTIVITY = 'key_captcha_last_activity'
neko259
Added ban middleware. Now banned user's won't cause load to the server.
r210 def get_client_ip(request):
x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
if x_forwarded_for:
ip = x_forwarded_for.split(',')[-1].strip()
else:
ip = request.META.get('REMOTE_ADDR')
neko259
Rewriting views to class-based
r542 return ip
def datetime_to_epoch(datetime):
return int(time.mktime(timezone.localtime(
datetime,timezone.get_current_timezone()).timetuple())
neko259
Moving neboard to python3 support (no python2 for now until we figure out how...
r765 * 1000000 + datetime.microsecond)
neko259
Added centrifuge (websocket) support for thread autoupdate. Only websocket version is supported for now
r853
def get_websocket_token(user_id='', timestamp=''):
"""
Create token to validate information provided by new connection.
"""
sign = hmac.new(settings.CENTRIFUGE_PROJECT_SECRET.encode())
sign.update(settings.CENTRIFUGE_PROJECT_ID.encode())
sign.update(user_id.encode())
sign.update(timestamp.encode())
token = sign.hexdigest()
return token