taskapp/events/user.py
changeset 31 988d4994578f
parent 30 055dc4c1db57
child 107 4903b4973fc8
equal deleted inserted replaced
30:055dc4c1db57 31:988d4994578f
    24         password : a password
    24         password : a password
    25         dob : a date object
    25         dob : a date object
    26         gender : u'M'/u'F' 
    26         gender : u'M'/u'F' 
    27     """
    27     """
    28 
    28 
    29     user = User(username=username, email=email)
    29     try:
    30     user.set_password(password)
    30         user = User.objects.get(username=username)
    31     user.save()
    31         return user
    32     properties = {'dob':dob, 'gender':gender}
    32     except:        
    33     user_profile = Profile(user=user)
    33         user = User(username=username, email=email)
    34     updateProfile(user_profile, properties)
    34         user.set_password(password)
    35     return user
    35         user.save()
       
    36         properties = {'dob':dob, 'gender':gender}
       
    37         user_profile = Profile(user=user)
       
    38         updateProfile(user_profile, properties)
       
    39         return user
    36     
    40     
    37 def createSuUser(username,email,password,dob,gender):
    41 def createSuUser(username,email,password,dob,gender):
    38     """ create user using createUser method and set the is_superuser flag """
    42     """ create user using createUser method and set the is_superuser flag """
    39     
    43     
    40     su_user = createUser(username,email,password,dob,gender)
    44     su_user = createUser(username,email,password,dob,gender)
    41     su_user.is_staff = True
    45     su_user.is_staff = True
    42     su_user.is_superuser = True
    46     su_user.is_superuser = True
    43     su_user.save()
    47     su_user.save()
       
    48     return su_user