forked from mirrors/bookwyrm
Adds block and unblock functionality
This commit is contained in:
parent
e4fe47b538
commit
ad543f46c1
2 changed files with 24 additions and 1 deletions
|
@ -4,6 +4,10 @@
|
||||||
|
|
||||||
{% block header %}
|
{% block header %}
|
||||||
{{ server.server_name }}
|
{{ server.server_name }}
|
||||||
|
|
||||||
|
{% if server.status == "blocked" %}<span class="icon icon-x has-text-danger is-size-5" title="{% trans 'Blocked' %}"><span class="is-sr-only">{% trans "Blocked" %}</span></span>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<a href="{% url 'settings-federation' %}" class="has-text-weight-normal help">{% trans "Back to server list" %}</a>
|
<a href="{% url 'settings-federation' %}" class="has-text-weight-normal help">{% trans "Back to server list" %}</a>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
@ -64,5 +68,17 @@
|
||||||
</dl>
|
</dl>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<section class="block content">
|
||||||
|
<h2 class="title is-4">{% trans "Actions" %}</h2>
|
||||||
|
<form class="block" method="post" action="{% url 'settings-federated-server' server.id %}">
|
||||||
|
{% csrf_token %}
|
||||||
|
{% if server.status != 'blocked' %}
|
||||||
|
<button class="button is-danger">{% trans "Block" %}</button>
|
||||||
|
{% else %}
|
||||||
|
<button class="button">{% trans "Un-block" %}</button>
|
||||||
|
{% endif %}
|
||||||
|
</form>
|
||||||
|
</section>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
""" manage federated servers """
|
""" manage federated servers """
|
||||||
from django.contrib.auth.decorators import login_required, permission_required
|
from django.contrib.auth.decorators import login_required, permission_required
|
||||||
from django.core.paginator import Paginator
|
from django.core.paginator import Paginator
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404, redirect
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
from django.utils.decorators import method_decorator
|
from django.utils.decorators import method_decorator
|
||||||
from django.views import View
|
from django.views import View
|
||||||
|
@ -61,3 +61,10 @@ class FederatedServer(View):
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
return TemplateResponse(request, "settings/federated_server.html", data)
|
return TemplateResponse(request, "settings/federated_server.html", data)
|
||||||
|
|
||||||
|
def post(self, request, server): # pylint: disable=unused-argument
|
||||||
|
""" (un)block a server """
|
||||||
|
server = get_object_or_404(models.FederatedServer, id=server)
|
||||||
|
server.status = "blocked" if server.status == "federated" else "federated"
|
||||||
|
server.save()
|
||||||
|
return redirect("settings-federated-server", server.id)
|
||||||
|
|
Loading…
Reference in a new issue