##// END OF EJS Templates
Allow loading files and links together
neko259 -
r1762:76498950 default
parent child Browse files
Show More
@@ -296,18 +296,13 b' class PostForm(NeboardForm):'
296 files = []
296 files = []
297
297
298 max_file_count = board_settings.get_int(SECTION_FORMS, 'MaxFileCount')
298 max_file_count = board_settings.get_int(SECTION_FORMS, 'MaxFileCount')
299 if type(inputs) == list:
299 if len(inputs) > max_file_count:
300 if len(inputs) > max_file_count:
300 raise forms.ValidationError(ERROR_MANY_FILES)
301 raise forms.ValidationError(ERROR_MANY_FILES)
301 for input in inputs:
302 for file in inputs:
302 if isinstance(input, UploadedFile):
303 files.append(self._clean_file_file(file))
303 files.append(self._clean_file_file(input))
304 elif inputs:
304 else:
305 inputs = inputs.replace('\r\n', '\n')
305 files.append(self._clean_file_url(input))
306 url_list = inputs.split('\n')
307 if len(url_list) > max_file_count:
308 raise forms.ValidationError(ERROR_MANY_FILES)
309 for url in url_list:
310 files.append(self._clean_file_url(url))
311
306
312 return files
307 return files
313
308
@@ -78,6 +78,13 b' class UrlFileField(forms.MultiValueField'
78 require_all_fields=False, *args, **kwargs)
78 require_all_fields=False, *args, **kwargs)
79
79
80 def compress(self, data_list):
80 def compress(self, data_list):
81 if data_list and len(data_list) >= 2:
81 all_data = []
82 return data_list[0] or data_list[1]
82 for data in data_list:
83 if type(data) == list:
84 all_data += data
85 elif type(data) == str:
86 input = data.replace('\r\n', '\n')
87 url_list = input.split('\n')
88 all_data += url_list
83
89
90 return all_data
General Comments 0
You need to be logged in to leave comments. Login now