if profile and students:
p = profile[0]
student = students[0]
- if student.is_subscribed and user.is_active and student.period == period:
+ if student.is_subscribed and user.is_active and \
+ student.period == period and student.platform_only:
data = []
data.append(user.first_name)
data.append(user.last_name)
- data.append(str(period.date_begin))
- data.append(str(period.date_end))
- data.append(str(period.date_begin))
- data.append(str(period.date_end))
data.append(p.wifi_login)
data.append(p.wifi_pass)
data.append('\n')
s = ','.join(data)
- f.write(s.encode('utf8'))
+ f.write(s)
f.close()
class Command(BaseCommand):
help = "init all user wifi pass"
- args = 'path'
-
- def add_arguments(self, parser):
- parser.add_argument('args', nargs='*')
def handle(self, *args, **options):
- path = args[0]
- f = open(path, 'w')
-
for user in User.objects.all():
try:
profile = user.profile.get()
profile.wifi_login = user.username
profile.wifi_pass = id_generator(8)
profile.save()
- f.write(user.first_name + ',' + user.last_name + ',' +
- profile.wifi_login + ',' + profile.wifi_pass + '\n')
except:
continue
-
- f.close()