Skip to content

Commit

Permalink
controle de l'extention du fichier
Browse files Browse the repository at this point in the history
  • Loading branch information
firm1 committed Sep 1, 2014
1 parent 8a41a39 commit c846ed4
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions zds/gallery/forms.py
Expand Up @@ -171,6 +171,20 @@ def __init__(self, *args, **kwargs):
u'href="{{ gallery.get_absolute_url }}">Annuler</a>'),
),
)

def clean(self):
cleaned_data = super(ArchiveImageForm, self).clean()

file = cleaned_data.get('file')
extension=file.name.split('.')[-1]

if extension != "zip":
self._errors['file'] = self.error_class(
[u"Le champ n'accepte que les fichiers zip"])
if 'file' in cleaned_data:
del cleaned_data['file']

return cleaned_data


class UpdateImageForm(ImageForm):
Expand Down

0 comments on commit c846ed4

Please sign in to comment.