Workout With Friends
Stay fit with a little motivation
 All Classes Namespaces Files Functions Variables Properties
adduser.py
Go to the documentation of this file.
1 import transaction
2 from getpass import getpass
3 from wowf.lib.auth import Auth
4 from wowf.models import User
5 from wowf.scripts import BaseCommand, make_main
6 
7 
9 
10  def run(self):
11  transaction.begin()
12  while True:
13  username = raw_input('Username: ')
14  email = raw_input('Email: ')
15  while True:
16  gender = raw_input('Gender (M/F): ')
17  if gender not in ('M', 'F'):
18  print 'Gender must be M or F!'
19  else:
20  break
21  while True:
22  password1 = getpass('Password: ')
23  password2 = getpass('Repeat password: ')
24  if password1 != password2:
25  print "Passwords don't match!"
26  else:
27  break
28  user = User.create(username, email, password1, gender, dob, weight, height)
29  Auth.register(user, login=False)
30  again = raw_input('Add another user ([y]/n)? ')
31  if again.upper() == 'N':
32  break
33  transaction.commit()
34 
35 
36 main = make_main(AddUserCommand)
37