From b8b1e12c3d6df551687fabd161add6e892051362 Mon Sep 17 00:00:00 2001 From: Timon Engelke Date: Tue, 10 Oct 2023 16:07:10 +0200 Subject: [PATCH] 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")