Correct typo in README, do basic form URL validation to make sure it is an image, the only thing Pinry currently supports.

This commit is contained in:
Isaac Bythewood
2012-04-27 02:48:49 +00:00
parent 273cbd678c
commit cd53e3ff1d
2 changed files with 9 additions and 1 deletions

View File

@@ -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

View File

@@ -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']