mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 19:41:11 +00:00
Merge pull request #1900 from willhoh/main
Added check for bocked or pending domains. Fixes #1850
This commit is contained in:
commit
0c3b6e6938
3 changed files with 74 additions and 30 deletions
|
@ -1,6 +1,7 @@
|
||||||
""" using django model forms """
|
""" using django model forms """
|
||||||
import datetime
|
import datetime
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.forms import ModelForm, PasswordInput, widgets, ChoiceField
|
from django.forms import ModelForm, PasswordInput, widgets, ChoiceField
|
||||||
|
@ -227,6 +228,34 @@ class FileLinkForm(CustomForm):
|
||||||
model = models.FileLink
|
model = models.FileLink
|
||||||
fields = ["url", "filetype", "availability", "book", "added_by"]
|
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")
|
||||||
|
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":
|
||||||
|
# pylint: disable=line-too-long
|
||||||
|
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():
|
||||||
|
# pylint: disable=line-too-long
|
||||||
|
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):
|
class EditionForm(CustomForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
|
@ -17,62 +17,70 @@ msgstr ""
|
||||||
"X-Crowdin-File: /[bookwyrm-social.bookwyrm] main/locale/en_US/LC_MESSAGES/django.po\n"
|
"X-Crowdin-File: /[bookwyrm-social.bookwyrm] main/locale/en_US/LC_MESSAGES/django.po\n"
|
||||||
"X-Crowdin-File-ID: 1553\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."
|
msgid "A user with this email already exists."
|
||||||
msgstr "Es existiert bereits ein Benutzer*inkonto mit dieser E-Mail-Adresse."
|
msgstr "Es existiert bereits ein Benutzer*inkonto mit dieser E-Mail-Adresse."
|
||||||
|
|
||||||
#: bookwyrm/forms.py:379
|
#: bookwyrm/forms.py:392
|
||||||
msgid "One Day"
|
msgid "One Day"
|
||||||
msgstr "Ein Tag"
|
msgstr "Ein Tag"
|
||||||
|
|
||||||
#: bookwyrm/forms.py:380
|
#: bookwyrm/forms.py:393
|
||||||
msgid "One Week"
|
msgid "One Week"
|
||||||
msgstr "Eine Woche"
|
msgstr "Eine Woche"
|
||||||
|
|
||||||
#: bookwyrm/forms.py:381
|
#: bookwyrm/forms.py:394
|
||||||
msgid "One Month"
|
msgid "One Month"
|
||||||
msgstr "Ein Monat"
|
msgstr "Ein Monat"
|
||||||
|
|
||||||
#: bookwyrm/forms.py:382
|
#: bookwyrm/forms.py:395
|
||||||
msgid "Does Not Expire"
|
msgid "Does Not Expire"
|
||||||
msgstr "Läuft nicht ab"
|
msgstr "Läuft nicht ab"
|
||||||
|
|
||||||
#: bookwyrm/forms.py:386
|
#: bookwyrm/forms.py:399
|
||||||
#, python-brace-format
|
#, python-brace-format
|
||||||
msgid "{i} uses"
|
msgid "{i} uses"
|
||||||
msgstr "{i}-mal verwendbar"
|
msgstr "{i}-mal verwendbar"
|
||||||
|
|
||||||
#: bookwyrm/forms.py:387
|
#: bookwyrm/forms.py:400
|
||||||
msgid "Unlimited"
|
msgid "Unlimited"
|
||||||
msgstr "Unbegrenzt"
|
msgstr "Unbegrenzt"
|
||||||
|
|
||||||
#: bookwyrm/forms.py:489
|
#: bookwyrm/forms.py:502
|
||||||
msgid "List Order"
|
msgid "List Order"
|
||||||
msgstr "Reihenfolge der Liste"
|
msgstr "Reihenfolge der Liste"
|
||||||
|
|
||||||
#: bookwyrm/forms.py:490
|
#: bookwyrm/forms.py:503
|
||||||
msgid "Book Title"
|
msgid "Book Title"
|
||||||
msgstr "Buchtitel"
|
msgstr "Buchtitel"
|
||||||
|
|
||||||
#: 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/shelf/shelf.html:187
|
||||||
#: bookwyrm/templates/snippets/create_status/review.html:32
|
#: bookwyrm/templates/snippets/create_status/review.html:32
|
||||||
msgid "Rating"
|
msgid "Rating"
|
||||||
msgstr "Bewertung"
|
msgstr "Bewertung"
|
||||||
|
|
||||||
#: bookwyrm/forms.py:493 bookwyrm/templates/lists/list.html:177
|
#: bookwyrm/forms.py:506 bookwyrm/templates/lists/list.html:177
|
||||||
msgid "Sort By"
|
msgid "Sort By"
|
||||||
msgstr "Sortieren nach"
|
msgstr "Sortieren nach"
|
||||||
|
|
||||||
#: bookwyrm/forms.py:497
|
#: bookwyrm/forms.py:510
|
||||||
msgid "Ascending"
|
msgid "Ascending"
|
||||||
msgstr "Aufsteigend"
|
msgstr "Aufsteigend"
|
||||||
|
|
||||||
#: bookwyrm/forms.py:498
|
#: bookwyrm/forms.py:511
|
||||||
msgid "Descending"
|
msgid "Descending"
|
||||||
msgstr "Absteigend"
|
msgstr "Absteigend"
|
||||||
|
|
||||||
#: bookwyrm/forms.py:511
|
#: bookwyrm/forms.py:524
|
||||||
msgid "Reading finish date cannot be before start date."
|
msgid "Reading finish date cannot be before start date."
|
||||||
msgstr "Enddatum darf nicht vor dem Startdatum liegen."
|
msgstr "Enddatum darf nicht vor dem Startdatum liegen."
|
||||||
|
|
||||||
|
@ -284,7 +292,7 @@ msgstr "Português Europeu (Portugiesisch)"
|
||||||
|
|
||||||
#: bookwyrm/settings.py:258
|
#: bookwyrm/settings.py:258
|
||||||
msgid "Swedish (Svenska)"
|
msgid "Swedish (Svenska)"
|
||||||
msgstr ""
|
msgstr "Swedish (Schwedisch)"
|
||||||
|
|
||||||
#: bookwyrm/settings.py:259
|
#: bookwyrm/settings.py:259
|
||||||
msgid "简体中文 (Simplified Chinese)"
|
msgid "简体中文 (Simplified Chinese)"
|
||||||
|
@ -4677,4 +4685,3 @@ msgid "Load %(count)d unread status"
|
||||||
msgid_plural "Load %(count)d unread statuses"
|
msgid_plural "Load %(count)d unread statuses"
|
||||||
msgstr[0] "Lade %(count)d ungelesene Statusmeldung"
|
msgstr[0] "Lade %(count)d ungelesene Statusmeldung"
|
||||||
msgstr[1] "Lade %(count)d ungelesene Statusmeldungen"
|
msgstr[1] "Lade %(count)d ungelesene Statusmeldungen"
|
||||||
|
|
||||||
|
|
|
@ -18,62 +18,70 @@ msgstr ""
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
"Plural-Forms: nplurals=2; plural=(n != 1);\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."
|
msgid "A user with this email already exists."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: bookwyrm/forms.py:379
|
#: bookwyrm/forms.py:392
|
||||||
msgid "One Day"
|
msgid "One Day"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: bookwyrm/forms.py:380
|
#: bookwyrm/forms.py:393
|
||||||
msgid "One Week"
|
msgid "One Week"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: bookwyrm/forms.py:381
|
#: bookwyrm/forms.py:394
|
||||||
msgid "One Month"
|
msgid "One Month"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: bookwyrm/forms.py:382
|
#: bookwyrm/forms.py:395
|
||||||
msgid "Does Not Expire"
|
msgid "Does Not Expire"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: bookwyrm/forms.py:386
|
#: bookwyrm/forms.py:399
|
||||||
#, python-brace-format
|
#, python-brace-format
|
||||||
msgid "{i} uses"
|
msgid "{i} uses"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: bookwyrm/forms.py:387
|
#: bookwyrm/forms.py:400
|
||||||
msgid "Unlimited"
|
msgid "Unlimited"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: bookwyrm/forms.py:489
|
#: bookwyrm/forms.py:502
|
||||||
msgid "List Order"
|
msgid "List Order"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: bookwyrm/forms.py:490
|
#: bookwyrm/forms.py:503
|
||||||
msgid "Book Title"
|
msgid "Book Title"
|
||||||
msgstr ""
|
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/shelf/shelf.html:187
|
||||||
#: bookwyrm/templates/snippets/create_status/review.html:32
|
#: bookwyrm/templates/snippets/create_status/review.html:32
|
||||||
msgid "Rating"
|
msgid "Rating"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: bookwyrm/forms.py:493 bookwyrm/templates/lists/list.html:177
|
#: bookwyrm/forms.py:506 bookwyrm/templates/lists/list.html:177
|
||||||
msgid "Sort By"
|
msgid "Sort By"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: bookwyrm/forms.py:497
|
#: bookwyrm/forms.py:510
|
||||||
msgid "Ascending"
|
msgid "Ascending"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: bookwyrm/forms.py:498
|
#: bookwyrm/forms.py:511
|
||||||
msgid "Descending"
|
msgid "Descending"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: bookwyrm/forms.py:511
|
#: bookwyrm/forms.py:524
|
||||||
msgid "Reading finish date cannot be before start date."
|
msgid "Reading finish date cannot be before start date."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue