Commit c9fec8d8 authored by Mitchell Moore's avatar Mitchell Moore
Browse files

Added timestamp to file output & basic code cleanup

- Remove temp functionality/replace loading visibility logic
- Remove 5 second pause
- Added fileput with timestamp
parent 16a7dcc0
......@@ -4,10 +4,12 @@
from __future__ import print_function
import os
import os.path
import sys
import subprocess
import time
import datetime
import subprocess
# third-party imports
from flask import Flask, redirect, url_for, request, render_template, flash
from flask_wtf import FlaskForm
......@@ -22,8 +24,6 @@ def create_app(config_name):
global return_url
return_url = ''
global loading
loading = False
class MainForm(FlaskForm):
fullname = StringField('Full Name: ', [validators.DataRequired(), ])
......@@ -32,10 +32,9 @@ def create_app(config_name):
@app.route('/', methods=['GET', 'POST'])
def index():
global return_url
global loading
user = request.remote_user
if "redir" in request.args:
if "redir" in request.args and return_url == "":
return_url = request.args.get("redir") or "/pun/sys/dashboard"
username = False
......@@ -46,7 +45,7 @@ def create_app(config_name):
return redirect(url_for('success', username=str(user), fullname=username))
return render_template('auth/SignUp.html', form=form, user=user, loading=loading)
return render_template('auth/SignUp.html', form=form, user=user)
@app.route('/success/<username>/<fullname>')
def success(username, fullname):
......@@ -59,14 +58,16 @@ def create_app(config_name):
print(tempString, file=sys.stdout)
try:
subprocess.check_output([tempString], shell=True)
time_stamp = time.strftime("%Y%m%d-%H%M%S")
blazer_path = "/var/www/ood/register/flask_user_reg"
complete_file_name = os.path.join(blazer_path, time_stamp+".txt")
file = open(complete_file_name, "w")
file.write(fullname)
file.close()
return redirect(return_url, 302)
except:
flash("Registration Failed. Please try again.")
global loading
loading = True
return redirect(url_for('index'))
@app.errorhandler(403)
......
......@@ -59,7 +59,29 @@
<h2>Hello, {{ user }}!</h2>
<form action="." method="post">
<script>
function displayloading() {
document.getElementById("notification_window").innerHTML = "" +
"<div class=\"joyride-tip-guide\" data-index=\"0\" style=\"visibility: visible; display: block; top: 77.5px; left: 570px;\"><span class=\"joyride-nub\" style=\"display: none;\"></span><div class=\"joyride-content-wrapper\" role=\"dialog\"><ol>\n" +
" <h4>\n" +
"\n" +
" Your account is pending creation...\n" +
"\n" +
" </h4>\n" +
" <br><p>\n" +
" This can take between 5-10 min.\n" +
" </p>\n" +
" </ol>\n" +
" <img src=\"/register/static/img/loading.gif\" style=\"width: 35px; height: auto\"> Pending...\n" +
" </div></div>\n" +
"\n" +
" <div class=\"joyride-modal-bg\" style=\"display: block;\"></div>"
}
</script>
<form action="." method="post" onsubmit="displayloading()">
<div class="signUpContainer">
<label><b>{{ form.fullname.label }}<br></b></label>
{{ form.fullname(class_="form-control", placeholder="Enter Full Name") }}
......@@ -78,22 +100,9 @@
</div>
</form>
</div>
{% if loading %}
<div class="joyride-tip-guide" data-index="0" style="visibility: visible; display: block; top: 77.5px; left: 570px;"><span class="joyride-nub" style="display: none;"></span><div class="joyride-content-wrapper" role="dialog"><ol>
<h4>
Your account is pending creation...
</h4>
<br><p>
This can take between 5-10 min.
</p>
</ol>
<img src="/register/static/img/loading.gif" style="width: 35px; height: auto"> Pending...
</div></div>
<div class="joyride-modal-bg" style="display: block;"></div>
{% endif %}
<div id="notification_window" >
</div>
{% endblock %}
</body>
{% block footer %}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment