From edf3b61602ccefb5d3ff87dd4d5745ee081a8a45 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Thu, 17 Feb 2022 18:00:19 -0800 Subject: [PATCH] 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 8efad308..2ecd988e 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 4dc14be1..7e75a820 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