Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @app.route("/signup", methods=["GET", "POST"])
- @templated("signup.html")
- def signup_user():
- """
- Signup-page with validating on POST request and commiting new user if all data is valid.
- @return: If validated and signed up - redirecting to index-page, if trying to add existing user,
- refresh page with message, otherwise - rendiring page with form (like simply GET request).
- """
- form = RegForm()
- try:
- if form.validate_on_submit():
- user = User(grup="user", regd=datetime.now())
- form.populate_obj(user)
- db.session.add(user)
- db.session.commit()
- return redirect("/index")
- return dict(title="Tell us about you...", form=form)
- except IntegrityError:
- return dict(title="Tell us about you...", form=form, message="User with such email already exists")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement