def user_save(methods=('GET','POST')): form = UserForm2(request.form) if form.validate(): if len(form.uid.data) > 0: # Existing user user = User.get_user_id(form.uid.data) else: # New user user = User() user.organization = g.organization user.active = form.active.data user.username = form.name.data user.name.first, user.name.last = form.name.data.split(' ') user.password = Password().set_password(form.password.data) user.save() return redirect(url_for('management.user_browse')) else: print "WTF?!" print form.errors return render_template('management/users/edit_users.html', form=form) return render_template('management/products/create_users.html', form=form)
def build_user(): u = User() u.username = raw_input("Username (email): ") u.name = NameToken() u.name.first, u.name.last = raw_input("Name: ").split(" ") # Get the organizations for org in multiprompt_organization(): u.organizations.append(org) # Setup the password p = Password() p.set_password(raw_input("Password: ")) p.save() u.password = p u.active = True # Create a settings store for item in DEFAULT_SETTINGS.items(): u.settings[item[0]] = item[1] # Create a permissions store for item in DEFAULT_PERMISSIONS.items(): u.permissions[item[0]] = item[1] u.save() return u