From 705313edb6eeade86344f80c906ab7669bd5f1ef Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Fri, 24 Apr 2020 19:34:20 +0200 Subject: [PATCH] Add Bus information in the WEI survey "api" --- apps/wei/forms/surveys/base.py | 25 +++++++++++++++++++++++++ apps/wei/views.py | 1 + 2 files changed, 26 insertions(+) diff --git a/apps/wei/forms/surveys/base.py b/apps/wei/forms/surveys/base.py index 80ee6fc3..f43dafc2 100644 --- a/apps/wei/forms/surveys/base.py +++ b/apps/wei/forms/surveys/base.py @@ -36,6 +36,16 @@ class WEISurveyInformation: registration.information = self.__dict__ +class WEIBusInformation: + """ + Abstract data of the bus. + """ + + def __init__(self, bus: Bus): + self.__dict__.update(bus.information) + self.bus = bus + + class WEISurveyAlgorithm: """ Abstract algorithm that attributes a bus to each new member. @@ -48,6 +58,14 @@ class WEISurveyAlgorithm: """ raise NotImplementedError + @classmethod + def get_bus_information_class(cls): + """ + The class of the information associated to a bus extending WEIBusInformation. + Default: WEIBusInformation (contains nothing) + """ + return WEIBusInformation + @classmethod def get_registrations(cls) -> QuerySet: """ @@ -62,6 +80,13 @@ class WEISurveyAlgorithm: """ return Bus.objects.filter(wei__year=cls.get_survey_class().get_year()) + @classmethod + def get_bus_information(cls, bus): + """ + Return the WEIBusInformation object containing the data stored in a given bus. + """ + return cls.get_bus_information_class()(bus) + def run_algorithm(self) -> None: """ Once this method implemented, run the algorithm that attributes a bus to each first year member. diff --git a/apps/wei/views.py b/apps/wei/views.py index 0f9ffd2c..ca596053 100644 --- a/apps/wei/views.py +++ b/apps/wei/views.py @@ -516,6 +516,7 @@ class WEIRegister2AView(ProtectQuerysetMixin, LoginRequiredMixin, CreateView): form.fields["soge_credit"].disabled = True form.fields["soge_credit"].help_text = _("You already opened an account in the Société générale.") + del form.fields["caution_check"] del form.fields["first_year"] del form.fields["ml_events_registration"] del form.fields["ml_art_registration"]