def create_admin(email, password, first_name=None, last_name=None): usr = User(email, password) usr.first_name = first_name usr.last_name = last_name usr.access = ACCESS_ADMIN usr.is_active = True db.session.add(usr) db.session.commit()
def create_admin(email, p, fn, ln): usr = User(email, p) usr.first_name = fn usr.last_name = ln usr.access = ACCESS_ADMIN usr.is_active = True db.session.add(usr) db.session.commit() print(f"User added: {usr}")
def users(): form = AddUserForm() if request.method == POST: if form.validate_on_submit(): user = User() user.first_name = form.first_name.data user.last_name = form.last_name.data user.email = form.email.data user.activation_code = activation_code() user.access = ACCESS_USER db.session.add(user) db.session.commit() send_activation_email(user) flash(f"Added account for {user.full_name} ({user.email})") return redirect(url_for("main.users")) return render_template("main/users.html", form=form)