Show More
@@ -47,6 +47,7 b" LABEL_TITLE = _('Title')" | |||||
47 | LABEL_TEXT = _('Text') |
|
47 | LABEL_TEXT = _('Text') | |
48 | LABEL_TAG = _('Tag') |
|
48 | LABEL_TAG = _('Tag') | |
49 | LABEL_SEARCH = _('Search') |
|
49 | LABEL_SEARCH = _('Search') | |
|
50 | LABEL_FILE = _('File') | |||
50 |
|
51 | |||
51 | ERROR_SPEED = 'Please wait %(delay)d second before sending message' |
|
52 | ERROR_SPEED = 'Please wait %(delay)d second before sending message' | |
52 | ERROR_SPEED_PLURAL = 'Please wait %(delay)d seconds before sending message' |
|
53 | ERROR_SPEED_PLURAL = 'Please wait %(delay)d seconds before sending message' | |
@@ -169,7 +170,8 b' class PostForm(NeboardForm):' | |||||
169 | ATTRIBUTE_ROWS: TEXTAREA_ROWS, |
|
170 | ATTRIBUTE_ROWS: TEXTAREA_ROWS, | |
170 | }), |
|
171 | }), | |
171 | required=False, label=LABEL_TEXT) |
|
172 | required=False, label=LABEL_TEXT) | |
172 |
file = UrlFileField(required=False, label= |
|
173 | file_1 = UrlFileField(required=False, label=LABEL_FILE + ' 1') | |
|
174 | file_2 = UrlFileField(required=False, label=LABEL_FILE + ' 2') | |||
173 |
|
175 | |||
174 | # This field is for spam prevention only |
|
176 | # This field is for spam prevention only | |
175 | email = forms.CharField(max_length=100, required=False, label=_('e-mail'), |
|
177 | email = forms.CharField(max_length=100, required=False, label=_('e-mail'), | |
@@ -217,9 +219,13 b' class PostForm(NeboardForm):' | |||||
217 | 'characters') % str(max_length)) |
|
219 | 'characters') % str(max_length)) | |
218 | return text |
|
220 | return text | |
219 |
|
221 | |||
220 | def clean_file(self): |
|
222 | def clean_file_1(self): | |
221 |
|
|
223 | return self._clean_file(self.cleaned_data['file_1']) | |
222 |
|
224 | |||
|
225 | def clean_file_2(self): | |||
|
226 | return self._clean_file(self.cleaned_data['file_2']) | |||
|
227 | ||||
|
228 | def _clean_file(self, file): | |||
223 | if isinstance(file, UploadedFile): |
|
229 | if isinstance(file, UploadedFile): | |
224 | file = self._clean_file_file(file) |
|
230 | file = self._clean_file_file(file) | |
225 | else: |
|
231 | else: | |
@@ -233,7 +239,6 b' class PostForm(NeboardForm):' | |||||
233 |
|
239 | |||
234 | return file |
|
240 | return file | |
235 |
|
241 | |||
236 |
|
||||
237 | def _clean_file_url(self, url): |
|
242 | def _clean_file_url(self, url): | |
238 | file = None |
|
243 | file = None | |
239 |
|
244 | |||
@@ -297,18 +302,30 b' class PostForm(NeboardForm):' | |||||
297 | Gets file from form or URL. |
|
302 | Gets file from form or URL. | |
298 | """ |
|
303 | """ | |
299 |
|
304 | |||
300 |
file = |
|
305 | cleaned_files = [ | |
|
306 | self.cleaned_data['file_1'], | |||
|
307 | self.cleaned_data['file_2'], | |||
|
308 | ] | |||
|
309 | ||||
|
310 | files = [] | |||
|
311 | for file in cleaned_files: | |||
301 | if isinstance(file, UploadedFile): |
|
312 | if isinstance(file, UploadedFile): | |
302 | return [file] |
|
313 | files.append(file) | |
303 | else: |
|
314 | ||
304 |
|
|
315 | return files | |
305 |
|
316 | |||
306 | def get_file_urls(self): |
|
317 | def get_file_urls(self): | |
307 |
file = |
|
318 | cleaned_files = [ | |
|
319 | self.cleaned_data['file_1'], | |||
|
320 | self.cleaned_data['file_2'], | |||
|
321 | ] | |||
|
322 | ||||
|
323 | files = [] | |||
|
324 | for file in cleaned_files: | |||
308 | if type(file) == str: |
|
325 | if type(file) == str: | |
309 | return [file] |
|
326 | files.append(file) | |
310 | else: |
|
327 | ||
311 |
|
|
328 | return files | |
312 |
|
329 | |||
313 | def get_tripcode(self): |
|
330 | def get_tripcode(self): | |
314 | title = self.cleaned_data['title'] |
|
331 | title = self.cleaned_data['title'] |
General Comments 0
You need to be logged in to leave comments.
Login now