+ def clean_source_url(self):
+ source_url = self.cleaned_data['source_url'] or None
+ if source_url is not None:
+ same_source = Image.objects.filter(source_url=source_url)
+ if same_source:
+ raise forms.ValidationError(mark_safe(
+ ugettext('Image <a href="%s">already in repository</a>'
+ % same_source.first().get_absolute_url())))
+