From 6022e7b232459d689a6cdc8df20307f8df7528c7 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 17 Sep 2021 12:59:16 -0700 Subject: [PATCH] Adds IP blocklist views --- bookwyrm/forms.py | 6 +++ bookwyrm/middleware/ip_middleware.py | 2 +- bookwyrm/static/css/bookwyrm.css | 7 +++ bookwyrm/templates/components/tooltip.html | 2 +- bookwyrm/templates/settings/domain_form.html | 2 +- .../templates/settings/ip_address_form.html | 36 ++++++++++++++ bookwyrm/templates/settings/ip_blocklist.html | 47 ++++++++++++++++++ bookwyrm/templates/settings/ip_tooltip.html | 8 +++ bookwyrm/templates/settings/layout.html | 4 ++ bookwyrm/urls.py | 10 ++++ bookwyrm/views/__init__.py | 1 + bookwyrm/views/admin/email_blocklist.py | 4 +- bookwyrm/views/admin/ip_blocklist.py | 49 +++++++++++++++++++ 13 files changed, 173 insertions(+), 5 deletions(-) create mode 100644 bookwyrm/templates/settings/ip_address_form.html create mode 100644 bookwyrm/templates/settings/ip_blocklist.html create mode 100644 bookwyrm/templates/settings/ip_tooltip.html create mode 100644 bookwyrm/views/admin/ip_blocklist.py diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py index b53d0b6a..0be53ba0 100644 --- a/bookwyrm/forms.py +++ b/bookwyrm/forms.py @@ -311,6 +311,12 @@ class EmailBlocklistForm(CustomForm): fields = ["domain"] +class IPBlocklistForm(CustomForm): + class Meta: + model = models.IPBlocklist + fields = ["address"] + + class ServerForm(CustomForm): class Meta: model = models.FederatedServer diff --git a/bookwyrm/middleware/ip_middleware.py b/bookwyrm/middleware/ip_middleware.py index 7fcec1df..8063dd1f 100644 --- a/bookwyrm/middleware/ip_middleware.py +++ b/bookwyrm/middleware/ip_middleware.py @@ -11,6 +11,6 @@ class IPBlocklistMiddleware: def __call__(self, request): address = request.META.get("REMOTE_ADDR") - if models.IPBlockList.objects.filter(address=address).exists(): + if models.IPBlocklist.objects.filter(address=address).exists(): raise Http404() return self.get_response(request) diff --git a/bookwyrm/static/css/bookwyrm.css b/bookwyrm/static/css/bookwyrm.css index 9065d7fb..e1012c2f 100644 --- a/bookwyrm/static/css/bookwyrm.css +++ b/bookwyrm/static/css/bookwyrm.css @@ -378,6 +378,13 @@ input[type=file]::file-selector-button:hover { right: 1em; } +/** Tooltips + ******************************************************************************/ + +.tooltip { + width: 100%; +} + /** States ******************************************************************************/ diff --git a/bookwyrm/templates/components/tooltip.html b/bookwyrm/templates/components/tooltip.html index 06b13f34..b1a8f56c 100644 --- a/bookwyrm/templates/components/tooltip.html +++ b/bookwyrm/templates/components/tooltip.html @@ -3,7 +3,7 @@ {% trans "Help" as button_text %} {% include 'snippets/toggle/open_button.html' with text=button_text class="ml-3 is-rounded is-small is-white p-0 pb-1" icon="question-circle is-size-6" controls_text=controls_text controls_uid=controls_uid %} -