emasil capability added

This commit is contained in:
CHIEFSOFT\ameye
2024-12-22 06:43:00 -05:00
parent f0765d2629
commit afc352274b
2 changed files with 64 additions and 54 deletions
+62 -53
View File
@@ -14,7 +14,7 @@ import project.validate.validate as validate
from project.models.members import Members
from flask_cors import CORS
from flasgger import Swagger, swag_from
from flask_mail import Mail, Message
from flask import (
Flask,
jsonify,
@@ -37,6 +37,20 @@ db = SQLAlchemy(app)
#jwt_secret = os.getenv("JWT_SECRET")
app.config['SECRET_KEY'] = os.getenv("JWT_SECRET")
mail = Mail(app) # instantiate the mail class
# configuration of mail
app.config['MAIL_SERVER']='smtp.gmail.com'
app.config['MAIL_PORT'] = 465
#app.config['MAIL_PORT'] = 587
app.config['MAIL_USERNAME'] = 'message@chiefsoft.com'
app.config['MAIL_PASSWORD'] = 'may12002!'
app.config['MAIL_USE_TLS'] = False
app.config['MAIL_USE_SSL'] = True
mail = Mail(app)
template = {
"swagger": "2.0",
"info": {
@@ -89,43 +103,35 @@ engine = create_engine(dataUrl)
@app.route("/")
def hello_world():
action_data = {
"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'},
{"no": "3", "description": "Web Traffic Analysis" , "date": "10-12-2010 11:30 AM", "status": 'verifying'},
]
}
msg = Message(
'Hello',
sender ='message@chiefsoft.com',
recipients = ['ses66181@gmail.com']
)
msg.body = 'Hello Flask message sent from Flask-Mail'
mail.send(msg)
GLOBAL_AVG = """SELECT * FROM members WHERE id > 0;"""
return jsonify(action_data="sent")
result = pd.read_sql(GLOBAL_AVG, engine)
print(result)
# GLOBAL_AVG = """SELECT * FROM members WHERE id > 0;"""
#
# result = pd.read_sql(GLOBAL_AVG, engine)
# print(result)
#
# cols = result.columns.difference(['Col1'])
# d = (result.groupby('Col1')[cols]
# .apply(lambda x: x.to_dict('r'))
# .reset_index(name='Other_details')
# .to_json(orient='records'))
#
# #json_data = [json.loads(row[0]) for row in result]
#
# with connection:
# with connection.cursor(cursor_factory=psycopg2.extras.DictCursor) as cursor:
# cursor.execute(GLOBAL_AVG)
# account = cursor.fetchall()
# print(account[0]["uid"])
cols = result.columns.difference(['Col1'])
d = (result.groupby('Col1')[cols]
.apply(lambda x: x.to_dict('r'))
.reset_index(name='Other_details')
.to_json(orient='records'))
#json_data = [json.loads(row[0]) for row in result]
with connection:
with connection.cursor(cursor_factory=psycopg2.extras.DictCursor) as cursor:
cursor.execute(GLOBAL_AVG)
account = cursor.fetchall()
print(account[0]["uid"])
# for row in account.rows:
# print(row['id'], row['uid'])
# print(account)
@@ -135,15 +141,15 @@ def hello_world():
# json_data = json.dumps(account)
# print(json_data)
# connection.close()
return jsonify(result=account, action_data=action_data, account=account)
# return jsonify(result=account, action_data=action_data, account=account)
GLOBAL_AVG = """SELECT * FROM members WHERE id = 1;"""
with connection:
with connection.cursor() as cursor:
cursor.execute(GLOBAL_AVG)
account = cursor.fetchone()
return jsonify(hello="ameye world")
# return {"account": account}
# GLOBAL_AVG = """SELECT * FROM members WHERE id = 1;"""
# with connection:
# with connection.cursor() as cursor:
# cursor.execute(GLOBAL_AVG)
# account = cursor.fetchone()
# return jsonify(hello="ameye world")
# # return {"account": account}
@app.route("/panel/auth/login", methods=["POST"])
@@ -234,7 +240,9 @@ def start_register():
cursor.execute(INSERT_MEMBERS)
last_row_id=cursor.lastrowid
print(last_row_id)
send_register_mail()
return jsonify(hello="ameye signup path world", last_row_id=last_row_id)
except Exception as e:
@@ -244,6 +252,14 @@ def start_register():
"data": None
}, 500
def send_register_mail():
msg = Message(
'verify your MERMS Account',
sender ='message@chiefsoft.com',
recipients = ['ses66181@gmail.com']
)
msg.body = 'Hello MERMS message sent for account verification http://localhost:8090/completesignup/JWT-djhgdhjgdhdggggd'
mail.send(msg)
@app.route("/panel/auth/reset", methods=["POST"])
def start_resetpass():
@@ -352,9 +368,9 @@ def recent_bar(current_user):
@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"
user_id = current_user["user"]["id"]
# 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 = "+user_id+" ORDER by id DESC LIMIT 4"
with connection:
with connection.cursor(cursor_factory=psycopg2.extras.DictCursor) as cursor:
cursor.execute(RECENT_ACTIONS)
@@ -376,13 +392,6 @@ 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):
+2 -1
View File
@@ -10,4 +10,5 @@ flask-cors
pandas
flasgger
sqlalchemy
flask-socketio
flask-socketio
Flask-Mail