Merge pull request #1952 from bookwyrm-social/settings

Fixes admin settings view
This commit is contained in:
Mouse Reeve 2022-02-17 18:10:17 -08:00 committed by GitHub
commit 9eb798e932
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 3 deletions

View file

@ -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"}

View file

@ -15,6 +15,24 @@
{% endblock %}
{% block panel %}
{% if success %}
<div class="notification is-success is-light">
<span class="icon icon-check" aria-hidden="true"></span>
<span>
{% trans "Settings saved" %}
</span>
</div>
{% endif %}
{% if site_form.errors %}
<div class="notification is-danger is-light">
<span class="icon icon-x" aria-hidden="true"></span>
<span>
{% trans "Unable to save settings" %}
</span>
</div>
{% endif %}
<form action="{% url 'settings-site' %}" method="POST" class="content" enctype="multipart/form-data">
{% csrf_token %}
<section class="block" id="instance_info">

View file

@ -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