##// END OF EJS Templates
Added support for youtu.be links. Show file size when size validation failed
neko259 -
r1433:8bc8ced0 default
parent child Browse files
Show More
@@ -356,8 +356,7 b' class PostForm(NeboardForm):'
356 356 except forms.ValidationError as e:
357 357 raise e
358 358 except Exception as e:
359 # Just return no file
360 pass
359 raise forms.ValidationError(e)
361 360
362 361 def _validate_hash(self, timestamp: str, iteration: str, guess: str, message: str):
363 362 post_time = timezone.datetime.fromtimestamp(
1 NO CONTENT: modified file, binary diff hidden
@@ -488,8 +488,8 b' msgstr "\xd0\x9e\xd0\xba"'
488 488
489 489 #: utils.py:120
490 490 #, python-format
491 msgid "File must be less than %s bytes"
492 msgstr "Файл должен быть менее %s байт"
491 msgid "File must be less than %s but is %s."
492 msgstr "Файл должен быть менее %s, но его размер %s."
493 493
494 494 msgid "Please wait %(delay)d second before sending message"
495 495 msgid_plural "Please wait %(delay)d seconds before sending message"
@@ -17,7 +17,7 b" HEADER_CONTENT_TYPE = 'content-type'"
17 17
18 18 FILE_DOWNLOAD_CHUNK_BYTES = 200000
19 19
20 YOUTUBE_URL = re.compile(r'https?://www\.youtube\.com/watch\?v=\w+')
20 YOUTUBE_URL = re.compile(r'https?://(www\.youtube\.com/watch\?v=|youtu.be/)\w+')
21 21
22 22
23 23 class Downloader:
@@ -9,6 +9,7 b' import hmac'
9 9 from django.core.cache import cache
10 10 from django.db.models import Model
11 11 from django import forms
12 from django.template.defaultfilters import filesizeformat
12 13 from django.utils import timezone
13 14 from django.utils.translation import ugettext_lazy as _
14 15 import magic
@@ -118,8 +119,8 b' def validate_file_size(size: int):'
118 119 max_size = boards.settings.get_int('Forms', 'MaxFileSize')
119 120 if size > max_size:
120 121 raise forms.ValidationError(
121 _('File must be less than %s bytes')
122 % str(max_size))
122 _('File must be less than %s but is %s.')
123 % (filesizeformat(max_size), filesizeformat(size)))
123 124
124 125
125 126 def get_extension(filename):
General Comments 0
You need to be logged in to leave comments. Login now