From 56a3000a9f8e80c05eaca1154ce129dc70b67ece Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Fri, 13 Jul 2018 12:58:33 +0200 Subject: [PATCH] Filter by period --- .../commands/teleforma-export-wifi-accounts.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/teleforma/management/commands/teleforma-export-wifi-accounts.py b/teleforma/management/commands/teleforma-export-wifi-accounts.py index 78cf43f0..fc839ddf 100644 --- a/teleforma/management/commands/teleforma-export-wifi-accounts.py +++ b/teleforma/management/commands/teleforma-export-wifi-accounts.py @@ -16,12 +16,18 @@ class Command(BaseCommand): def handle(self, *args, **options): path = args[0] + period_name = args[1] + f = open(path, 'w') for user in User.objects.all(): profile = Profile.objects.filter(user=user) - if profile: + students = user.student.all() + if profile and students: p = profile[0] - f.write(p.wifi_login + ',' + p.wifi_pass + '\n') + student = students[0] + if student.is_subscribed and not user.is_active and student.period == period: + f.write(p.wifi_login + ',' + p.wifi_pass + '\n') f.close() + -- 2.39.5