FileLinkForm: fix duplicate check

This commit is contained in:
Bart Schuurmans 2024-03-09 15:39:52 +01:00
parent 9e7b040b73
commit 8d018b872f

View file

@ -1,4 +1,5 @@
""" using django model forms """ """ using django model forms """
from urllib.parse import urlparse from urllib.parse import urlparse
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
@ -37,10 +38,9 @@ class FileLinkForm(CustomForm):
), ),
) )
if ( if (
not self.instance models.FileLink.objects.filter(url=url, book=book, filetype=filetype)
and models.FileLink.objects.filter( .exclude(pk=self.instance)
url=url, book=book, filetype=filetype .exists()
).exists()
): ):
# pylint: disable=line-too-long # pylint: disable=line-too-long
self.add_error( self.add_error(