From ffaa0203109acbe654e1b828f103b4354fbfe3d6 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Sun, 5 Sep 2021 18:52:57 +0200 Subject: [PATCH] Fix WEI registration in dev mode Signed-off-by: Yohann D'ANELLO --- apps/wei/views.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/wei/views.py b/apps/wei/views.py index 2fb1f4a5..a9d0c865 100644 --- a/apps/wei/views.py +++ b/apps/wei/views.py @@ -490,7 +490,10 @@ class WEIRegister1AView(ProtectQuerysetMixin, ProtectedCreateView): if "myself" in self.request.path: user = self.request.user else: - user = User.objects.get(username="note") + # To avoid unique validation issues, we use an account that can't join the WEI. + # In development mode, the note account may not exist, we use a random user (may fail) + user = User.objects.get(username="note") if User.objects.filter(username="note").exists() \ + else User.objects.first() return WEIRegistration( wei=wei, user=user, @@ -562,7 +565,10 @@ class WEIRegister2AView(ProtectQuerysetMixin, ProtectedCreateView): if "myself" in self.request.path: user = self.request.user else: - user = User.objects.get(username="note") + # To avoid unique validation issues, we use an account that can't join the WEI. + # In development mode, the note account may not exist, we use a random user (may fail) + user = User.objects.get(username="note") if User.objects.filter(username="note").exists() \ + else User.objects.first() return WEIRegistration( wei=wei, user=user,