1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2024-11-26 18:37:12 +00:00

Add Bus information in the WEI survey "api"

This commit is contained in:
Yohann D'ANELLO 2020-04-24 19:34:20 +02:00
parent cdff0d3893
commit 705313edb6
2 changed files with 26 additions and 0 deletions

View File

@ -36,6 +36,16 @@ class WEISurveyInformation:
registration.information = self.__dict__ 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: class WEISurveyAlgorithm:
""" """
Abstract algorithm that attributes a bus to each new member. Abstract algorithm that attributes a bus to each new member.
@ -48,6 +58,14 @@ class WEISurveyAlgorithm:
""" """
raise NotImplementedError 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 @classmethod
def get_registrations(cls) -> QuerySet: def get_registrations(cls) -> QuerySet:
""" """
@ -62,6 +80,13 @@ class WEISurveyAlgorithm:
""" """
return Bus.objects.filter(wei__year=cls.get_survey_class().get_year()) 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: def run_algorithm(self) -> None:
""" """
Once this method implemented, run the algorithm that attributes a bus to each first year member. Once this method implemented, run the algorithm that attributes a bus to each first year member.

View File

@ -516,6 +516,7 @@ class WEIRegister2AView(ProtectQuerysetMixin, LoginRequiredMixin, CreateView):
form.fields["soge_credit"].disabled = True form.fields["soge_credit"].disabled = True
form.fields["soge_credit"].help_text = _("You already opened an account in the Société générale.") 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["first_year"]
del form.fields["ml_events_registration"] del form.fields["ml_events_registration"]
del form.fields["ml_art_registration"] del form.fields["ml_art_registration"]