forked from mirrors/bookwyrm
Block all/unblock all users on server block
This commit is contained in:
parent
839ac061b7
commit
ddba61f138
3 changed files with 13 additions and 2 deletions
|
@ -89,8 +89,10 @@
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{% if server.status != 'blocked' %}
|
{% if server.status != 'blocked' %}
|
||||||
<button class="button is-danger">{% trans "Block" %}</button>
|
<button class="button is-danger">{% trans "Block" %}</button>
|
||||||
|
<p class="help">{% trans "All users from this instance will be deactivated." %}</p>
|
||||||
{% else %}
|
{% else %}
|
||||||
<button class="button">{% trans "Un-block" %}</button>
|
<button class="button">{% trans "Un-block" %}</button>
|
||||||
|
<p class="help">{% trans "All users from this instance will be re-activated." %}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</form>
|
</form>
|
||||||
</section>
|
</section>
|
||||||
|
|
|
@ -36,7 +36,9 @@ class Federation(View):
|
||||||
paginated = Paginator(servers, PAGE_LENGTH)
|
paginated = Paginator(servers, PAGE_LENGTH)
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
"servers": paginated.page(page), "sort": sort, "form": forms.ServerForm()
|
"servers": paginated.page(page),
|
||||||
|
"sort": sort,
|
||||||
|
"form": forms.ServerForm(),
|
||||||
}
|
}
|
||||||
return TemplateResponse(request, "settings/federation.html", data)
|
return TemplateResponse(request, "settings/federation.html", data)
|
||||||
|
|
||||||
|
@ -93,4 +95,11 @@ class FederatedServer(View):
|
||||||
server = get_object_or_404(models.FederatedServer, id=server)
|
server = get_object_or_404(models.FederatedServer, id=server)
|
||||||
server.status = "blocked" if server.status == "federated" else "federated"
|
server.status = "blocked" if server.status == "federated" else "federated"
|
||||||
server.save()
|
server.save()
|
||||||
|
|
||||||
|
# TODO: there needs to be differentiation between types of deactivated users
|
||||||
|
if server.status == "blocked":
|
||||||
|
server.user_set.update(is_active=False)
|
||||||
|
else:
|
||||||
|
server.user_set.update(is_active=True)
|
||||||
|
|
||||||
return redirect("settings-federated-server", server.id)
|
return redirect("settings-federated-server", server.id)
|
||||||
|
|
|
@ -70,7 +70,7 @@ def is_blocked_user_agent(request):
|
||||||
user_agent = request.headers.get("User-Agent")
|
user_agent = request.headers.get("User-Agent")
|
||||||
if not user_agent:
|
if not user_agent:
|
||||||
return False
|
return False
|
||||||
url = re.search(r"+https?://{:s}/?".format(regex.domain), user_agent)
|
url = re.search(r"https?://{:s}/?".format(regex.domain), user_agent).group()
|
||||||
domain = urlparse(url).netloc
|
domain = urlparse(url).netloc
|
||||||
if not domain:
|
if not domain:
|
||||||
# idk, we'll try again later with the actor
|
# idk, we'll try again later with the actor
|
||||||
|
|
Loading…
Reference in a new issue