From: Guillaume Pellerin Date: Fri, 5 Feb 2016 09:48:17 +0000 (+0100) Subject: fix account init X-Git-Tag: 1.1~72 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=f5bb58e898ee1009e315e8e7828539e51e1808ea;p=teleforma.git fix account init --- diff --git a/teleforma/management/commands/teleforma-reset-all-passwords-with-mail.py b/teleforma/management/commands/teleforma-reset-all-passwords-with-mail.py index 3d4cc917..fc21978d 100644 --- a/teleforma/management/commands/teleforma-reset-all-passwords-with-mail.py +++ b/teleforma/management/commands/teleforma-reset-all-passwords-with-mail.py @@ -43,18 +43,24 @@ class Command(BaseCommand): def handle(self, *args, **options): log_file = args[-1] + period_name = args[-2] logger = Logger(log_file) logger.logger.info('########### Processing #############') + period = Period.objects.get(name=period_name) users = User.objects.all() translation.activate(self.language_code) for user in users: profile, c = Profile.objects.get_or_create(user=user) students = user.student.all() + if students: + student = students[0] + else: + student = Student() professors = user.professor.all() quotas = user.quotas.all() - if students or professors or quotas: + if student.period == period or professors or quotas: if profile and user.is_active: if not profile.init_password and user.email: self.init_password_email(user) diff --git a/teleforma/management/commands/teleforma-send-subscription-email.py b/teleforma/management/commands/teleforma-send-subscription-email.py index 965393d1..5011ccac 100644 --- a/teleforma/management/commands/teleforma-send-subscription-email.py +++ b/teleforma/management/commands/teleforma-send-subscription-email.py @@ -56,7 +56,7 @@ class Command(BaseCommand): translation.activate(self.language_code) for student in students: - if student.is_subscribed and not student.confirmation_sent and student.user.is_active and student.user.email and student.period == period: + if student.is_subscribed and not student.confirmation_sent and student.user.email and student.period == period: self.email(student) student.confirmation_sent = True student.save()