mirror of
https://github.com/pinry/pinry.git
synced 2026-01-23 23:59:21 +01:00
Added in duplicate URL detection fixing issue #13.
This commit is contained in:
@@ -8,11 +8,15 @@ class PinForm(forms.ModelForm):
|
||||
|
||||
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
|
||||
try:
|
||||
Pin.objects.get(url=data)
|
||||
raise forms.ValidationError("URL has already been pinned!")
|
||||
except Pin.DoesNotExist:
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user