Browse Source

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

master
Benni Bärmann 1 year ago
parent
commit
d2d9149a62
4 changed files with 42 additions and 6 deletions
  1. +4
    -4
      input/management/commands/sendmails.py
  2. +18
    -0
      input/migrations/0091_auto_20221209_1752.py
  3. +18
    -0
      input/migrations/0092_auto_20221209_1754.py
  4. +2
    -2
      input/models.py

+ 4
- 4
input/management/commands/sendmails.py View File

@ -68,7 +68,7 @@ class Command(BaseCommand):
# get all projects which ended # get all projects which ended
old = Project.objects.filter(end__lt = date.today())\ old = Project.objects.filter(end__lt = date.today())\
.exclude(end_mail_send = True)\
.exclude(end_mail_send = False)\
.filter(mail_state = 'NONE') .filter(mail_state = 'NONE')
txt_mail_template = get_template('input/if_end_of_project.txt') txt_mail_template = get_template('input/if_end_of_project.txt')
@ -92,7 +92,7 @@ class Command(BaseCommand):
# IF_EMAIL, # IF_EMAIL,
# [IF_EMAIL], # [IF_EMAIL],
# fail_silently=False) # fail_silently=False)
project.end_mail_send = True
project.end_mail_send = False
project.mail_state = 'INF' project.mail_state = 'INF'
try: try:
project.save() 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 # 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')\ approved_end = Project.objects.filter(status = 'END')\
.exclude(end_mail_send = False)\
.exclude(end_mail_send = True)\
.filter(mail_state = 'INF') .filter(mail_state = 'INF')
txt_mail_template = get_template('input/if_end_of_project_approved.txt') txt_mail_template = get_template('input/if_end_of_project_approved.txt')
html_mail_template = get_template('input/if_end_of_project_approved.html') 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 # 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')\ approved_notHappened = Project.objects.filter(status = 'NOT')\
.exclude(end_mail_send = False)\
.exclude(end_mail_send = True)\
.filter(mail_state = 'INF') .filter(mail_state = 'INF')
html_mail_template = get_template('input/if_not_of_project_approved.html') html_mail_template = get_template('input/if_not_of_project_approved.html')

+ 18
- 0
input/migrations/0091_auto_20221209_1752.py 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'),
),
]

+ 18
- 0
input/migrations/0092_auto_20221209_1754.py 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'),
),
]

+ 2
- 2
input/models.py View File

@ -19,9 +19,9 @@ class Volunteer(models.Model):
# the following Fields are not supposed to be edited by users # the following Fields are not supposed to be edited by users
granted = models.BooleanField(null=True, verbose_name='bewilligt') granted = models.BooleanField(null=True, verbose_name='bewilligt')
granted_date = models.DateField(null=True, verbose_name='bewilligt am') 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) 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') 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 @classmethod
@ -66,6 +66,7 @@ class Account(models.Model):
return f"{self.code} {self.description}" return f"{self.code} {self.description}"
class Project(Volunteer): 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') name = models.CharField(max_length=200, verbose_name='Name des Projekts')
description = models.CharField(max_length=500, verbose_name="Kurzbeschreibung", null=True) description = models.CharField(max_length=500, verbose_name="Kurzbeschreibung", null=True)
start = models.DateField('Startdatum', 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') 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") 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 # the following Fields are not supposed to be edited by users
pid = models.CharField(max_length=15, null=True, blank=True) pid = models.CharField(max_length=15, null=True, blank=True)

Loading…
Cancel
Save