diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py index b159a89ef..55bb66506 100644 --- a/bookwyrm/forms.py +++ b/bookwyrm/forms.py @@ -281,3 +281,9 @@ class ReportForm(CustomForm): class Meta: model = models.Report fields = ["user", "reporter", "statuses", "note"] + + +class ServerForm(CustomForm): + class Meta: + model = models.FederatedServer + exclude = [] diff --git a/bookwyrm/templates/settings/add_server_form.html b/bookwyrm/templates/settings/add_server_form.html new file mode 100644 index 000000000..a16aac2db --- /dev/null +++ b/bookwyrm/templates/settings/add_server_form.html @@ -0,0 +1,15 @@ +{% extends 'components/inline_form.html' %} +{% load i18n %} + +{% block header %} +{% trans "Add server" %} +{% endblock %} + +{% block form %} +
+ {% csrf_token %} + {{ form.as_p }} + +
+{% endblock %} + diff --git a/bookwyrm/templates/settings/admin_layout.html b/bookwyrm/templates/settings/admin_layout.html index 9340da9e1..4f71a2284 100644 --- a/bookwyrm/templates/settings/admin_layout.html +++ b/bookwyrm/templates/settings/admin_layout.html @@ -6,7 +6,14 @@ {% block content %}
-

{% block header %}{% endblock %}

+
+
+

{% block header %}{% endblock %}

+
+
+ {% block edit-button %}{% endblock %} +
+
diff --git a/bookwyrm/templates/settings/federation.html b/bookwyrm/templates/settings/federation.html index 696d7a205..1106bc128 100644 --- a/bookwyrm/templates/settings/federation.html +++ b/bookwyrm/templates/settings/federation.html @@ -4,8 +4,17 @@ {% block header %}{% trans "Federated Servers" %}{% endblock %} +{% block edit-button %} +{% trans "Add server" as button_text %} +{% include 'snippets/toggle/open_button.html' with controls_text="add-server" icon="plus" text=button_text focus="add-server-header" %} +{% endblock%} + {% block panel %} +
+ {% include 'settings/add_server_form.html' with controls_text="add-server" %} +
+ {% url 'settings-federation' as url %} diff --git a/bookwyrm/views/federation.py b/bookwyrm/views/federation.py index 0405ebf53..969627684 100644 --- a/bookwyrm/views/federation.py +++ b/bookwyrm/views/federation.py @@ -6,7 +6,7 @@ from django.template.response import TemplateResponse from django.utils.decorators import method_decorator from django.views import View -from bookwyrm import models +from bookwyrm import forms, models from bookwyrm.settings import PAGE_LENGTH @@ -34,7 +34,7 @@ class Federation(View): servers = servers.order_by(sort) paginated = Paginator(servers, PAGE_LENGTH) - data = {"servers": paginated.page(page), "sort": sort} + data = {"servers": paginated.page(page), "sort": sort, "form": forms.ServerForm} return TemplateResponse(request, "settings/federation.html", data)