From 5a2a5d769fbf7c630614b82ea0d59aa067490eb6 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Fri, 2 Feb 2018 09:36:05 +0100 Subject: [PATCH] Add validation date, rename confirmation_date --- candidats/admin.py | 6 ++-- candidats/migrations/0001_initial.py | 4 +-- .../0007_candidate_datetime_fields.py | 31 +++++++++++++++++++ candidats/models.py | 9 +++--- candidats/tests.py | 6 ++-- 5 files changed, 44 insertions(+), 12 deletions(-) create mode 100644 candidats/migrations/0007_candidate_datetime_fields.py diff --git a/candidats/admin.py b/candidats/admin.py index 4953f09..c595c3a 100644 --- a/candidats/admin.py +++ b/candidats/admin.py @@ -117,7 +117,7 @@ class CandidateAdmin(admin.ModelAdmin): form = CandidateForm list_display = ('last_name', 'first_name', 'section', 'confirm_mail', 'convocation') list_filter = ('section', 'option') - readonly_fields = ('total_result_points', 'total_result_mark', 'date_confirmation_mail') + readonly_fields = ('total_result_points', 'total_result_mark', 'confirmation_date') actions = [export_candidates, send_confirmation_mail, print_summary] fieldsets = ( (None, { @@ -127,7 +127,7 @@ class CandidateAdmin(admin.ModelAdmin): ('birth_date', 'avs', 'handicap', 'has_photo'), ('section', 'option'), ('corporation', 'instructor'), - ('deposite_date', 'date_confirmation_mail', 'canceled_file'), + ('deposite_date', 'confirmation_date', 'canceled_file'), 'comment', ), }), @@ -150,7 +150,7 @@ class CandidateAdmin(admin.ModelAdmin): ) def confirm_mail(self, obj): - return obj.date_confirmation_mail is not None + return obj.confirmation_date is not None confirm_mail.boolean = True def convocation(self, obj): diff --git a/candidats/migrations/0001_initial.py b/candidats/migrations/0001_initial.py index 715ed91..106504b 100644 --- a/candidats/migrations/0001_initial.py +++ b/candidats/migrations/0001_initial.py @@ -27,12 +27,12 @@ class Migration(migrations.Migration): ('email', models.EmailField(blank=True, max_length=254, verbose_name='Courriel')), ('avs', models.CharField(blank=True, max_length=15, verbose_name='No AVS')), ('handicap', models.BooleanField(default=False)), - ('section', models.CharField(choices=[('ASA', 'Aide en soin et accompagnement AFP'), ('ASE', 'Assist. socio-éducatif-ve CFC'), ('ASSC', 'Assist. en soin et santé communautaire CFC'), ('EDE', "Educ. de l'enfance, dipl. ES"), ('EDS', 'Educ. social-e, dipl. ES')], max_length=10, verbose_name='Filière')), + ('section', models.CharField(choices=[('ASA', 'Aide en soin et accompagnement AFP'), ('ASE', 'Assist. socio-éducatif-ve CFC'), ('ASSC', 'Assist. en soin et santé communautaire CFC'), ('EDE', "Education de l'enfance, dipl. ES"), ('EDS', 'Education sociale, dipl. ES')], max_length=10, verbose_name='Filière')), ('option', models.CharField(blank=True, choices=[('GEN', 'Généraliste'), ('ENF', 'Enfance'), ('PAG', 'Personnes âgées'), ('HAN', 'Handicap'), ('PE-5400h', 'Parcours Emploi 5400h.'), ('PE-3600h', 'Parcours Emploi 3600h.'), ('PS', 'Parcours stage')], max_length=20, verbose_name='Option')), ('exemption_ecg', models.BooleanField(default=False)), ('validation_sfpo', models.DateField(blank=True, null=True, verbose_name='Confirmation SFPO')), ('integration_second_year', models.BooleanField(default=False, verbose_name='Intégration')), - ('date_confirmation_mail', models.DateField(blank=True, null=True, verbose_name='Mail de confirmation')), + ('date_confirmation_mail', models.DateField(blank=True, null=True, verbose_name='Envoi mail de confirmation')), ('canceled_file', models.BooleanField(default=False, verbose_name='Dossier retiré')), ('has_photo', models.BooleanField(default=False, verbose_name='Photo passeport')), ('registration_form', models.BooleanField(default=False, verbose_name="Formulaire d'inscription")), diff --git a/candidats/migrations/0007_candidate_datetime_fields.py b/candidats/migrations/0007_candidate_datetime_fields.py new file mode 100644 index 0000000..28b9ba5 --- /dev/null +++ b/candidats/migrations/0007_candidate_datetime_fields.py @@ -0,0 +1,31 @@ +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('candidats', '0006_residence_permits_nullable'), + ] + + operations = [ + migrations.AddField( + model_name='candidate', + name='validation_date', + field=models.DateTimeField(blank=True, null=True, verbose_name='Envoi mail de validation'), + ), + migrations.AlterField( + model_name='candidate', + name='convocation_date', + field=models.DateTimeField(blank=True, null=True, verbose_name='Envoi mail de confirmation'), + ), + migrations.RenameField( + model_name='candidate', + old_name='date_confirmation_mail', + new_name='confirmation_date', + ), + migrations.AlterField( + model_name='candidate', + name='confirmation_date', + field=models.DateTimeField(blank=True, null=True, verbose_name='Envoi mail de confirmation'), + ), + ] diff --git a/candidats/models.py b/candidats/models.py index 5c09f1c..49ec1bb 100644 --- a/candidats/models.py +++ b/candidats/models.py @@ -13,8 +13,8 @@ SECTION_CHOICES = ( ('ASA', 'Aide en soin et accompagnement AFP'), ('ASE', 'Assist. socio-éducatif-ve CFC'), ('ASSC', 'Assist. en soin et santé communautaire CFC'), - ('EDE', 'Educ. de l\'enfance, dipl. ES'), - ('EDS', 'Educ. social-e, dipl. ES'), + ('EDE', "Education de l'enfance, dipl. ES"), + ('EDS', 'Education sociale, dipl. ES'), ) OPTION_CHOICES = ( @@ -76,7 +76,7 @@ class Candidate(models.Model): exemption_ecg = models.BooleanField(default=False) validation_sfpo = models.DateField('Confirmation SFPO', blank=True, null=True) integration_second_year = models.BooleanField('Intégration', default=False) - date_confirmation_mail = models.DateField('Mail de confirmation', blank=True, null=True) + confirmation_date = models.DateTimeField('Envoi mail de confirmation', blank=True, null=True) canceled_file = models.BooleanField('Dossier retiré', default=False) has_photo = models.BooleanField(default=False, verbose_name='Photo passeport') @@ -114,7 +114,8 @@ class Candidate(models.Model): diploma_detail = models.CharField('Détail titre', max_length=30, blank=True, default='') diploma_status = models.PositiveSmallIntegerField("Statut titre", choices=DIPLOMA_STATUS_CHOICES, default=0) activity_rate = models.CharField("Taux d'activité", max_length=50, blank=True, default='') - convocation_date = models.DateTimeField(null=True, blank=True, default=None) + validation_date = models.DateTimeField('Envoi mail de validation', null=True, blank=True) + convocation_date = models.DateTimeField('Envoi mail de confirmation', null=True, blank=True) aes_accords = models.PositiveSmallIntegerField("Accord AES", choices=AES_ACCORDS_CHOICES, default=0) residence_permits = models.PositiveSmallIntegerField( diff --git a/candidats/tests.py b/candidats/tests.py index b025296..a3a378b 100644 --- a/candidats/tests.py +++ b/candidats/tests.py @@ -92,7 +92,7 @@ class CandidateTests(TestCase): # A mail should NOT be sent for those first 2 Candidate( first_name='Jill', last_name='Simth', gender='F', section=ede, - deposite_date=date.today(), date_confirmation_mail=date.today()), + deposite_date=date.today(), confirmation_date=date.today()), Candidate(first_name='Hervé', last_name='Bern', gender='M', section=ede, deposite_date=date.today(), canceled_file=True), # Good @@ -142,7 +142,7 @@ me@example.org """.format() ) # One was already set, 2 new. - self.assertEqual(Candidate.objects.filter(date_confirmation_mail__isnull=False).count(), 3) + self.assertEqual(Candidate.objects.filter(confirmation_date__isnull=False).count(), 3) def test_send_confirmation_error(self): ede = Section.objects.create(name='EDE') @@ -160,7 +160,7 @@ me@example.org }, follow=True) self.assertContains(response, "Échec d’envoi pour le candidat Dupond Henri (Error sending mail)") henri.refresh_from_db() - self.assertIsNone(henri.date_confirmation_mail) + self.assertIsNone(henri.confirmation_date) def test_convocation_ede(self): ede = Section.objects.create(name='EDE')