From 802a6c68cb32076b748c3b414fcd654326e71433 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Thu, 26 Aug 2021 00:11:24 +0200 Subject: [PATCH] [WEI] Update survey words Signed-off-by: Yohann D'ANELLO --- apps/wei/forms/registration.py | 2 +- apps/wei/forms/surveys/wei2021.py | 23 ++++++++++++++--------- apps/wei/models.py | 4 ++-- apps/wei/views.py | 2 ++ 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/apps/wei/forms/registration.py b/apps/wei/forms/registration.py index 3a1e779c..13e7b86b 100644 --- a/apps/wei/forms/registration.py +++ b/apps/wei/forms/registration.py @@ -138,7 +138,7 @@ class WEIMembershipForm(forms.ModelForm): class BusForm(forms.ModelForm): class Meta: model = Bus - exclude = ('information_json',) + fields = '__all__' widgets = { "wei": Autocomplete( WEIClub, diff --git a/apps/wei/forms/surveys/wei2021.py b/apps/wei/forms/surveys/wei2021.py index 6739772f..f35f3347 100644 --- a/apps/wei/forms/surveys/wei2021.py +++ b/apps/wei/forms/surveys/wei2021.py @@ -10,14 +10,16 @@ from django.utils.translation import gettext_lazy as _ from .base import WEISurvey, WEISurveyInformation, WEISurveyAlgorithm, WEIBusInformation from ...models import Bus - -# TODO: Use new words -WORDS = ['Rap', 'Retro', 'DJ', 'Rock', 'Jazz', 'Chansons Populaires', 'Chansons Paillardes', 'Pop', 'Fanfare', - 'Biere', 'Pastis', 'Vodka', 'Cocktails', 'Eau', 'Sirop', 'Jus de fruit', 'Binge Drinking', 'Rhum', - 'Eau de vie', 'Apéro', 'Morning beer', 'Huit-six', 'Jeux de societé', 'Jeux de cartes', 'Danse', 'Karaoké', - 'Bière Pong', 'Poker', 'Loup Garou', 'Films', "Jeux d'alcool", 'Sport', 'Rangées de cul', 'Chips', 'BBQ', - 'Kebab', 'Saucisse', 'Vegan', 'Vege', 'LGBTIQ+', 'Dab', 'Solitaire', 'Séducteur', 'Sociale', 'Chanteur', - 'Se lacher', 'Chill', 'Débile', 'Beauf', 'Bon enfant'] +WORDS = [ + '13 organisé', '3ième mi temps', 'Années 2000', 'Apéro', 'BBQ', 'BP', 'Beauf', 'Binge drinking', 'Bon enfant', + 'Cartouche', 'Catacombes', 'Chansons paillardes', 'Chansons populaires', 'Chanteur', 'Chartreuse', 'Chill', + 'Core', 'DJ', 'Dancefloor', 'Danse', 'David Guetta', 'Disco', 'Eau de vie', 'Électro', 'Escalade', 'Familial', + 'Fanfare', 'Fracassage', 'Féria', 'Hard rock', 'Hoeggarden', 'House', 'Huit-six', 'IPA', 'Inclusif', 'Inferno', + 'Introverti', 'Jager bomb', 'Jazz', 'Jeux d\'alcool', 'Jeux de rôles', 'Jeux vidéo', 'Jul', 'Jus de fruit', + 'Karaoké', 'LGBTQI+', 'Lady Gaga', 'Loup garou', 'Morning beer', 'Métal', 'Nuit blanche', 'Ovalie', 'Psychedelic', + 'Pétanque', 'Rave', 'Reggae', 'Rhum', 'Ricard', 'Rock', 'Rosé', 'Rétro', 'Séducteur', 'Techno', 'Thérapie taxi', + 'Théâtre', 'Trap', 'Turn up', 'Underground', 'Volley', 'Wati B', 'Zinédine Zidane', +] class WEISurveyForm2021(forms.Form): @@ -59,9 +61,12 @@ class WEIBusInformation2021(WEIBusInformation): """ For each word, the bus has a score """ + scores: dict + def __init__(self, bus): + self.scores = {} for word in WORDS: - setattr(self, word, 0.0) + self.scores[word] = 0.0 super().__init__(bus) diff --git a/apps/wei/models.py b/apps/wei/models.py index 750284a6..1788019c 100644 --- a/apps/wei/models.py +++ b/apps/wei/models.py @@ -96,7 +96,7 @@ class Bus(models.Model): """ Store information as a JSON string """ - self.information_json = json.dumps(information) + self.information_json = json.dumps(information, indent=2) def __str__(self): return self.name @@ -260,7 +260,7 @@ class WEIRegistration(models.Model): """ Store information as a JSON string """ - self.information_json = json.dumps(information) + self.information_json = json.dumps(information, indent=2) @property def is_validated(self): diff --git a/apps/wei/views.py b/apps/wei/views.py index 3371c963..bb8fec68 100644 --- a/apps/wei/views.py +++ b/apps/wei/views.py @@ -344,6 +344,8 @@ class BusUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, UpdateView): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context["club"] = self.object.wei + context["information"] = CurrentSurvey.get_algorithm_class().get_bus_information(self.object) + self.object.save() return context def get_form(self, form_class=None):