From 0015478320171fbefd6cdfaf043f076b64287f0c Mon Sep 17 00:00:00 2001 From: Krish M <krish94@uab.edu> Date: Mon, 11 Apr 2022 15:23:42 -0500 Subject: [PATCH] merge auto-conflict on app/__init__.py --- app/__init__.py | 9 +++++++-- app/static/scripts/function.js | 8 ++++++++ run.py | 11 +++++++++++ tasks.py | 18 +++++++++++++++++- 4 files changed, 43 insertions(+), 3 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index 7a3e061..dffb23c 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -58,8 +58,13 @@ def create_app(config_name): return render_template('errors/blocked.html') elif rc_util.check_state(session['user'].get('username')) == "certification": - return render_template('errors/certification.html') - + return render_template('errors/certify.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, + welcome_msg=messages.welcome_message, + cancel_msg=messages.cancel_message, + error_msg=messages.error_message) else: return render_template('auth/SignUp.html', room_id=session['uid'], username=session['user'].get('username'), diff --git a/app/static/scripts/function.js b/app/static/scripts/function.js index ae406d7..8848dae 100644 --- a/app/static/scripts/function.js +++ b/app/static/scripts/function.js @@ -16,6 +16,14 @@ function request_account() { }) } +function certify_account() { + socket.emit('request certification', { + fullname: document.getElementById("fullname").value, + email: document.getElementById("email").value, + username: document.getElementById("username").value + }) +} + function renderDom(title, message, error_msg) { document.getElementById("form-wrapper").innerHTML = "<h3>" + title + "</h3><br>"; document.getElementById("form-wrapper").innerHTML += "<p>" + message + "</p><br>"; diff --git a/run.py b/run.py index f69a208..d68af76 100644 --- a/run.py +++ b/run.py @@ -35,5 +35,16 @@ def request_account(json, methods=['GET', 'POST']): print(time.strftime("%m-%d-%Y_%H:%M:%S") + "\tError in account creation: ", e) socketio.emit("Account creation failed", room) +@socketio.on('request certification') +def certify_account(json, methods=['GET', 'POST']): + print (time.strftime("%m-%d-%Y_%H:%M:%S") + '\tQueue request received: ' + str(json)) + room = str(session['uid']) + print("CERTIFY Room: {}".format(room)) + try: + tasks.celery_certify_account(json, session=room ) + except Exception as e: + print(time.strftime("%m-%d-%Y_%H:%M:%S") + "\tError in account certification: ", e) + socketio.emit("Account certification failed", room) + if __name__ == '__main__': socketio.run(app, host='0.0.0.0') diff --git a/tasks.py b/tasks.py index acf3818..5721e47 100644 --- a/tasks.py +++ b/tasks.py @@ -59,4 +59,20 @@ def celery_create_account(json, session): rc_util.add_account(username, queuename, email, fullname, reason) print('sent account info') print('Waiting for completion...') - rc_util.consume(queuename, routing_key=f'complete.{queuename}', callback=gen_f(room)) + rc_util.consume(queuename, routing_key=f'complete.{queuename}', callback=gen_f(room)) + +@celery.task +def celery_certify_account(json, session): + room = session + username= json['username'] + email= json['email'] + fullname= json['fullname'] + queuename= rc_util.encode_name(username) + + print("CERTIFY : "+time.strftime("%m-%d-%Y_%H:%M:%S") + '\tUser ' + username + ' added to queue') + send_msg('certifying account', room) + print(username) + rc_util.update_state(username, 'ok') + print('sent account info') + print('Waiting for certification...') + send_msg('certified', room) -- GitLab