def get_or_create_user(cls, username, password): username = username.lower() if User.objects.filter(username=username).count(): print username, password user = User.objects.get(username=username) if password: print "Setting password" user.profile.set_password(password) user_profile = user.profile print user.username, user.password, user.profile.ninjacourses_password else: user = User.objects.create_user(username=username, email='', password=generate_password()) user_profile = UserProfile.objects.create( user=user, ninjacourses_password=generate_password()) user_profile.set_password(password) return user, user_profile
def get_or_create_user(cls, username, password): username = username.lower() if User.objects.filter(username=username).count(): print username, password user = User.objects.get(username=username) if password: print "Setting password" user.profile.set_password(password) user_profile = user.profile print user.username, user.password, user.profile.ninjacourses_password else: user = User.objects.create_user(username=username, email='', password=generate_password()) user_profile = UserProfile.objects.create(user=user, ninjacourses_password=generate_password()) user_profile.set_password(password) return user, user_profile
def add_friend(self, username, realname, url_as_friend): user, user_profile = UserProfile.get_or_create_user( username=username, password=generate_password()) user_profile.update(realname=realname, url_as_friend=url_as_friend) self.friend.add(user_profile)
def add_friend(self, username, realname, url_as_friend): user, user_profile = UserProfile.get_or_create_user(username=username, password=generate_password()) user_profile.update(realname=realname, url_as_friend=url_as_friend) self.friend.add(user_profile)