From f25eb1d2c5d972bc2ed39f0d078a0944e297c7aa Mon Sep 17 00:00:00 2001
From: Yohann D'ANELLO <ynerant@crans.org>
Date: Sun, 5 Sep 2021 17:30:59 +0200
Subject: [PATCH] [WEI] Fix some issues

Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
---
 apps/wei/forms/surveys/wei2021.py |  1 +
 apps/wei/views.py                 | 12 ++++++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/apps/wei/forms/surveys/wei2021.py b/apps/wei/forms/surveys/wei2021.py
index fd788a74..16a9961c 100644
--- a/apps/wei/forms/surveys/wei2021.py
+++ b/apps/wei/forms/surveys/wei2021.py
@@ -40,6 +40,7 @@ class WEISurveyForm2021(forms.Form):
         if not information.seed:
             information.seed = int(1000 * time.time())
             information.save(registration)
+            registration._force_save = True
             registration.save()
 
         rng = Random(information.seed)
diff --git a/apps/wei/views.py b/apps/wei/views.py
index 231fc220..2fb1f4a5 100644
--- a/apps/wei/views.py
+++ b/apps/wei/views.py
@@ -487,9 +487,13 @@ class WEIRegister1AView(ProtectQuerysetMixin, ProtectedCreateView):
 
     def get_sample_object(self):
         wei = WEIClub.objects.get(pk=self.kwargs["wei_pk"])
+        if "myself" in self.request.path:
+            user = self.request.user
+        else:
+            user = User.objects.get(username="note")
         return WEIRegistration(
             wei=wei,
-            user=User.objects.get(username="note"),
+            user=user,
             first_year=True,
             birth_date="1970-01-01",
             gender="No",
@@ -555,9 +559,13 @@ class WEIRegister2AView(ProtectQuerysetMixin, ProtectedCreateView):
 
     def get_sample_object(self):
         wei = WEIClub.objects.get(pk=self.kwargs["wei_pk"])
+        if "myself" in self.request.path:
+            user = self.request.user
+        else:
+            user = User.objects.get(username="note")
         return WEIRegistration(
             wei=wei,
-            user=User.objects.get(username="note"),
+            user=user,
             first_year=True,
             birth_date="1970-01-01",
             gender="No",
-- 
GitLab