From c50fdd668949bd167b2a64eca06f91928cf61ae1 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Thu, 13 Aug 2020 19:43:37 +0200 Subject: [PATCH] Move the mailing list registration to the Profile model, see #50 --- apps/member/models.py | 22 +++++++++++++++++++ .../commands/extract_ml_registrations.py | 8 +++++++ apps/wei/models.py | 15 ------------- .../wei/templates/wei/weimembership_form.html | 9 -------- apps/wei/tests/test_wei_registration.py | 15 ------------- apps/wei/views.py | 3 --- 6 files changed, 30 insertions(+), 42 deletions(-) diff --git a/apps/member/models.py b/apps/member/models.py index b4b9b957..20f50591 100644 --- a/apps/member/models.py +++ b/apps/member/models.py @@ -92,6 +92,28 @@ class Profile(models.Model): default=False, ) + ml_events_registration = models.BooleanField( + blank=True, + null=True, + default=None, + choices=[ + (None, _("No")), + ('fr', _("Yes (receive them in french)")), + ('en', _("Yes (receive them in english)")), + ], + verbose_name=_("Register on the mailing list to stay informed of the events of the campus (1 mail/week)"), + ) + + ml_sport_registration = models.BooleanField( + default=False, + verbose_name=_("Register on the mailing list to stay informed of the sport events of the campus (1 mail/week)"), + ) + + ml_art_registration = models.BooleanField( + default=False, + verbose_name=_("Register on the mailing list to stay informed of the art events of the campus (1 mail/week)"), + ) + report_frequency = models.PositiveSmallIntegerField( verbose_name=_("report frequency (in days)"), default=0, diff --git a/apps/wei/management/commands/extract_ml_registrations.py b/apps/wei/management/commands/extract_ml_registrations.py index b67bf10b..6d48093e 100644 --- a/apps/wei/management/commands/extract_ml_registrations.py +++ b/apps/wei/management/commands/extract_ml_registrations.py @@ -5,6 +5,7 @@ from datetime import date from django.core.management import BaseCommand from django.db.models import Q + from member.models import Membership, Club from wei.models import WEIClub @@ -21,6 +22,13 @@ class Command(BaseCommand): help='Select the year of the concerned WEI. Default: last year') def handle(self, *args, **options): + ########################################################### + # WARNING # + ########################################################### + # + # This code is obsolete. + # TODO: Improve the mailing list extraction system, and link it automatically with Mailman. + if options["type"] == "members": for membership in Membership.objects.filter( club__name="BDE", diff --git a/apps/wei/models.py b/apps/wei/models.py index b72208ed..46d9383f 100644 --- a/apps/wei/models.py +++ b/apps/wei/models.py @@ -229,21 +229,6 @@ class WEIRegistration(models.Model): verbose_name=_("emergency contact phone"), ) - ml_events_registration = models.BooleanField( - default=False, - verbose_name=_("Register on the mailing list to stay informed of the events of the campus (1 mail/week)"), - ) - - ml_sport_registration = models.BooleanField( - default=False, - verbose_name=_("Register on the mailing list to stay informed of the sport events of the campus (1 mail/week)"), - ) - - ml_art_registration = models.BooleanField( - default=False, - verbose_name=_("Register on the mailing list to stay informed of the art events of the campus (1 mail/week)"), - ) - first_year = models.BooleanField( default=False, verbose_name=_("first year"), diff --git a/apps/wei/templates/wei/weimembership_form.html b/apps/wei/templates/wei/weimembership_form.html index 1fc4e43c..9a1a4d97 100644 --- a/apps/wei/templates/wei/weimembership_form.html +++ b/apps/wei/templates/wei/weimembership_form.html @@ -77,15 +77,6 @@
{% trans 'emergency contact phone'|capfirst %}
{{ registration.emergency_contact_phone }}
-
{% trans 'Register on the mailing list to stay informed of the events of the campus (1 mail/week)' %}
-
{{ registration.ml_events_registration|yesno }}
- -
{% trans 'Register on the mailing list to stay informed of the sport events of the campus (1 mail/week)' %}
-
{{ registration.ml_sport_registration|yesno }}
- -
{% trans 'Register on the mailing list to stay informed of the art events of the campus (1 mail/week)' %}
-
{{ registration.ml_art_registration|yesno }}
-
{% trans 'Payment from Société générale' %}
{{ registration.soge_credit|yesno }}
diff --git a/apps/wei/tests/test_wei_registration.py b/apps/wei/tests/test_wei_registration.py index f09ae604..de14c8b3 100644 --- a/apps/wei/tests/test_wei_registration.py +++ b/apps/wei/tests/test_wei_registration.py @@ -99,9 +99,6 @@ class TestWEIRegistration(TestCase): health_issues="I am a bot", emergency_contact_name="Pikachu", emergency_contact_phone="+33123456789", - ml_events_registration=True, - ml_sport_registration=True, - ml_art_registration=True, first_year=False, ) @@ -387,9 +384,6 @@ class TestWEIRegistration(TestCase): health_issues='I am a bot', emergency_contact_name='NoteKfet2020', emergency_contact_phone='+33123456789', - ml_events_registration=True, - ml_sport_registration=False, - ml_art_registration=False, )) qs = WEIRegistration.objects.filter(user_id=user.id) self.assertTrue(qs.exists()) @@ -422,9 +416,6 @@ class TestWEIRegistration(TestCase): health_issues='I am a bot', emergency_contact_name='NoteKfet2020', emergency_contact_phone='+33123456789', - ml_events_registration=True, - ml_sport_registration=False, - ml_art_registration=False, )) self.assertEqual(response.status_code, 200) self.assertTrue("This user is already registered to this WEI." in str(response.context["form"].errors)) @@ -448,9 +439,6 @@ class TestWEIRegistration(TestCase): health_issues='I am a bot', emergency_contact_name='NoteKfet2020', emergency_contact_phone='+33123456789', - ml_events_registration=True, - ml_sport_registration=False, - ml_art_registration=False, )) self.assertEqual(response.status_code, 200) self.assertTrue("This user can't be in her/his first year since he/she has already participated to a WEI." @@ -813,9 +801,6 @@ class TestWEISurveyAlgorithm(TestCase): health_issues="I am a bot", emergency_contact_name="Pikachu", emergency_contact_phone="+33123456789", - ml_events_registration=True, - ml_sport_registration=True, - ml_art_registration=True, first_year=True, ) CurrentSurvey(self.registration).save() diff --git a/apps/wei/views.py b/apps/wei/views.py index 5b16fe3a..ada4c5d8 100644 --- a/apps/wei/views.py +++ b/apps/wei/views.py @@ -594,9 +594,6 @@ class WEIRegister2AView(ProtectQuerysetMixin, LoginRequiredMixin, ProtectedCreat del form.fields["caution_check"] del form.fields["first_year"] - del form.fields["ml_events_registration"] - del form.fields["ml_art_registration"] - del form.fields["ml_sport_registration"] del form.fields["information_json"] return form