diff --git a/app/__init__.py b/app/__init__.py index 304b267d40081ad8874e3a1886bfe38f6dbf4d0a..e8e7526a326e732efa83b19dd6e22ebc597dce68 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -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) diff --git a/app/templates/auth/SignUp.html b/app/templates/auth/SignUp.html index d3ad6927084a0ba79c0ec3fe806b94e1ba7ca2dc..b1b55c588c7e4a68d75836cabde269d462d2ced8 100644 --- a/app/templates/auth/SignUp.html +++ b/app/templates/auth/SignUp.html @@ -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 %}