From d2d9149a627d3f270e03e90434402824833a2971 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benni=20B=C3=A4rmann?= Date: Fri, 9 Dec 2022 17:58:37 +0000 Subject: [PATCH] send end mails var in admin.model.project changed to boolean check field, also true is false now, so changed logic in sendmails.py --- input/management/commands/sendmails.py | 8 ++++---- input/migrations/0091_auto_20221209_1752.py | 18 ++++++++++++++++++ input/migrations/0092_auto_20221209_1754.py | 18 ++++++++++++++++++ input/models.py | 4 ++-- 4 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 input/migrations/0091_auto_20221209_1752.py create mode 100644 input/migrations/0092_auto_20221209_1754.py diff --git a/input/management/commands/sendmails.py b/input/management/commands/sendmails.py index 43abad3..4e1ad64 100755 --- a/input/management/commands/sendmails.py +++ b/input/management/commands/sendmails.py @@ -68,7 +68,7 @@ class Command(BaseCommand): # get all projects which ended old = Project.objects.filter(end__lt = date.today())\ - .exclude(end_mail_send = True)\ + .exclude(end_mail_send = False)\ .filter(mail_state = 'NONE') txt_mail_template = get_template('input/if_end_of_project.txt') @@ -92,7 +92,7 @@ class Command(BaseCommand): # IF_EMAIL, # [IF_EMAIL], # fail_silently=False) - project.end_mail_send = True + project.end_mail_send = False project.mail_state = 'INF' try: project.save() @@ -108,7 +108,7 @@ class Command(BaseCommand): # get all projects where end was reached already, and send mails for the ones already set to status "ended" by the admins approved_end = Project.objects.filter(status = 'END')\ - .exclude(end_mail_send = False)\ + .exclude(end_mail_send = True)\ .filter(mail_state = 'INF') txt_mail_template = get_template('input/if_end_of_project_approved.txt') html_mail_template = get_template('input/if_end_of_project_approved.html') @@ -165,7 +165,7 @@ class Command(BaseCommand): # get all projects where end was reached already, and send mails for the ones where status was put to NOT by admins approved_notHappened = Project.objects.filter(status = 'NOT')\ - .exclude(end_mail_send = False)\ + .exclude(end_mail_send = True)\ .filter(mail_state = 'INF') html_mail_template = get_template('input/if_not_of_project_approved.html') diff --git a/input/migrations/0091_auto_20221209_1752.py b/input/migrations/0091_auto_20221209_1752.py new file mode 100644 index 0000000..63905de --- /dev/null +++ b/input/migrations/0091_auto_20221209_1752.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.2 on 2022-12-09 17:52 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('input', '0090_auto_20221209_1720'), + ] + + operations = [ + migrations.AlterField( + model_name='project', + name='end_mail_send', + field=models.BooleanField(null=True, verbose_name='Keine Projektabschlussmail schicken'), + ), + ] diff --git a/input/migrations/0092_auto_20221209_1754.py b/input/migrations/0092_auto_20221209_1754.py new file mode 100644 index 0000000..ac5a873 --- /dev/null +++ b/input/migrations/0092_auto_20221209_1754.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.2 on 2022-12-09 17:54 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('input', '0091_auto_20221209_1752'), + ] + + operations = [ + migrations.AlterField( + model_name='project', + name='end_mail_send', + field=models.BooleanField(default=False, verbose_name='Keine Projektabschlussmail schicken'), + ), + ] diff --git a/input/models.py b/input/models.py index fa336a4..cce427a 100755 --- a/input/models.py +++ b/input/models.py @@ -19,9 +19,9 @@ class Volunteer(models.Model): # the following Fields are not supposed to be edited by users granted = models.BooleanField(null=True, verbose_name='bewilligt') granted_date = models.DateField(null=True, verbose_name='bewilligt am') - survey_mail_send = models.BooleanField(default=False, verbose_name='Keine Umfragemail schicken') survey_mail_date = models.DateField(verbose_name='Umfragemail wurde verschickt am', null=True, blank=True) mail_state = models.CharField(max_length=6, choices=EMAIL_STATES.items(), default='NONE') + survey_mail_send = models.BooleanField(default=False, verbose_name='Keine Umfragemail schicken') @classmethod @@ -66,6 +66,7 @@ class Account(models.Model): return f"{self.code} {self.description}" class Project(Volunteer): + end_mail_send = models.BooleanField(default=False, verbose_name='Keine Projektabschlussmail schicken') name = models.CharField(max_length=200, verbose_name='Name des Projekts') description = models.CharField(max_length=500, verbose_name="Kurzbeschreibung", null=True) start = models.DateField('Startdatum', null=True) @@ -87,7 +88,6 @@ class Project(Volunteer): notes = models.TextField(max_length=1000,null=True,blank=True,verbose_name='Anmerkungen') intern_notes = models.TextField(max_length=1000, blank=True, verbose_name="interne Anmerkungen") - end_mail_send = models.BooleanField(null=True, verbose_name='Endmail versenden') # the following Fields are not supposed to be edited by users pid = models.CharField(max_length=15, null=True, blank=True)