From de3fd8aed34a46fb3d6849e46cb13651b999bb82 Mon Sep 17 00:00:00 2001 From: Krish <krish94@uab.edu> Date: Thu, 6 May 2021 14:44:31 -0500 Subject: [PATCH] sending text message for welcome message, error message and cancel message as a variable from messages.py --- app/__init__.py | 16 +++++++--------- app/templates/auth/SignUp.html | 6 +++--- messages.py | 3 +++ 3 files changed, 13 insertions(+), 12 deletions(-) create mode 100644 messages.py diff --git a/app/__init__.py b/app/__init__.py index cf68fb1..c99094c 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -3,17 +3,17 @@ # local imports from __future__ import print_function import vars - +import messages # third-party imports import uuid -from flask import Flask, redirect, url_for, request, render_template, flash, session +from flask import Flask, redirect, url_for, request, render_template, flash, session, send_from_directory from flask_bootstrap import Bootstrap import random import os import json def create_app(config_name): - app = Flask(__name__) # initialization of the flask app + app = Flask(__name__, static_folder='static') # initialization of the flask app Bootstrap(app) # allowing app to use bootstrap def get_authorized_user(): @@ -49,12 +49,10 @@ def create_app(config_name): return render_template('auth/SignUp.html', room_id=session['uid'], username=session['user'].get('username'), fullname=session['user'].get('fullname'), email=session['user'].get('email'), - referrer=session['return_url'], cancel_url=vars.default_referrer) - - - @app.route('/error') - def error(): - return 'ERROR: ' + referrer=session['return_url'], cancel_url=vars.default_referrer, + welcome_msg=messages.welcome_message, + cancel_msg=messages.cancel_message, + error_msg=messages.error_message) @app.route('/error_account') def error_account_create(): diff --git a/app/templates/auth/SignUp.html b/app/templates/auth/SignUp.html index dc95ad6..7c450cb 100644 --- a/app/templates/auth/SignUp.html +++ b/app/templates/auth/SignUp.html @@ -28,7 +28,7 @@ socket.on( 'account error', function( msg ) { console.log(msg); $('#myModal2').modal('hide'); - renderDom("Account Create Error", "Error while creating your account. We've been notified about this", msg); + renderDom("Account Create Error", "{{ error_msg }}", msg); }); }); @@ -80,7 +80,7 @@ <div class="col-md-10 col-sm-10 my-col"> <div id="form-wrapper"> <h2> Self Registration Form </h2> - <p style="font-size:110%;"> Welcome to UAB's Reseach Computing cluster. The information below will be used to create your account. Please fill in all the details as this helps us understand our user base. Contact <a href="mailto:someone@yoursite.com">Research Computing</a> for any assistance in creating your account.</p> + <p style="font-size:110%;"> {{ welcome_msg |safe }}</p> <div id="user-input"> <form id="signup" data-toggle="validator" role="form" action="." method="post" onsubmit=""> <div class="col-md-7 col-sm-7 my-col"> @@ -98,7 +98,7 @@ </div> <br> <div class="col-md-7 col-sm-7 my-col"> - <button class="btn btn-danger btn-md" id="cancel" name="cancel" type="button" onClick="renderDom('Account Creation Cancelled','Close browser to end session', null)">Cancel</button> + <button class="btn btn-danger btn-md" id="cancel" name="cancel" type="button" onClick="renderDom('Account Creation Cancelled','{{ cancel_msg |safe }}', null)">Cancel</button> <button class="btn btn-primary btn-md" id="submit" name="submit" type="button" value="Submit" onclick="displayloading1();request_account()"> Create Account</button> </div> </form> diff --git a/messages.py b/messages.py new file mode 100644 index 0000000..8895350 --- /dev/null +++ b/messages.py @@ -0,0 +1,3 @@ +welcome_message = "Welcome to UAB's Reseach Computing cluster. The information below will be used to create your account. Please fill in all the details as this helps us understand our user base. Contact <a href='mailto:someone@yoursite.com'>Research Computing</a> for any assistance in creating your account." +cancel_message = "Close browser to end session. Contact <a href="'mailto:someone@yoursite.com'">Research Computing</a> for any assistance in creating your account." +error_message = "Error while creating your account. We've been notified about this. Contact <a href="'mailto:someone@yoursite.com'">Research Computing</a> for any assistance in creating your account." -- GitLab