diff --git a/README.md b/README.md index 4b808f5..b63a025 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ for bad code, I'll simply work with you to improve it. Have virtualenv and pip installed. You may also need to have the build dependencies for PIL installed. (If you are on Ubuntu you can do this by typing -"sudo build-dep python-imaging".) +"sudo apt-get build-dep python-imaging".) $ git clone git://github.com/overshard/pinry.git $ cd pinry diff --git a/pinry/pins/forms.py b/pinry/pins/forms.py index 6a4766a..21f929a 100644 --- a/pinry/pins/forms.py +++ b/pinry/pins/forms.py @@ -6,6 +6,14 @@ from .models import Pin class PinForm(forms.ModelForm): url = forms.CharField(label='URL') + def clean_url(self): + data = self.cleaned_data['url'] + image_file_types = ['png', 'gif', 'jpeg', 'jpg'] + file_type = data.split('.')[-1] + if file_type.lower() not in image_file_types: + raise forms.ValidationError("Requested URL is not an image file. Only images are currently supported.") + return data + class Meta: model = Pin exclude = ['image']