added domain pending or blocked check

fixes #1850
This commit is contained in:
Willi Hohenstein 2022-02-02 19:35:26 +01:00
parent dd39046ff9
commit e37982d285
3 changed files with 154 additions and 76 deletions

View file

@ -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):

View file

@ -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 <mousereeve@riseup.net>\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 <span data-poll=\"stream/%(tab_key)s\">0</span> unread status(es)"
msgstr "lade <span data-poll=\"stream/%(tab_key)s\">0</span> 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 <a href=\"%(support_link)s\" target=\"_blank\">%(suppo
msgid "BookWyrm's source code is freely available. You can contribute or report issues on <a href=\"https://github.com/mouse-reeve/bookwyrm\">GitHub</a>."
msgstr "BookWyrm ist open source Software. Du kannst dich auf <a href=\"https://github.com/mouse-reeve/bookwyrm\">GitHub</a> beteiligen oder etwas melden."
#: bookwyrm/templates/lists/add_item_modal.html:8
#, fuzzy, python-format
#| msgid "Add read dates for \"<em>%(title)s</em>\""
msgid "Add \"<em>%(title)s</em>\" to this list"
msgstr "„<em>%(title)s</em>“ zu dieser Liste hinzufügen"
#: bookwyrm/templates/lists/add_item_modal.html:12
#, fuzzy, python-format
#| msgid "Start \"<em>%(book_title)s</em>\""
msgid "Suggest \"<em>%(title)s</em>\" for this list"
msgstr "„<em>%(book_title)s</em>“ 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 <a href=\"%(path)s\">%(username)s</a>"
msgid "Created by <a href=\"%(path)s\">%(username)s</a>"
msgstr "Erstellt von <a href=\"%(path)s\">%(username)s</a>"
#: 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 <a href=\"%(user_path)s\">%(username)s</a>"
msgid "<a href=\"%(user_path)s\">%(username)s</a> says:"
msgstr "<a href=\"%(user_path)s\">%(username)s</a> 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 <a href=\"/\">%(site_name)s</a>"
msgstr "auf <a href=\"/\">%(site_name)s</a>"
#: 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 <a href=\"%(user_path)s\">%(username)s</a>"
msgstr "Hinzugefügt von <a href=\"%(user_path)s\">%(username)s</a>"
#: 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 <span data-poll=\"stream/%(tab_key)s\">0</span> unread status(es)"
#~ msgstr "lade <span data-poll=\"stream/%(tab_key)s\">0</span> ungelesene Statusmeldung(en)"

View file

@ -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 <mousereeve@riseup.net>\n"
"Language-Team: English <LL@li.org>\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 ""