send end mails var in admin.model.project changed to boolean check field, also true is false now, so changed logic in sendmails.py

This commit is contained in:
Benni Bärmann 2022-12-09 17:58:37 +00:00
parent a6defcb627
commit d2d9149a62
4 changed files with 42 additions and 6 deletions

View file

@ -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')

View file

@ -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'),
),
]

View file

@ -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'),
),
]

View file

@ -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)