def users(): users = User.query.all() inviteForm = forms.InviteUserForm() if inviteForm.validate_on_submit(): invitation = UserInvitation.new_invite(inviteForm.email.data) msg = UserInvitation.deliver_invite(invitation) flash(msg, "success") db.session.commit() return redirect(url_for("admin.users")) return render_template( "admin/users.html", users=users, delForm=forms.UserDeleteForm(), editForm=forms.UserEditForm(), inviteForm=inviteForm, )
def users(): users = User.query.all() delForm = forms.UserDeleteForm() editForm = forms.UserEditForm() inviteForm = forms.InviteUserForm() if inviteForm.validate_on_submit(): validemail = User.validate_email(inviteForm.email.data) if not validemail: flash("%s does not appear to be a valid, deliverable email address." % inviteForm.email.data, "danger") return redirect(request.referrer) newUser = User(email=validemail) db.session.add(newUser) db.session.commit() send_user_invite_email(newUser) flash('Invitation Sent!', 'success') return redirect(url_for('admin.users')) return render_template("admin/users.html", users=users, delForm=delForm, editForm=editForm, inviteForm=inviteForm)