(self)
| 55 | return url |
| 56 | |
| 57 | def clean(self): |
| 58 | url = self.cleaned_data.get("url") |
| 59 | sites = self.cleaned_data.get("sites") |
| 60 | |
| 61 | same_url = FlatPage.objects.filter(url=url) |
| 62 | if self.instance.pk: |
| 63 | same_url = same_url.exclude(pk=self.instance.pk) |
| 64 | |
| 65 | if sites and same_url.filter(sites__in=sites).exists(): |
| 66 | for site in sites: |
| 67 | if same_url.filter(sites=site).exists(): |
| 68 | raise ValidationError( |
| 69 | _("Flatpage with url %(url)s already exists for site %(site)s"), |
| 70 | code="duplicate_url", |
| 71 | params={"url": url, "site": site}, |
| 72 | ) |
| 73 | |
| 74 | return super().clean() |
nothing calls this directly
no test coverage detected