From 1aac6650945dd3e9984b558bf7a991db564265d3 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Thu, 17 Feb 2022 17:50:57 -0800 Subject: [PATCH 1/2] Fixes settings form --- bookwyrm/forms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py index cb9a1e97e..865bc02fe 100644 --- a/bookwyrm/forms.py +++ b/bookwyrm/forms.py @@ -440,7 +440,7 @@ class GoalForm(CustomForm): class SiteForm(CustomForm): class Meta: model = models.SiteSettings - exclude = [] + exclude = ["admin_code", "install_mode"] widgets = { "instance_short_description": forms.TextInput( attrs={"aria-describedby": "desc_instance_short_description"} From edf3b61602ccefb5d3ff87dd4d5745ee081a8a45 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Thu, 17 Feb 2022 18:00:19 -0800 Subject: [PATCH 2/2] Show error or success states --- bookwyrm/templates/settings/site.html | 18 ++++++++++++++++++ bookwyrm/views/admin/site.py | 4 ++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/bookwyrm/templates/settings/site.html b/bookwyrm/templates/settings/site.html index 8efad308d..2ecd988ea 100644 --- a/bookwyrm/templates/settings/site.html +++ b/bookwyrm/templates/settings/site.html @@ -15,6 +15,24 @@ {% endblock %} {% block panel %} +{% if success %} +
+ + + {% trans "Settings saved" %} + +
+{% endif %} + +{% if site_form.errors %} +
+ + + {% trans "Unable to save settings" %} + +
+{% endif %} +
{% csrf_token %}
diff --git a/bookwyrm/views/admin/site.py b/bookwyrm/views/admin/site.py index 4dc14be16..7e75a8204 100644 --- a/bookwyrm/views/admin/site.py +++ b/bookwyrm/views/admin/site.py @@ -1,6 +1,5 @@ """ manage site settings """ from django.contrib.auth.decorators import login_required, permission_required -from django.shortcuts import redirect from django.template.response import TemplateResponse from django.utils.decorators import method_decorator from django.views import View @@ -32,7 +31,8 @@ class Site(View): return TemplateResponse(request, "settings/site.html", data) form.save() - return redirect("settings-site") + data = {"site_form": forms.SiteForm(instance=site), "success": True} + return TemplateResponse(request, "settings/site.html", data) @login_required