##// END OF EJS Templates
Removed old websocket related code (since websockets are no longer supported
neko259 -
r1948:be2714ff default
parent child Browse files
Show More
@@ -1,24 +1,22 b''
1 1 """
2 2 This module contains helper functions and helper classes.
3 3 """
4 import hashlib
4 import time
5 5 import uuid
6 6
7 from boards.abstracts.constants import FILE_DIRECTORY
8 from random import random
9 import time
7 import hashlib
10 8 import hmac
11
9 import magic
10 import os
11 from django import forms
12 12 from django.core.cache import cache
13 13 from django.db.models import Model
14 from django import forms
15 14 from django.template.defaultfilters import filesizeformat
16 15 from django.utils import timezone
17 16 from django.utils.translation import ugettext_lazy as _
18 import magic
19 import os
20 17
21 18 import boards
19 from boards.abstracts.constants import FILE_DIRECTORY
22 20 from boards.settings import get_bool
23 21 from neboard import settings
24 22
@@ -58,20 +56,6 b' def datetime_to_epoch(datetime):'
58 56 * 1000000 + datetime.microsecond)
59 57
60 58
61 def get_websocket_token(user_id='', timestamp=''):
62 """
63 Create token to validate information provided by new connection.
64 """
65
66 sign = hmac.new(settings.CENTRIFUGE_PROJECT_SECRET.encode())
67 sign.update(settings.CENTRIFUGE_PROJECT_ID.encode())
68 sign.update(user_id.encode())
69 sign.update(timestamp.encode())
70 token = sign.hexdigest()
71
72 return token
73
74
75 59 # TODO Test this carefully
76 60 def cached_result(key_method=None):
77 61 """
@@ -117,7 +101,7 b' def get_file_hash(file) -> str:'
117 101
118 102 def validate_file_size(size: int):
119 103 max_size = boards.settings.get_int('Forms', 'MaxFileSize')
120 if max_size > 0 and size > max_size:
104 if 0 < max_size < size:
121 105 raise forms.ValidationError(
122 106 _('File must be less than %s but is %s.')
123 107 % (filesizeformat(max_size), filesizeformat(size)))
General Comments 0
You need to be logged in to leave comments. Login now