diff --git a/services/web/project/__init__.py b/services/web/project/__init__.py index 80f98e4..e80c974 100644 --- a/services/web/project/__init__.py +++ b/services/web/project/__init__.py @@ -15,8 +15,6 @@ from project.models.members import Members from flask_cors import CORS from flasgger import Swagger, swag_from -#from models.models import User - from flask import ( Flask, jsonify, @@ -27,10 +25,7 @@ from flask_sqlalchemy import SQLAlchemy from sqlalchemy import create_engine # import socket - - #import SQLAlchemy - #from werkzeug.utils import secure_filename load_dotenv() @@ -41,10 +36,6 @@ app.config.from_object("project.config.Config") db = SQLAlchemy(app) #jwt_secret = os.getenv("JWT_SECRET") app.config['SECRET_KEY'] = os.getenv("JWT_SECRET") -#print( "aaaa-bbbb--ccccc" ) -#print( jwt_secret ) -# SOCKET_URL = os.getenv("SOCKET_URL") # The server's hostname or IP address -# print(SOCKET_URL) template = { "swagger": "2.0", @@ -64,10 +55,6 @@ app.config['SWAGGER'] = { Swagger(app, template=template) @swag_from('../../docs/consume.yml') -# client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) -# # client_socket.connect((os.getenv("SOCKET_URL"), 80)) -# # client_socket.send('hello from server') - def token_required(f): @wraps(f) def decorated(*args, **kwargs): @@ -364,18 +351,23 @@ def recent_bar(current_user): @app.route("/panel/account/actions") @token_required def recent_actions(current_user): + print( current_user["user"]["uid"]) + user_uid = current_user["user"]["uid"] + FIND_USER_DETAIL= "SELECT id,uid,username,updated,email,account_name, firstname, lastname FROM members WHERE uid::text = '"+user_uid+"'" + RECENT_ACTIONS = "SELECT * FROM members_actions WHERE member_id =1 ORDER by id DESC LIMIT 4" + with connection: + with connection.cursor(cursor_factory=psycopg2.extras.DictCursor) as cursor: + cursor.execute(RECENT_ACTIONS) + recent_actions = cursor.fetchall() + print(recent_actions) + action_data = { + "recent_actions" : recent_actions, "last_update": datetime.datetime.utcnow(), "initial": random.randint(0, 10), "processing": random.randint(0, 10), "verifying" : random.randint(0, 10), "completed" : random.randint(0, 10), - "top_bar": [ - {"id": "1", "description": "Contacts" , "last_update": "10-10-2010 11:00 AM", "value": '0' , "data_span":'Last 2 months'}, - {"id": "2", "description": "Site Traffic" , "last_update": "10-10-2010 11:30 AM", "value": '0', "data_span":'Past 12 hours'}, - {"id": "3", "description": "Appointments" , "last_update": "10-12-2010 11:30 AM", "value": '0', "data_span":'Last 14 days'}, - {"id": "4", "description": "Purchases" , "last_update": "10-12-2010 11:30 AM", "value": '0', "data_span":'Last 3 months'}, - ], "actions": [ {"no": "1", "description": "Welcome to MERMS" , "date": "10-10-2010 11:00 AM", "status": 'completed'}, {"no": "2", "description": "Personal Blog Setup" , "date": "10-10-2010 11:30 AM", "status": 'processing'}, @@ -384,6 +376,13 @@ def recent_actions(current_user): } return jsonify(action_data=action_data) +# "top_bar": [ +# {"id": "1", "description": "Contacts" , "last_update": "10-10-2010 11:00 AM", "value": '0' , "data_span":'Last 2 months'}, +# {"id": "2", "description": "Site Traffic" , "last_update": "10-10-2010 11:30 AM", "value": '0', "data_span":'Past 12 hours'}, +# {"id": "3", "description": "Appointments" , "last_update": "10-12-2010 11:30 AM", "value": '0', "data_span":'Last 14 days'}, +# {"id": "4", "description": "Purchases" , "last_update": "10-12-2010 11:30 AM", "value": '0', "data_span":'Last 3 months'}, +# ], +# @app.route("/panel/account/products/url") @token_required def product_urls(current_user): @@ -445,55 +444,3 @@ def myproduct(current_user): } return jsonify(myproduct_data=myproduct_data) - - - # PORT = 65432 # The port used by the serv - -# @app.route("/panel/socket/send") -# def socket_connect_send(): -# print(SOCKET_URL) -# client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) -# client_socket.connect(('10.0.0.32', 5005)) -# print( "HERE 002:") -# while 1: -# data = client_socket.recv(512) -# print( "HERE 003: " , data) -# if ( data == 'q' or data == 'Q'): -# print( "HERE 001:") -# client_socket.close() -# break; -# else: -# print( "RECIEVED:" , data) -# data = raw_input ( "SEND( TYPE q or Q to Quit):" ) -# if (data != 'Q' and data != 'q'): -# client_socket.send(data) -# else: -# client_socket.send(data) -# client_socket.close() -# break; -# -# # -# # with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: -# # s.connect(("10.0.0.32", 5005)) -# # while 1: -# # data = s.recv(512) -# # if ( data == 'q' or data == 'Q'): -# # s.close() -# # break; -# # else: -# # print "RECIEVED:" , data -# # data = raw_input ( "SEND( TYPE q or Q to Quit):" ) -# # if (data <> 'Q' and data <> 'q'): -# # s.send(data) -# # else: -# # s.send(data) -# # s.close() -# # break; -# # # s.emit('join', 'room1'); -# # s.join('room1') -# # s.sendall(b"Hello, world") -# # data = s.recv(1024) -# # print(f"ConRes {res!r}") -# # print(f"Received {data!r}") -# -# return jsonify(socket_end="socket_call") \ No newline at end of file