From e285eb0911b30c02c4dad6eda3e2b6f79566d34e Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Thu, 13 Jan 2022 17:50:28 +0100 Subject: [PATCH] update teleforma-deactivate-students command --- .../commands/teleforma-deactivate-students.py | 22 ++----------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/teleforma/management/commands/teleforma-deactivate-students.py b/teleforma/management/commands/teleforma-deactivate-students.py index 3aca50eb..3283c8db 100644 --- a/teleforma/management/commands/teleforma-deactivate-students.py +++ b/teleforma/management/commands/teleforma-deactivate-students.py @@ -28,26 +28,9 @@ class Logger: class Command(BaseCommand): - help = "Deactivate student user and send an email" + help = "Deactivate student user for a given period" language_code = 'fr_FR' - def email(self, student): - site = Site.objects.get_current() - if student.platform_only: - mode = 'E-learning' - message = student.period.message_platform - else: - mode = 'Presentielle' - message = student.period.message_local - - ctx_dict = {'site': site, 'organization': settings.TELEMETA_ORGANIZATION, 'student': student, 'mode': mode} - subject_template = 'teleforma/messages/email_deactivate_subject.txt' - subject = render_to_string(subject_template, ctx_dict) - subject = ''.join(subject.splitlines()) - message_template = 'teleforma/messages/email_deactivate_body.txt' - message = render_to_string(message_template, ctx_dict) - send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [student.user.email], fail_silently=False) - def handle(self, *args, **options): log_file = args[-1] period_name = args[-2] @@ -63,7 +46,6 @@ class Command(BaseCommand): if student.is_subscribed and student.confirmation_sent and student.user.email and student.user.is_active: student.user.is_active = False student.user.save() - self.email(student) - logger.logger.info('deactivated and email sent : ' + student.user.username) + logger.logger.info('deactivated : ' + student.user.username) logger.logger.info('############## Done #################') -- 2.39.5