list of federated servers for admin panel

This commit is contained in:
Mouse Reeve 2021-01-29 16:02:59 -08:00
parent 9db327a69e
commit d1ee26e282
5 changed files with 52 additions and 1 deletions

View file

@ -14,6 +14,10 @@
{% url 'settings-invites' as url %} {% url 'settings-invites' as url %}
<a href="{{ url }}"{% if url in request.path %} class="is-active" aria-selected="true"{% endif %}>Invites</a> <a href="{{ url }}"{% if url in request.path %} class="is-active" aria-selected="true"{% endif %}>Invites</a>
</li> </li>
<li>
{% url 'settings-federation' as url %}
<a href="{{ url }}"{% if url in request.path %} class="is-active" aria-selected="true"{% endif %}>Federated Servers</a>
</li>
</ul> </ul>
{% endif %} {% endif %}
{% if perms.bookwyrm.edit_instance_settings %} {% if perms.bookwyrm.edit_instance_settings %}

View file

@ -0,0 +1,21 @@
{% extends 'settings/admin_layout.html' %}
{% block header %}Federated Servers{% endblock %}
{% block panel %}
<table class="table is-striped">
<tr>
<th>Server name</th>
<th>Software</th>
<th>Status</th>
</tr>
{% for server in servers %}
<tr>
<td>{{ server.server_name }}</td>
<td>{{ server.application_type }} ({{ server.application_version }})</td>
<td>{{ server.status }}</td>
</tr>
{% endfor %}
</table>
{% endblock %}

View file

@ -52,7 +52,8 @@ urlpatterns = [
# admin # admin
re_path(r'^settings/site-settings', re_path(r'^settings/site-settings',
views.Site.as_view(), name='settings-site'), views.Site.as_view(), name='settings-site'),
# invites re_path(r'^settings/federation',
views.Federation.as_view(), name='settings-federation'),
re_path(r'^settings/invites/?$', re_path(r'^settings/invites/?$',
views.ManageInvites.as_view(), name='settings-invites'), views.ManageInvites.as_view(), name='settings-invites'),
re_path(r'^invite/(?P<code>[A-Za-z0-9]+)/?$', views.Invite.as_view()), re_path(r'^invite/(?P<code>[A-Za-z0-9]+)/?$', views.Invite.as_view()),

View file

@ -5,6 +5,7 @@ from .block import Block, unblock
from .books import Book, EditBook, Editions from .books import Book, EditBook, Editions
from .books import upload_cover, add_description, switch_edition, resolve_book from .books import upload_cover, add_description, switch_edition, resolve_book
from .error import not_found_page, server_error_page from .error import not_found_page, server_error_page
from .federation import Federation
from .feed import DirectMessage, Feed, Replies, Status from .feed import DirectMessage, Feed, Replies, Status
from .follow import follow, unfollow from .follow import follow, unfollow
from .follow import accept_follow_request, delete_follow_request, handle_accept from .follow import accept_follow_request, delete_follow_request, handle_accept

View file

@ -0,0 +1,24 @@
''' manage federated servers '''
from django.contrib.auth.decorators import login_required, permission_required
from django.template.response import TemplateResponse
from django.utils.decorators import method_decorator
from django.views import View
from bookwyrm import models
# pylint: disable= no-self-use
@method_decorator(login_required, name='dispatch')
@method_decorator(
permission_required('bookwyrm.control_federation', raise_exception=True),
name='dispatch')
class Federation(View):
''' what servers do we federate with '''
def get(self, request):
''' edit form '''
servers = models.FederatedServer.objects.all()
data = {
'title': 'Federated Servers',
'servers': servers
}
return TemplateResponse(request, 'settings/federation.html', data)