Commit 5b76c53249d60b243e09d163be88ceea4104f31f
1 parent
5c06bf58
Exists in
master
and in
2 other branches
Modified models to properly treat some file issues
Showing
1 changed file
with
3 additions
and
9 deletions
Show diff stats
bulletin/models.py
... | ... | @@ -8,23 +8,17 @@ from topics.models import Resource |
8 | 8 | |
9 | 9 | def validate_file_extension(value): |
10 | 10 | valid_formats = [ |
11 | - 'image/jpeg','image/x-citrix-jpeg','image/png','image/x-citrix-png','image/x-png', | |
12 | - 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', | |
13 | 11 | 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', |
14 | - 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', | |
15 | - 'application/vnd.openxmlformats-officedocument.presentationml.presentation', | |
16 | - 'application/vnd.ms-excel','text/html','application/msword','application/vnd.oasis.opendocument.presentation', | |
17 | - 'application/vnd.oasis.opendocument.spreadsheet','application/vnd.oasis.opendocument.text', | |
18 | - 'application/pdf' | |
12 | + 'application/vnd.ms-excel','application/vnd.oasis.opendocument.spreadsheet','text/csv' | |
19 | 13 | ] |
20 | 14 | |
21 | 15 | if hasattr(value.file, 'content_type'): |
22 | 16 | if not value.file.content_type in valid_formats: |
23 | - raise ValidationError(_('Please select a valid file. The uploaded file must have one of the following extensions: .doc, .docx, .html, .jpg, .odp, .ods, .odt, .pdf, .png, .ppt, .pptx, .xlx e .xlsx')) | |
17 | + raise ValidationError(_('Please select a valid file. The uploaded file must have one of the following extensions: .csv, .xlx, .xls and .xlsx')) | |
24 | 18 | |
25 | 19 | class Bulletin(Resource): |
26 | 20 | content = models.TextField(_('Bulletin Content'), blank = True) |
27 | - file_content = models.FileField(_('File'), blank = True, upload_to = 'files/', validators = [validate_file_extension]) | |
21 | + file_content = models.FileField(_('Bulletin Data (Goals)'), blank = True, upload_to = 'files/', validators = [validate_file_extension]) | |
28 | 22 | |
29 | 23 | class Meta: |
30 | 24 | verbose_name = _('Bulletin') | ... | ... |