From 42f0febd38f0427f33994b153c1a1d937afb609c Mon Sep 17 00:00:00 2001 From: Navan Chauhan Date: Thu, 3 Jun 2021 23:45:17 +0530 Subject: fixed sign up form --- app/templates/auth/signup.html | 38 ++++++++++++++++++++++++++++++++++++++ app/views/auth.py | 21 +++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 app/templates/auth/signup.html create mode 100644 app/views/auth.py diff --git a/app/templates/auth/signup.html b/app/templates/auth/signup.html new file mode 100644 index 0000000..e0cae82 --- /dev/null +++ b/app/templates/auth/signup.html @@ -0,0 +1,38 @@ +{% extends "base.html" %} + +{% block title %}Sign Up{% endblock %} + +{% block head %} + {{ super() }} +{% endblock %} + +{% block content %} +
+

Sign Up

+

Register your account.

+
+ {% include 'flash_messages.html' %} + {{ form.csrf_token }} + {% from "_formhelpers.html" import render_field %} +
+
+
+ {{ render_field(form.first_name) }} +
+
+ {{ render_field(form.last_name) }} +
+
+
+
+ {{ render_field(form.email) }} +
+
+ {{ render_field(form.password) }} +
+
+ +
+
+
+{% endblock %} \ No newline at end of file diff --git a/app/views/auth.py b/app/views/auth.py new file mode 100644 index 0000000..f31a4cd --- /dev/null +++ b/app/views/auth.py @@ -0,0 +1,21 @@ +from app import app, db, models +from app.forms.app_forms import UserSignUp +from flask import render_template, flash +from app.misc_func import flash_errors + + +@app.route("/signup", methods=['GET', 'POST']) +def register_user(): + form = UserSignUp() + if form.validate_on_submit(): + user = models.User( + first_name=form.first_name.data, + last_name=form.last_name.data, + email=form.email.data, + confirmation=False, + password=form.password.data, + ) + db.session.add(user) + db.session.commit() + flash_errors(form) + return render_template("auth/signup.html",form=form) \ No newline at end of file -- cgit v1.2.3