reorganisation of functions in sendmails command

This commit is contained in:
Benni Bärmann 2020-10-26 12:56:29 +01:00
parent d82cea75e9
commit c816fbd2fe
1 changed files with 22 additions and 7 deletions

View File

@ -13,7 +13,7 @@ class Command(BaseCommand):
- two weeks after confirmation of support for volunteer (/extern) send link - two weeks after confirmation of support for volunteer (/extern) send link
with surveylink with surveylink
- TODO: same for HonoraryCertificate (/intern) - same for HonoraryCertificate (/intern)
- TODO: travel: mail 3 weeks after end of project. - TODO: travel: mail 3 weeks after end of project.
@ -67,12 +67,9 @@ class Command(BaseCommand):
self.stdout.write(self.style.SUCCESS('end_of_projects_reached() executed.')) self.stdout.write(self.style.SUCCESS('end_of_projects_reached() executed.'))
def surveymails_to_lib(self):
'''get all library objects which where granted two weeks ago'''
def handle(self, *args, **options):
self.end_of_projects_reached()
# get all library objects which where granted two weeks ago
supported = Library.objects.filter(granted=True)\ supported = Library.objects.filter(granted=True)\
.filter(granted_date__lt = date.today() - timedelta(days=14))\ .filter(granted_date__lt = date.today() - timedelta(days=14))\
.exclude(survey_mail_send=True) .exclude(survey_mail_send=True)
@ -86,7 +83,9 @@ class Command(BaseCommand):
item.survey_mail_send = True item.survey_mail_send = True
item.save() item.save()
# get all HonoraryCertificate objects which where granted two weeks ago def surveymails_to_hon(self):
'''get all HonoraryCertificate objects which where granted two weeks ago'''
supported = HonoraryCertificate.objects.filter(granted=True)\ supported = HonoraryCertificate.objects.filter(granted=True)\
.filter(granted_date__lt = date.today() - timedelta(days=14))\ .filter(granted_date__lt = date.today() - timedelta(days=14))\
.exclude(survey_mail_send=True) .exclude(survey_mail_send=True)
@ -100,4 +99,20 @@ class Command(BaseCommand):
item.survey_mail_send = True item.survey_mail_send = True
item.save() item.save()
def surveymails_to_project(self):
pass
def surveymails_to_travel(self):
pass
def handle(self, *args, **options):
'''the main function which is called by the custom command'''
self.end_of_projects_reached()
self.surveymails_to_lib()
self.surveymails_to_hon()
self.surveymails_to_project()
self.surveymails_to_travel()
self.stdout.write(self.style.SUCCESS('sendmails custom command executed')) self.stdout.write(self.style.SUCCESS('sendmails custom command executed'))