From e37982d28506111e46d124b418094b6dceca8d2b Mon Sep 17 00:00:00 2001 From: Willi Hohenstein Date: Wed, 2 Feb 2022 19:35:26 +0100 Subject: [PATCH 1/4] added domain pending or blocked check fixes #1850 --- bookwyrm/forms.py | 13 +++ locale/de_DE/LC_MESSAGES/django.po | 179 +++++++++++++++++++---------- locale/en_US/LC_MESSAGES/django.po | 38 +++--- 3 files changed, 154 insertions(+), 76 deletions(-) diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py index e442dbf45..1b13598b0 100644 --- a/bookwyrm/forms.py +++ b/bookwyrm/forms.py @@ -1,6 +1,7 @@ """ using django model forms """ import datetime from collections import defaultdict +from urllib.parse import urlparse from django import forms from django.forms import ModelForm, PasswordInput, widgets, ChoiceField @@ -226,6 +227,18 @@ class FileLinkForm(CustomForm): class Meta: model = models.FileLink fields = ["url", "filetype", "availability", "book", "added_by"] + + def clean(self): + """make sure the domain isn't blocked or pending""" + cleaned_data = super().clean() + url = cleaned_data.get('url') + domain = urlparse(url).netloc + if models.LinkDomain.objects.filter(domain=domain).exists(): + status = models.LinkDomain.objects.get(domain=domain).status + if status == 'blocked': + self.add_error("url", _("Domain is blocked. Don't try this url again.")) + elif status == 'pending': + self.add_error("url", _("Domain already pending. Please try later.")) class EditionForm(CustomForm): diff --git a/locale/de_DE/LC_MESSAGES/django.po b/locale/de_DE/LC_MESSAGES/django.po index bb05219b3..8b4e11d45 100644 --- a/locale/de_DE/LC_MESSAGES/django.po +++ b/locale/de_DE/LC_MESSAGES/django.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: bookwyrm\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-01-24 17:25+0000\n" +"POT-Creation-Date: 2022-02-02 18:03+0000\n" "PO-Revision-Date: 2022-01-24 18:55\n" "Last-Translator: Mouse Reeve \n" "Language-Team: German\n" @@ -17,62 +17,70 @@ msgstr "" "X-Crowdin-File: /[bookwyrm-social.bookwyrm] main/locale/en_US/LC_MESSAGES/django.po\n" "X-Crowdin-File-ID: 1553\n" -#: bookwyrm/forms.py:365 +#: bookwyrm/forms.py:239 +msgid "Domain is blocked. Don't try this url again." +msgstr "Die Domäne ist blockiert. Versuchen Sie diese Url nicht mehr." + +#: bookwyrm/forms.py:241 +msgid "Domain already pending. Please try later." +msgstr "Die Domain ist bereits in Bearbeitung. Bitte versuchen Sie es später." + +#: bookwyrm/forms.py:378 msgid "A user with this email already exists." msgstr "Es existiert bereits ein Benutzer*inkonto mit dieser E-Mail-Adresse." -#: bookwyrm/forms.py:379 +#: bookwyrm/forms.py:392 msgid "One Day" msgstr "Ein Tag" -#: bookwyrm/forms.py:380 +#: bookwyrm/forms.py:393 msgid "One Week" msgstr "Eine Woche" -#: bookwyrm/forms.py:381 +#: bookwyrm/forms.py:394 msgid "One Month" msgstr "Ein Monat" -#: bookwyrm/forms.py:382 +#: bookwyrm/forms.py:395 msgid "Does Not Expire" msgstr "Läuft nicht ab" -#: bookwyrm/forms.py:386 +#: bookwyrm/forms.py:399 #, python-brace-format msgid "{i} uses" msgstr "{i}-mal verwendbar" -#: bookwyrm/forms.py:387 +#: bookwyrm/forms.py:400 msgid "Unlimited" msgstr "Unbegrenzt" -#: bookwyrm/forms.py:483 +#: bookwyrm/forms.py:502 msgid "List Order" msgstr "Reihenfolge der Liste" -#: bookwyrm/forms.py:484 +#: bookwyrm/forms.py:503 msgid "Book Title" msgstr "Buchtitel" -#: bookwyrm/forms.py:485 bookwyrm/templates/shelf/shelf.html:155 +#: bookwyrm/forms.py:504 bookwyrm/templates/shelf/shelf.html:155 #: bookwyrm/templates/shelf/shelf.html:187 #: bookwyrm/templates/snippets/create_status/review.html:32 msgid "Rating" msgstr "Bewertung" -#: bookwyrm/forms.py:487 bookwyrm/templates/lists/list.html:135 +#: bookwyrm/forms.py:506 bookwyrm/templates/lists/list.html:177 msgid "Sort By" msgstr "Sortieren nach" -#: bookwyrm/forms.py:491 +#: bookwyrm/forms.py:510 msgid "Ascending" msgstr "Aufsteigend" -#: bookwyrm/forms.py:492 +#: bookwyrm/forms.py:511 msgid "Descending" msgstr "Absteigend" -#: bookwyrm/forms.py:505 +#: bookwyrm/forms.py:524 msgid "Reading finish date cannot be before start date." msgstr "Enddatum darf nicht vor dem Startdatum liegen." @@ -283,10 +291,14 @@ msgid "Português Europeu (European Portuguese)" msgstr "Português Europeu (Portugiesisch)" #: bookwyrm/settings.py:258 +msgid "Swedish (Svenska)" +msgstr "Swedish (Schwedisch)" + +#: bookwyrm/settings.py:259 msgid "简体中文 (Simplified Chinese)" msgstr "简体中文 (vereinfachtes Chinesisch)" -#: bookwyrm/settings.py:259 +#: bookwyrm/settings.py:260 msgid "繁體中文 (Traditional Chinese)" msgstr "繁體中文 (Chinesisch, traditionell)" @@ -424,7 +436,7 @@ msgid "Copy address" msgstr "Adresse kopieren" #: bookwyrm/templates/annual_summary/layout.html:68 -#: bookwyrm/templates/lists/list.html:231 +#: bookwyrm/templates/lists/list.html:269 msgid "Copied!" msgstr "Kopiert!" @@ -689,6 +701,7 @@ msgstr "ISNI:" #: bookwyrm/templates/book/file_links/edit_links.html:82 #: bookwyrm/templates/groups/form.html:30 #: bookwyrm/templates/lists/bookmark_button.html:15 +#: bookwyrm/templates/lists/edit_item_form.html:15 #: bookwyrm/templates/lists/form.html:130 #: bookwyrm/templates/preferences/edit_user.html:124 #: bookwyrm/templates/readthrough/readthrough_modal.html:72 @@ -712,6 +725,7 @@ msgstr "Speichern" #: bookwyrm/templates/book/file_links/verification_modal.html:21 #: bookwyrm/templates/book/sync_modal.html:23 #: bookwyrm/templates/groups/delete_group_modal.html:17 +#: bookwyrm/templates/lists/add_item_modal.html:42 #: bookwyrm/templates/lists/delete_list_modal.html:18 #: bookwyrm/templates/readthrough/delete_readthrough_modal.html:23 #: bookwyrm/templates/readthrough/readthrough_modal.html:74 @@ -816,7 +830,7 @@ msgstr "Orte" #: bookwyrm/templates/book/book.html:348 #: bookwyrm/templates/groups/group.html:19 bookwyrm/templates/layout.html:74 -#: bookwyrm/templates/lists/curate.html:7 bookwyrm/templates/lists/list.html:11 +#: bookwyrm/templates/lists/curate.html:8 bookwyrm/templates/lists/list.html:12 #: bookwyrm/templates/lists/lists.html:5 bookwyrm/templates/lists/lists.html:12 #: bookwyrm/templates/search/layout.html:25 #: bookwyrm/templates/search/layout.html:50 @@ -830,7 +844,8 @@ msgstr "Zur Liste hinzufügen" #: bookwyrm/templates/book/book.html:369 #: bookwyrm/templates/book/cover_add_modal.html:31 -#: bookwyrm/templates/lists/list.html:209 +#: bookwyrm/templates/lists/add_item_modal.html:37 +#: bookwyrm/templates/lists/list.html:247 #: bookwyrm/templates/settings/email_blocklist/domain_form.html:24 #: bookwyrm/templates/settings/ip_blocklist/ip_address_form.html:31 msgid "Add" @@ -1551,16 +1566,11 @@ msgstr "Alle Nachrichten" msgid "You have no messages right now." msgstr "Du hast momentan keine Nachrichten." -#: bookwyrm/templates/feed/feed.html:28 -#, python-format -msgid "load 0 unread status(es)" -msgstr "lade 0 ungelesene Statusmeldung(en)" - -#: bookwyrm/templates/feed/feed.html:51 +#: bookwyrm/templates/feed/feed.html:54 msgid "There aren't any activities right now! Try following a user to get started" msgstr "Hier sind noch keine Aktivitäten! Folge Anderen, um loszulegen" -#: bookwyrm/templates/feed/feed.html:52 +#: bookwyrm/templates/feed/feed.html:55 msgid "Alternatively, you can try enabling more status types" msgstr "Alternativ könntest du auch weitere Statustypen aktivieren" @@ -1649,7 +1659,7 @@ msgid "What are you reading?" msgstr "Was liest du gerade?" #: bookwyrm/templates/get_started/books.html:9 -#: bookwyrm/templates/layout.html:47 bookwyrm/templates/lists/list.html:163 +#: bookwyrm/templates/layout.html:47 bookwyrm/templates/lists/list.html:205 msgid "Search for a book" msgstr "Nach einem Buch suchen" @@ -1669,7 +1679,7 @@ msgstr "Du kannst Bücher hinzufügen, wenn du %(site_name)s benutzt." #: bookwyrm/templates/get_started/users.html:19 #: bookwyrm/templates/groups/members.html:15 #: bookwyrm/templates/groups/members.html:16 bookwyrm/templates/layout.html:53 -#: bookwyrm/templates/layout.html:54 bookwyrm/templates/lists/list.html:167 +#: bookwyrm/templates/layout.html:54 bookwyrm/templates/lists/list.html:209 #: bookwyrm/templates/search/layout.html:4 #: bookwyrm/templates/search/layout.html:9 msgid "Search" @@ -1685,7 +1695,7 @@ msgid "Popular on %(site_name)s" msgstr "Auf %(site_name)s beliebt" #: bookwyrm/templates/get_started/books.html:58 -#: bookwyrm/templates/lists/list.html:180 +#: bookwyrm/templates/lists/list.html:222 msgid "No books found" msgstr "Keine Bücher gefunden" @@ -2034,7 +2044,7 @@ msgid "Approving a suggestion will permanently add the suggested book to your sh msgstr "Die Genehmigung eines Vorschlags wird das vorgeschlagene Buch dauerhaft in deine Regale aufnehmen und deine Lesedaten, Besprechungen und Bewertungen mit diesem Buch verknüpfen." #: bookwyrm/templates/import/manual_review.html:58 -#: bookwyrm/templates/lists/curate.html:59 +#: bookwyrm/templates/lists/curate.html:71 #: bookwyrm/templates/settings/link_domains/link_domains.html:76 msgid "Approve" msgstr "Bestätigen" @@ -2245,6 +2255,23 @@ msgstr "%(site_name)s auf %(suppo msgid "BookWyrm's source code is freely available. You can contribute or report issues on GitHub." msgstr "BookWyrm ist open source Software. Du kannst dich auf GitHub beteiligen oder etwas melden." +#: bookwyrm/templates/lists/add_item_modal.html:8 +#, fuzzy, python-format +#| msgid "Add read dates for \"%(title)s\"" +msgid "Add \"%(title)s\" to this list" +msgstr "„%(title)s“ zu dieser Liste hinzufügen" + +#: bookwyrm/templates/lists/add_item_modal.html:12 +#, fuzzy, python-format +#| msgid "Start \"%(book_title)s\"" +msgid "Suggest \"%(title)s\" for this list" +msgstr "„%(book_title)s“ für diese Liste vorschlagen" + +#: bookwyrm/templates/lists/add_item_modal.html:39 +#: bookwyrm/templates/lists/list.html:249 +msgid "Suggest" +msgstr "Vorschlagen" + #: bookwyrm/templates/lists/bookmark_button.html:30 msgid "Un-save" msgstr "Speichern rückgängig machen" @@ -2264,23 +2291,30 @@ msgstr "Erstellt und betreut von %(username)s" msgid "Created by %(username)s" msgstr "Erstellt von %(username)s" -#: bookwyrm/templates/lists/curate.html:11 +#: bookwyrm/templates/lists/curate.html:12 msgid "Curate" msgstr "Kuratieren" -#: bookwyrm/templates/lists/curate.html:20 +#: bookwyrm/templates/lists/curate.html:21 msgid "Pending Books" msgstr "Unbestätigte Bücher" -#: bookwyrm/templates/lists/curate.html:23 +#: bookwyrm/templates/lists/curate.html:24 msgid "You're all set!" msgstr "Du bist soweit!" -#: bookwyrm/templates/lists/curate.html:43 +#: bookwyrm/templates/lists/curate.html:45 +#: bookwyrm/templates/lists/list.html:83 +#, fuzzy, python-format +#| msgid "Added by %(username)s" +msgid "%(username)s says:" +msgstr "%(username)s sagt:" + +#: bookwyrm/templates/lists/curate.html:55 msgid "Suggested by" msgstr "Vorgeschlagen von" -#: bookwyrm/templates/lists/curate.html:65 +#: bookwyrm/templates/lists/curate.html:77 msgid "Discard" msgstr "Ablehnen" @@ -2304,7 +2338,7 @@ msgid "on %(site_name)s" msgstr "auf %(site_name)s" #: bookwyrm/templates/lists/embed-list.html:27 -#: bookwyrm/templates/lists/list.html:43 +#: bookwyrm/templates/lists/list.html:44 msgid "This list is currently empty" msgstr "Diese Liste ist momentan leer" @@ -2365,76 +2399,93 @@ msgstr "Gruppe erstellen" msgid "Delete list" msgstr "Liste löschen" -#: bookwyrm/templates/lists/list.html:35 +#: bookwyrm/templates/lists/item_notes_field.html:7 +#: bookwyrm/templates/settings/federation/edit_instance.html:74 +msgid "Notes:" +msgstr "Anmerkungen:" + +#: bookwyrm/templates/lists/item_notes_field.html:19 +msgid "An optional note that will be displayed with the book." +msgstr "Eine optionale Anmerkung, die mit dem Buch angezeigt wird." + +#: bookwyrm/templates/lists/list.html:36 msgid "You successfully suggested a book for this list!" msgstr "Dein Buchvorschlag wurde dieser Liste hinzugefügt!" -#: bookwyrm/templates/lists/list.html:37 +#: bookwyrm/templates/lists/list.html:38 msgid "You successfully added a book to this list!" msgstr "Du hast ein Buch zu dieser Liste hinzugefügt!" -#: bookwyrm/templates/lists/list.html:81 +#: bookwyrm/templates/lists/list.html:96 +#, fuzzy +#| msgid "Edit links" +msgid "Edit notes" +msgstr "Anmerkungen bearbeiten" + +#: bookwyrm/templates/lists/list.html:111 +#, fuzzy +#| msgid "Add cover" +msgid "Add notes" +msgstr "Anmerkungen hinzufügen" + +#: bookwyrm/templates/lists/list.html:123 #, python-format msgid "Added by %(username)s" msgstr "Hinzugefügt von %(username)s" -#: bookwyrm/templates/lists/list.html:96 +#: bookwyrm/templates/lists/list.html:138 msgid "List position" msgstr "Listenposition" -#: bookwyrm/templates/lists/list.html:102 +#: bookwyrm/templates/lists/list.html:144 #: bookwyrm/templates/settings/link_domains/edit_domain_modal.html:21 msgid "Set" msgstr "Übernehmen" -#: bookwyrm/templates/lists/list.html:117 +#: bookwyrm/templates/lists/list.html:159 #: bookwyrm/templates/snippets/remove_from_group_button.html:20 msgid "Remove" msgstr "Entfernen" -#: bookwyrm/templates/lists/list.html:131 -#: bookwyrm/templates/lists/list.html:148 +#: bookwyrm/templates/lists/list.html:173 +#: bookwyrm/templates/lists/list.html:190 msgid "Sort List" msgstr "Liste sortieren" -#: bookwyrm/templates/lists/list.html:141 +#: bookwyrm/templates/lists/list.html:183 msgid "Direction" msgstr "Reihenfolge" -#: bookwyrm/templates/lists/list.html:155 +#: bookwyrm/templates/lists/list.html:197 msgid "Add Books" msgstr "Bücher hinzufügen" -#: bookwyrm/templates/lists/list.html:157 +#: bookwyrm/templates/lists/list.html:199 msgid "Suggest Books" msgstr "Bücher vorschlagen" -#: bookwyrm/templates/lists/list.html:168 +#: bookwyrm/templates/lists/list.html:210 msgid "search" msgstr "suchen" -#: bookwyrm/templates/lists/list.html:174 +#: bookwyrm/templates/lists/list.html:216 msgid "Clear search" msgstr "Suche zurücksetzen" -#: bookwyrm/templates/lists/list.html:179 +#: bookwyrm/templates/lists/list.html:221 #, python-format msgid "No books found matching the query \"%(query)s\"" msgstr "Keine passenden Bücher zu „%(query)s“ gefunden" -#: bookwyrm/templates/lists/list.html:211 -msgid "Suggest" -msgstr "Vorschlagen" - -#: bookwyrm/templates/lists/list.html:222 +#: bookwyrm/templates/lists/list.html:260 msgid "Embed this list on a website" msgstr "Diese Liste auf einer Webseite einbetten" -#: bookwyrm/templates/lists/list.html:230 +#: bookwyrm/templates/lists/list.html:268 msgid "Copy embed code" msgstr "Code zum einbetten kopieren" -#: bookwyrm/templates/lists/list.html:232 +#: bookwyrm/templates/lists/list.html:270 #, python-format msgid "%(list_name)s, a list by %(owner)s on %(site_name)s" msgstr "%(list_name)s, eine Liste von %(owner)s auf %(site_name)s" @@ -3222,10 +3273,6 @@ msgstr "Software:" msgid "Version:" msgstr "Version:" -#: bookwyrm/templates/settings/federation/edit_instance.html:74 -msgid "Notes:" -msgstr "Anmerkungen:" - #: bookwyrm/templates/settings/federation/instance.html:19 msgid "Details" msgstr "Details" @@ -4631,3 +4678,13 @@ msgstr "Ein Link zum Zurücksetzen des Passworts wurde an {email} gesendet" msgid "Status updates from {obj.display_name}" msgstr "Status -Updates von {obj.display_name}" +#: bookwyrm/views/updates.py:45 +#, python-format +msgid "Load %(count)d unread status" +msgid_plural "Load %(count)d unread statuses" +msgstr[0] "" +msgstr[1] "" + +#, python-format +#~ msgid "load 0 unread status(es)" +#~ msgstr "lade 0 ungelesene Statusmeldung(en)" diff --git a/locale/en_US/LC_MESSAGES/django.po b/locale/en_US/LC_MESSAGES/django.po index 6895c534b..78afefa79 100644 --- a/locale/en_US/LC_MESSAGES/django.po +++ b/locale/en_US/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-01-28 02:50+0000\n" +"POT-Creation-Date: 2022-02-02 18:03+0000\n" "PO-Revision-Date: 2021-02-28 17:19-0800\n" "Last-Translator: Mouse Reeve \n" "Language-Team: English \n" @@ -18,62 +18,70 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -#: bookwyrm/forms.py:365 +#: bookwyrm/forms.py:239 +msgid "Domain is blocked. Don't try this url again." +msgstr "" + +#: bookwyrm/forms.py:241 +msgid "Domain already pending. Please try later." +msgstr "" + +#: bookwyrm/forms.py:378 msgid "A user with this email already exists." msgstr "" -#: bookwyrm/forms.py:379 +#: bookwyrm/forms.py:392 msgid "One Day" msgstr "" -#: bookwyrm/forms.py:380 +#: bookwyrm/forms.py:393 msgid "One Week" msgstr "" -#: bookwyrm/forms.py:381 +#: bookwyrm/forms.py:394 msgid "One Month" msgstr "" -#: bookwyrm/forms.py:382 +#: bookwyrm/forms.py:395 msgid "Does Not Expire" msgstr "" -#: bookwyrm/forms.py:386 +#: bookwyrm/forms.py:399 #, python-brace-format msgid "{i} uses" msgstr "" -#: bookwyrm/forms.py:387 +#: bookwyrm/forms.py:400 msgid "Unlimited" msgstr "" -#: bookwyrm/forms.py:489 +#: bookwyrm/forms.py:502 msgid "List Order" msgstr "" -#: bookwyrm/forms.py:490 +#: bookwyrm/forms.py:503 msgid "Book Title" msgstr "" -#: bookwyrm/forms.py:491 bookwyrm/templates/shelf/shelf.html:155 +#: bookwyrm/forms.py:504 bookwyrm/templates/shelf/shelf.html:155 #: bookwyrm/templates/shelf/shelf.html:187 #: bookwyrm/templates/snippets/create_status/review.html:32 msgid "Rating" msgstr "" -#: bookwyrm/forms.py:493 bookwyrm/templates/lists/list.html:177 +#: bookwyrm/forms.py:506 bookwyrm/templates/lists/list.html:177 msgid "Sort By" msgstr "" -#: bookwyrm/forms.py:497 +#: bookwyrm/forms.py:510 msgid "Ascending" msgstr "" -#: bookwyrm/forms.py:498 +#: bookwyrm/forms.py:511 msgid "Descending" msgstr "" -#: bookwyrm/forms.py:511 +#: bookwyrm/forms.py:524 msgid "Reading finish date cannot be before start date." msgstr "" From c2c33fe1e8ddfa455007ad765478671ce8b7640b Mon Sep 17 00:00:00 2001 From: Willi Hohenstein Date: Wed, 2 Feb 2022 20:20:16 +0100 Subject: [PATCH 2/4] fixed merge conflict --- locale/de_DE/LC_MESSAGES/django.po | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/locale/de_DE/LC_MESSAGES/django.po b/locale/de_DE/LC_MESSAGES/django.po index 2e975d62b..34fecd22b 100644 --- a/locale/de_DE/LC_MESSAGES/django.po +++ b/locale/de_DE/LC_MESSAGES/django.po @@ -4675,15 +4675,5 @@ msgstr "Status -Updates von {obj.display_name}" #, python-format msgid "Load %(count)d unread status" msgid_plural "Load %(count)d unread statuses" -<<<<<<< HEAD -msgstr[0] "" -msgstr[1] "" - -#, python-format -#~ msgid "load 0 unread status(es)" -#~ msgstr "lade 0 ungelesene Statusmeldung(en)" -======= msgstr[0] "Lade %(count)d ungelesene Statusmeldung" msgstr[1] "Lade %(count)d ungelesene Statusmeldungen" - ->>>>>>> f84241b085a00b54a2f5ba083e8e60311ccb8622 From 1b313c2b624d81451735e4e404f8265c7375f181 Mon Sep 17 00:00:00 2001 From: Willi Hohenstein Date: Wed, 2 Feb 2022 22:34:30 +0100 Subject: [PATCH 3/4] added check of existing url for book sould also fix #1899 --- bookwyrm/forms.py | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py index 1b13598b0..684fe91f6 100644 --- a/bookwyrm/forms.py +++ b/bookwyrm/forms.py @@ -227,18 +227,32 @@ class FileLinkForm(CustomForm): class Meta: model = models.FileLink fields = ["url", "filetype", "availability", "book", "added_by"] - + def clean(self): """make sure the domain isn't blocked or pending""" cleaned_data = super().clean() - url = cleaned_data.get('url') + url = cleaned_data.get("url") + filetype = cleaned_data.get("filetype") + book = cleaned_data.get("book") domain = urlparse(url).netloc if models.LinkDomain.objects.filter(domain=domain).exists(): status = models.LinkDomain.objects.get(domain=domain).status - if status == 'blocked': - self.add_error("url", _("Domain is blocked. Don't try this url again.")) - elif status == 'pending': - self.add_error("url", _("Domain already pending. Please try later.")) + if status == "blocked": + self.add_error( + "url", + _( + "This domain is blocked. Please contact your administrator if you think this is an error." + ), + ) + elif models.FileLink.objects.filter( + url=url, book=book, filetype=filetype + ).exists(): + self.add_error( + "url", + _( + "This link with file type has already been added for this book. If it is not visible, the domain is still pending." + ), + ) class EditionForm(CustomForm): From 82aacf8f2aaca178457e461c5652f5e3d9f2dce4 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 4 Feb 2022 11:47:18 -0800 Subject: [PATCH 4/4] Update forms.py --- bookwyrm/forms.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py index 684fe91f6..564ea91b2 100644 --- a/bookwyrm/forms.py +++ b/bookwyrm/forms.py @@ -238,6 +238,7 @@ class FileLinkForm(CustomForm): if models.LinkDomain.objects.filter(domain=domain).exists(): status = models.LinkDomain.objects.get(domain=domain).status if status == "blocked": + # pylint: disable=line-too-long self.add_error( "url", _( @@ -247,6 +248,7 @@ class FileLinkForm(CustomForm): elif models.FileLink.objects.filter( url=url, book=book, filetype=filetype ).exists(): + # pylint: disable=line-too-long self.add_error( "url", _(