From b8b1e12c3d6df551687fabd161add6e892051362 Mon Sep 17 00:00:00 2001 From: Timon Engelke Date: Tue, 10 Oct 2023 16:07:10 +0200 Subject: [PATCH 1/3] Allow unpin of etherpads even if user is not in group --- mafiasi/etherpad/views.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/mafiasi/etherpad/views.py b/mafiasi/etherpad/views.py index 02cbaa7b..cb4b8b8e 100644 --- a/mafiasi/etherpad/views.py +++ b/mafiasi/etherpad/views.py @@ -5,6 +5,7 @@ from django import forms from django.conf import settings from django.contrib.auth.decorators import login_required +from django.contrib.auth.models import Group from django.core.exceptions import ObjectDoesNotExist from django.shortcuts import redirect from django.template.response import TemplateResponse @@ -159,18 +160,10 @@ def pin_pad(request, group_name, pad_name): @require_POST def unpin_pad(request, group_name, pad_name): try: - group = request.user.groups.get(name=group_name) + group = Group.objects.get(name=group_name) + PinnedEtherpad.objects.filter(user=request.user, group_name=group, pad_name=pad_name).delete() except ObjectDoesNotExist: - return TemplateResponse( - request, - "etherpad/forbidden-notingroup.html", - { - "group_name": group_name, - }, - status=403, - ) - - PinnedEtherpad.objects.filter(user=request.user, group_name=group, pad_name=pad_name).delete() + pass # redirect to pad overview return redirect("ep_index") From 01e98887b1c440140d60db2d8b7024994b8ef910 Mon Sep 17 00:00:00 2001 From: kritzl Date: Mon, 30 Oct 2023 16:22:36 +0100 Subject: [PATCH 2/3] allow slash at end of path --- mafiasi/urls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mafiasi/urls.py b/mafiasi/urls.py index acad248d..1ac24a57 100644 --- a/mafiasi/urls.py +++ b/mafiasi/urls.py @@ -63,7 +63,7 @@ def handler500(request): def handler404(request, exception): try: apps.get_app_config("wiki") - path = str(request.path).replace("/", "", 1) + path = str(request.path).replace("/", "", 2) if "/" in path: return HttpResponse("Page not found", status=404) From 2cfc4dda3279a6c8ba0e9ec5a30c7300b42e2c31 Mon Sep 17 00:00:00 2001 From: kritzl Date: Mon, 30 Oct 2023 16:42:29 +0100 Subject: [PATCH 3/3] remove slashes only at start & end of path --- mafiasi/urls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mafiasi/urls.py b/mafiasi/urls.py index 1ac24a57..efcd982b 100644 --- a/mafiasi/urls.py +++ b/mafiasi/urls.py @@ -63,7 +63,7 @@ def handler500(request): def handler404(request, exception): try: apps.get_app_config("wiki") - path = str(request.path).replace("/", "", 2) + path = str(request.path).strip("/") if "/" in path: return HttpResponse("Page not found", status=404)