From ebee8c34e13aecf8ff6e77064f8250dfb67451ff Mon Sep 17 00:00:00 2001 From: Bartuccio Antoine Date: Mon, 16 Dec 2019 15:00:33 +0100 Subject: [PATCH 1/2] forum: fix ForumTopicSubscribeView error 500 with anonymous user --- forum/views.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/forum/views.py b/forum/views.py index 11ab52ad..9a2f443b 100644 --- a/forum/views.py +++ b/forum/views.py @@ -42,6 +42,7 @@ from core.views import ( CanEditMixin, CanEditPropMixin, CanCreateMixin, + UserIsLoggedMixin, can_view, ) from core.views.forms import MarkdownInput @@ -273,7 +274,9 @@ class ForumTopicEditView(CanEditMixin, UpdateView): template_name = "core/edit.jinja" -class ForumTopicSubscribeView(CanViewMixin, SingleObjectMixin, RedirectView): +class ForumTopicSubscribeView( + CanViewMixin, UserIsLoggedMixin, SingleObjectMixin, RedirectView +): model = ForumTopic pk_url_kwarg = "topic_id" permanent = False From 4a1bfc366daea85cdff455d78c46e26f2dcafeef Mon Sep 17 00:00:00 2001 From: Bartuccio Antoine Date: Tue, 17 Dec 2019 10:51:19 +0100 Subject: [PATCH 2/2] sas: fix 500 error when tagging the same user twice or adding a non existing user --- sas/views.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sas/views.py b/sas/views.py index 941e2bb6..a43369e4 100644 --- a/sas/views.py +++ b/sas/views.py @@ -180,6 +180,12 @@ class PictureView(CanViewMixin, DetailView, FormMixin): if self.form.is_valid(): for uid in self.form.cleaned_data["users"]: u = User.objects.filter(id=uid).first() + if not u: # Don't use a non existing user + continue + if PeoplePictureRelation.objects.filter( + user=u, picture=self.form.cleaned_data["picture"] + ).exists(): # Avoid existing relation + continue PeoplePictureRelation( user=u, picture=self.form.cleaned_data["picture"] ).save()