@ -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
from input.models import Project , Library , HonoraryCertificate
from input.settings import URLPREFIX , IF_EMAIL , SURVEYPREFIX
class Command ( BaseCommand ) :
@ -13,13 +13,13 @@ class Command(BaseCommand):
- two weeks after confirmation of support for volunteer ( / extern ) send link
with surveylink
- same for HonoraryCertificate and accreditation ( / intern )
- TODO : same for HonoraryCertificate ( / intern )
- travel : mail 3 weeks after end of project .
- TODO : travel : mail 3 weeks after end of project .
- assumed end of project ( / project ) reached : mail to IF , link to project - editpage
- 4 weeks after end of project reached : mail with surveylink
- TODO : 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
@ -86,4 +86,18 @@ class Command(BaseCommand):
item . survey_mail_send = True
item . save ( )
# get all HonoraryCertificate objects which where granted two weeks ago
supported = HonoraryCertificate . objects . filter ( granted = True ) \
. filter ( granted_date__lt = date . today ( ) - timedelta ( days = 14 ) ) \
. exclude ( survey_mail_send = True )
print ( supported )
for item in supported :
self . survey_link ( email = item . email ,
type = ' HON ' ,
pid = 9999 , ## TODO
name = item . request_url ,
realname = item . realname )
item . survey_mail_send = True
item . save ( )
self . stdout . write ( self . style . SUCCESS ( ' sendmails custom command executed ' ) )