Skip to content
Snippets Groups Projects
Commit 57ce1d41 authored by Mitchell Moore's avatar Mitchell Moore
Browse files

Merge branch 'fix-form-functionality' into 'master'

Fix form functionality

See merge request !20
parents 146d845b 051428a8
No related branches found
No related tags found
1 merge request!20Fix form functionality
......@@ -10,7 +10,9 @@ import time
# third-party imports
from flask import Flask, redirect, url_for, request, render_template, flash
from flask_wtf import FlaskForm
from flask_bootstrap import Bootstrap
from wtforms import StringField, SubmitField, validators
def create_app(config_name):
......@@ -21,30 +23,27 @@ def create_app(config_name):
global return_url
return_url = ''
class MainForm(FlaskForm):
fullname = StringField('Full Name: ', [validators.DataRequired(), ])
submit = SubmitField('Submit')
@app.route('/', methods=['GET', 'POST'])
def index():
global return_url
user = request.remote_user
if request.method == 'GET':
global return_url
if "redir" in request.args:
return_url = request.args.get("redir") or "/pun/sys/dashboard"
return render_template("auth/SignUp.html", user=user)
if request.method == 'POST':
name = request.form['name']
if "redir" in request.args:
return_url = request.args.get("redir") or "/pun/sys/dashboard"
if name != "":
username = False
form = MainForm()
if form.is_submitted():
username = form.fullname.data
form.fullname.data = ''
return redirect(url_for('success', username=str(user), fullname=name))
return redirect(url_for('success', username=str(user), fullname=username))
else:
return render_template("auth/SignUp.html", user=user)
return render_template('auth/SignUp.html', form=form, user=user)
@app.route('/success/<username>/<fullname>')
def success(username, fullname):
......@@ -62,8 +61,8 @@ def create_app(config_name):
return redirect(return_url, 302)
except:
flash("Registration Failed")
return redirect(return_url)
flash("Registration Failed. Please try again.")
return redirect(url_for('index'))
@app.errorhandler(403)
......
{% extends "auth/base.html" %}
<html class="gr__rc_uab_edu">
{% block title %} User Register {% endblock %}
{% block title %} User Registration {% endblock %}
{% block head %}
{{ super() }}
<style type="text/css">
......@@ -46,20 +46,22 @@
</div>
</nav>
</header>
<div class="container content" role="main" style="
width: 800;
">
<div class="container content" role="main" style="width: 625px">
<div class="col-md-12">
<div style="position:relative;">
<img alt="logo" height="100" style="margin-bottom: 20px" src="/register/static/img/cheaha-logo-a605de0aecd3006b82a5ee30a6d0cb8cd9bf8b7e836296cc293eac746a4c2b11.png">
<a href="https://tinyurl.com/cheahaAL" target="_blank">
<div style="float:left;position:absolute;display:block;left:310px;top:-6px;padding:10px 20px;"> </div>
</a>
</div>
<img class="header-logo" height="100" style="margin-bottom: 20px" src="/register/static/img/cheaha-logo-a605de0aecd3006b82a5ee30a6d0cb8cd9bf8b7e836296cc293eac746a4c2b11.png">
<h2>Hello, {{ user }}!</h2>
<form action="." method="post">
<div class="signUpContainer">
<label for="name"><b>Full Name:<br></b></label>
<input class="form-control" type="text" placeholder="Enter Full Name" name="name" required>
<input class="btn btn-primary btn-block" type="submit" value="submit">
<label><b>{{ form.fullname.label }}<br></b></label>
{{ form.fullname(class_="form-control", placeholder="Enter Full Name") }}
{{ form.submit(class_="btn btn-primary btn-block") }}
{% with messages = get_flashed_messages() %}
{% if messages %}
......@@ -74,7 +76,6 @@
</div>
</form>
</div>
</div>
{% endblock %}
</body>
{% block footer %}
......
......@@ -3,7 +3,7 @@
<head>
{% block head %}
<link rel="stylesheet" href="/register/static/style/application.css">
<title>{% block title %}{% endblock %} - My Webpage</title>
<title>{% block title %}{% endblock %}</title>
{% endblock %}
</head>
<body>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment