From 3eaac5c68f7913258a0156700a0c54a28202f707 Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Mon, 22 May 2023 11:10:44 +0200 Subject: [PATCH] =?UTF-8?q?feat(cof):=20Rajoute=20la=20date=20d'adh=C3=A9s?= =?UTF-8?q?ion=20dans=20les=20profils?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../0019_cofprofile_date_adhesion.py | 19 +++++++++++++++++++ gestioncof/models.py | 1 + gestioncof/tests/test_views.py | 6 ++++-- gestioncof/views.py | 7 ++++++- 4 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 gestioncof/migrations/0019_cofprofile_date_adhesion.py diff --git a/gestioncof/migrations/0019_cofprofile_date_adhesion.py b/gestioncof/migrations/0019_cofprofile_date_adhesion.py new file mode 100644 index 00000000..5e70398b --- /dev/null +++ b/gestioncof/migrations/0019_cofprofile_date_adhesion.py @@ -0,0 +1,19 @@ +# Generated by Django 2.2.28 on 2023-05-22 09:01 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("gestioncof", "0018_petitscours_email"), + ] + + operations = [ + migrations.AddField( + model_name="cofprofile", + name="date_adhesion", + field=models.DateField( + blank=True, null=True, verbose_name="Date d'adhésion" + ), + ), + ] diff --git a/gestioncof/models.py b/gestioncof/models.py index c2c71660..d16b3db2 100644 --- a/gestioncof/models.py +++ b/gestioncof/models.py @@ -50,6 +50,7 @@ class CofProfile(models.Model): "Login clipper", max_length=32, blank=True, unique=True, null=True ) is_cof = models.BooleanField("Membre du COF", default=False) + date_adhesion = models.DateField("Date d'adhésion", blank=True, null=True) phone = models.CharField("Téléphone", max_length=20, blank=True) occupation = models.CharField( _("Occupation"), diff --git a/gestioncof/tests/test_views.py b/gestioncof/tests/test_views.py index d4955732..80d33c14 100644 --- a/gestioncof/tests/test_views.py +++ b/gestioncof/tests/test_views.py @@ -1,5 +1,5 @@ import uuid -from datetime import timedelta +from datetime import date, timedelta from django.contrib import messages from django.contrib.auth import get_user_model @@ -484,6 +484,7 @@ class ExportMembersViewTests(CSVResponseMixin, ViewTestCaseMixin, TestCase): u1.last_name = "last" u1.email = "user@mail.net" u1.save() + u1.profile.date_adhesion = date(2023, 5, 22) u1.profile.phone = "0123456789" u1.profile.departement = "Dept" u1.profile.save() @@ -505,8 +506,9 @@ class ExportMembersViewTests(CSVResponseMixin, ViewTestCaseMixin, TestCase): "1A", "Dept", "normalien", + "2023-05-22", ], - [str(u2.pk), "staff", "", "", "", "", "1A", "", "normalien"], + [str(u2.pk), "staff", "", "", "", "", "1A", "", "normalien", "None"], ], ) diff --git a/gestioncof/views.py b/gestioncof/views.py index fbe74ec7..37353346 100644 --- a/gestioncof/views.py +++ b/gestioncof/views.py @@ -1,6 +1,6 @@ import csv import uuid -from datetime import timedelta +from datetime import date, timedelta from smtplib import SMTPRecipientsRefused from urllib.parse import parse_qs, urlencode, urlparse, urlunparse @@ -86,6 +86,7 @@ class ResetComptes(BuroRequiredMixin, TemplateView): nb_adherents = CofProfile.objects.filter(is_cof=True).count() CofProfile.objects.update( is_cof=False, + date_adhesion=None, mailing_cof=False, mailing_bda=False, mailing_bda_revente=False, @@ -575,6 +576,9 @@ def registration(request): profile = profile_form.save() if profile.is_cof and not was_cof: notify_new_member(request, member) + profile.date_adhesion = date.today() + profile.save() + # Enregistrement des inscriptions aux événements for form in event_formset: if "status" not in form.cleaned_data: @@ -715,6 +719,7 @@ def export_members(request): profile.occupation, profile.departement, profile.type_cotiz, + profile.date_adhesion, ] writer.writerow([str(bit) for bit in bits])