sned mails for Travel objects 3 weeks after the related project has ended

This commit is contained in:
Benni Bärmann 2020-10-26 13:23:05 +01:00
parent cdc8b01d2f
commit 1458a1cb6b
1 changed files with 17 additions and 3 deletions

View File

@ -4,7 +4,7 @@ from django.core.management.base import BaseCommand, CommandError
from django.template.loader import get_template
from django.core.mail import send_mail, BadHeaderError
from input.models import Project, Library, HonoraryCertificate
from input.models import Project, Library, HonoraryCertificate, Travel
from input.settings import URLPREFIX, IF_EMAIL, SURVEYPREFIX
class Command(BaseCommand):
@ -15,11 +15,11 @@ class Command(BaseCommand):
- same for HonoraryCertificate (/intern)
- TODO: travel: mail 3 weeks after end of project.
- travel: mail 3 weeks after end of project.
- assumed end of project (/project) reached: mail to IF, link to project-editpage
- TODO: 4 weeks after end of project reached: mail with surveylink
- 4 weeks after end of project reached: mail with surveylink
'''
help = '''This command sends mail with some links to the database or to the survey
@ -116,6 +116,20 @@ class Command(BaseCommand):
def surveymails_to_travel(self):
'''send survey link 3 weeks after end of project reached'''
supported = Travel.objects.filter(project__granted=True)\
.filter(project__granted_date__lt = date.today() - timedelta(days=21))\
.exclude(survey_mail_send=True)
print(supported)
for item in supported:
self.survey_link(email=item.email,
type='TRAV',
pid=9999, ## TODO
name=item.request_url,
realname=item.realname)
item.survey_mail_send = True
item.save()
pass