mirror of
https://github.com/pinry/pinry.git
synced 2026-01-15 03:32:05 +01:00
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:
@@ -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
|
||||
|
||||
@@ -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']
|
||||
|
||||
Reference in New Issue
Block a user