Skip to content

Commit

Permalink
FileLinkForm: fix duplicate check (#3311)
Browse files Browse the repository at this point in the history
Merged from: Minnozz/filelink-duplicate-check.
  • Loading branch information
dato authored Mar 11, 2024
2 parents 6dfb500 + b68a4cc commit 304c478
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions bookwyrm/forms/links.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
""" using django model forms """

from urllib.parse import urlparse

from django.utils.translation import gettext_lazy as _
Expand Down Expand Up @@ -37,10 +38,9 @@ def clean(self):
),
)
if (
not self.instance
and models.FileLink.objects.filter(
url=url, book=book, filetype=filetype
).exists()
models.FileLink.objects.filter(url=url, book=book, filetype=filetype)
.exclude(pk=self.instance)
.exists()
):
# pylint: disable=line-too-long
self.add_error(
Expand Down

0 comments on commit 304c478

Please sign in to comment.