1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-02-24 09:01:18 +00:00

Compare commits

..

2 Commits

Author SHA1 Message Date
f25eb1d2c5
[WEI] Fix some issues
Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
2021-09-05 17:30:59 +02:00
a2a749e1ca
[WEI] Fix permission check to register new accounts to users
Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
2021-09-05 17:15:19 +02:00
2 changed files with 22 additions and 12 deletions

View File

@ -40,15 +40,17 @@ 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)
words = []
for _ignored in range(information.step + 1):
# Generate N times words
words = None
preferred_words = {bus: [word for word in WORDS if WEIBusInformation2021(bus).scores[word] >= 50]
# Update seed
rng.randint(0, information.step)
preferred_words = {bus: [word for word in WORDS if bus.size > 0
and WEIBusInformation2021(bus).scores[word] >= 50]
for bus in WEISurveyAlgorithm2021.get_buses()}
while words is None or len(set(words)) != len(words):
# Ensure that there is no the same word 2 times

View File

@ -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=self.request.user,
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=self.request.user,
user=user,
first_year=True,
birth_date="1970-01-01",
gender="No",