Adds edit server form

This commit is contained in:
Mouse Reeve 2021-04-07 11:52:13 -07:00
parent 8261fbf86a
commit 74549956c2
5 changed files with 40 additions and 3 deletions

View file

@ -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 = []

View file

@ -0,0 +1,15 @@
{% extends 'components/inline_form.html' %}
{% load i18n %}
{% block header %}
{% trans "Add server" %}
{% endblock %}
{% block form %}
<form>
{% csrf_token %}
{{ form.as_p }}
<button type="submit" class="button is-primary">{% trans "Save" %}</button>
</form>
{% endblock %}

View file

@ -6,7 +6,14 @@
{% block content %}
<header class="block column is-offset-one-quarter pl-1">
<h1 class="title">{% block header %}{% endblock %}</h1>
<div class="columns is-mobile">
<div class="column">
<h1 class="title">{% block header %}{% endblock %}</h1>
</div>
<div class="column is-narrow">
{% block edit-button %}{% endblock %}
</div>
</div>
</header>
<div class="block columns">

View file

@ -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 %}
<div class="block">
{% include 'settings/add_server_form.html' with controls_text="add-server" %}
</div>
<table class="table is-striped">
<tr>
{% url 'settings-federation' as url %}

View file

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