From c816fbd2fe6d4cccbbf6fd0dea01319c91663174 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Mon, 26 Oct 2020 12:56:29 +0100 Subject: [PATCH] reorganisation of functions in sendmails command --- input/management/commands/sendmails.py | 29 +++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/input/management/commands/sendmails.py b/input/management/commands/sendmails.py index 18bc7b2..3a1621e 100644 --- a/input/management/commands/sendmails.py +++ b/input/management/commands/sendmails.py @@ -13,7 +13,7 @@ class Command(BaseCommand): - two weeks after confirmation of support for volunteer (/extern) send link with surveylink - - TODO: same for HonoraryCertificate (/intern) + - same for HonoraryCertificate (/intern) - 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.')) + 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)\ .filter(granted_date__lt = date.today() - timedelta(days=14))\ .exclude(survey_mail_send=True) @@ -86,7 +83,9 @@ class Command(BaseCommand): item.survey_mail_send = True 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)\ .filter(granted_date__lt = date.today() - timedelta(days=14))\ .exclude(survey_mail_send=True) @@ -100,4 +99,20 @@ class Command(BaseCommand): item.survey_mail_send = True 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'))