From f580a51f24dac593caa967430b430c89ad482342 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 10 Jan 2022 10:38:05 -0800 Subject: [PATCH] Form to edit link domain display names --- bookwyrm/forms.py | 6 +++++ .../link_domains/edit_domain_modal.html | 25 +++++++++++++++++++ .../settings/link_domains/link_domains.html | 10 ++++++-- bookwyrm/urls.py | 7 +++++- 4 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 bookwyrm/templates/settings/link_domains/edit_domain_modal.html diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py index f73da6489..12ebbff85 100644 --- a/bookwyrm/forms.py +++ b/bookwyrm/forms.py @@ -216,6 +216,12 @@ class CoverForm(CustomForm): help_texts = {f: None for f in fields} +class LinkDomainForm(CustomForm): + class Meta: + model = models.LinkDomain + fields = ["id", "name"] + + class FileLinkForm(CustomForm): class Meta: model = models.FileLink diff --git a/bookwyrm/templates/settings/link_domains/edit_domain_modal.html b/bookwyrm/templates/settings/link_domains/edit_domain_modal.html new file mode 100644 index 000000000..7b2a46e24 --- /dev/null +++ b/bookwyrm/templates/settings/link_domains/edit_domain_modal.html @@ -0,0 +1,25 @@ +{% extends 'components/modal.html' %} +{% load i18n %} + +{% block modal-title %} +{% blocktrans with url=domain.domain %}Set display name for {{ url }}{% endblocktrans %} +{% endblock %} + +{% block modal-form-open %} +
+{% endblock %} + +{% block modal-body %} +{% csrf_token %} + +
+ +
+{% endblock %} + +{% block modal-footer %} + + +{% endblock %} + +{% block modal-form-close %}
{% endblock %} diff --git a/bookwyrm/templates/settings/link_domains/link_domains.html b/bookwyrm/templates/settings/link_domains/link_domains.html index 555a81a11..3d89929dc 100644 --- a/bookwyrm/templates/settings/link_domains/link_domains.html +++ b/bookwyrm/templates/settings/link_domains/link_domains.html @@ -1,6 +1,7 @@ {% extends 'settings/layout.html' %} {% load humanize %} {% load i18n %} +{% load utilities %} {% block title %}{% trans "Link Domains" %}{% endblock %} @@ -30,6 +31,7 @@ {% for domain in domains %} + {% join "domain" domain.id as domain_modal %}
@@ -39,8 +41,10 @@
- {% trans "Set name" as button_text %} - {% include 'snippets/toggle/open_button.html' with text=button_text icon_with_text="pencil" controls_text="edit_domain" controls_uid=domain.id focus="id_description" %} +
@@ -66,6 +70,8 @@
+ {% include "settings/link_domains/edit_domain_modal.html" with domain=domain id=domain_modal %} +
{% csrf_token %}
diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index 61ff7ffaa..781430dc1 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -154,7 +154,12 @@ urlpatterns = [ name="settings-email-blocks-delete", ), re_path( - r"^setting/link-domains/(?P(pending|approved|blocked))/?", + r"^setting/link-domains/(?P(pending|approved|blocked|))/?", + views.LinkDomain.as_view(), + name="settings-link-domain", + ), + re_path( + r"^setting/link-domains/?", views.LinkDomain.as_view(), name="settings-link-domain", ),