emasil capability added
This commit is contained in:
@@ -14,7 +14,7 @@ import project.validate.validate as validate
|
|||||||
from project.models.members import Members
|
from project.models.members import Members
|
||||||
from flask_cors import CORS
|
from flask_cors import CORS
|
||||||
from flasgger import Swagger, swag_from
|
from flasgger import Swagger, swag_from
|
||||||
|
from flask_mail import Mail, Message
|
||||||
from flask import (
|
from flask import (
|
||||||
Flask,
|
Flask,
|
||||||
jsonify,
|
jsonify,
|
||||||
@@ -37,6 +37,20 @@ db = SQLAlchemy(app)
|
|||||||
#jwt_secret = os.getenv("JWT_SECRET")
|
#jwt_secret = os.getenv("JWT_SECRET")
|
||||||
app.config['SECRET_KEY'] = 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 = {
|
template = {
|
||||||
"swagger": "2.0",
|
"swagger": "2.0",
|
||||||
"info": {
|
"info": {
|
||||||
@@ -89,43 +103,35 @@ engine = create_engine(dataUrl)
|
|||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def hello_world():
|
def hello_world():
|
||||||
action_data = {
|
msg = Message(
|
||||||
"last_update": datetime.datetime.utcnow(),
|
'Hello',
|
||||||
"initial": random.randint(0, 10),
|
sender ='message@chiefsoft.com',
|
||||||
"processing": random.randint(0, 10),
|
recipients = ['ses66181@gmail.com']
|
||||||
"verifying" : random.randint(0, 10),
|
)
|
||||||
"completed" : random.randint(0, 10),
|
msg.body = 'Hello Flask message sent from Flask-Mail'
|
||||||
"top_bar": [
|
mail.send(msg)
|
||||||
{"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'},
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
GLOBAL_AVG = """SELECT * FROM members WHERE id > 0;"""
|
return jsonify(action_data="sent")
|
||||||
|
|
||||||
result = pd.read_sql(GLOBAL_AVG, engine)
|
# GLOBAL_AVG = """SELECT * FROM members WHERE id > 0;"""
|
||||||
print(result)
|
#
|
||||||
|
# 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:
|
# for row in account.rows:
|
||||||
# print(row['id'], row['uid'])
|
# print(row['id'], row['uid'])
|
||||||
# print(account)
|
# print(account)
|
||||||
@@ -135,15 +141,15 @@ def hello_world():
|
|||||||
# json_data = json.dumps(account)
|
# json_data = json.dumps(account)
|
||||||
# print(json_data)
|
# print(json_data)
|
||||||
# connection.close()
|
# 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;"""
|
# GLOBAL_AVG = """SELECT * FROM members WHERE id = 1;"""
|
||||||
with connection:
|
# with connection:
|
||||||
with connection.cursor() as cursor:
|
# with connection.cursor() as cursor:
|
||||||
cursor.execute(GLOBAL_AVG)
|
# cursor.execute(GLOBAL_AVG)
|
||||||
account = cursor.fetchone()
|
# account = cursor.fetchone()
|
||||||
return jsonify(hello="ameye world")
|
# return jsonify(hello="ameye world")
|
||||||
# return {"account": account}
|
# # return {"account": account}
|
||||||
|
|
||||||
|
|
||||||
@app.route("/panel/auth/login", methods=["POST"])
|
@app.route("/panel/auth/login", methods=["POST"])
|
||||||
@@ -234,7 +240,9 @@ def start_register():
|
|||||||
cursor.execute(INSERT_MEMBERS)
|
cursor.execute(INSERT_MEMBERS)
|
||||||
|
|
||||||
last_row_id=cursor.lastrowid
|
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)
|
return jsonify(hello="ameye signup path world", last_row_id=last_row_id)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -244,6 +252,14 @@ def start_register():
|
|||||||
"data": None
|
"data": None
|
||||||
}, 500
|
}, 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"])
|
@app.route("/panel/auth/reset", methods=["POST"])
|
||||||
def start_resetpass():
|
def start_resetpass():
|
||||||
@@ -352,9 +368,9 @@ def recent_bar(current_user):
|
|||||||
@token_required
|
@token_required
|
||||||
def recent_actions(current_user):
|
def recent_actions(current_user):
|
||||||
print( current_user["user"]["uid"])
|
print( current_user["user"]["uid"])
|
||||||
user_uid = current_user["user"]["uid"]
|
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+"'"
|
# 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"
|
RECENT_ACTIONS = "SELECT * FROM members_actions WHERE member_id = "+user_id+" ORDER by id DESC LIMIT 4"
|
||||||
with connection:
|
with connection:
|
||||||
with connection.cursor(cursor_factory=psycopg2.extras.DictCursor) as cursor:
|
with connection.cursor(cursor_factory=psycopg2.extras.DictCursor) as cursor:
|
||||||
cursor.execute(RECENT_ACTIONS)
|
cursor.execute(RECENT_ACTIONS)
|
||||||
@@ -376,13 +392,6 @@ def recent_actions(current_user):
|
|||||||
}
|
}
|
||||||
return jsonify(action_data=action_data)
|
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")
|
@app.route("/panel/account/products/url")
|
||||||
@token_required
|
@token_required
|
||||||
def product_urls(current_user):
|
def product_urls(current_user):
|
||||||
|
|||||||
@@ -10,4 +10,5 @@ flask-cors
|
|||||||
pandas
|
pandas
|
||||||
flasgger
|
flasgger
|
||||||
sqlalchemy
|
sqlalchemy
|
||||||
flask-socketio
|
flask-socketio
|
||||||
|
Flask-Mail
|
||||||
|
|||||||
Reference in New Issue
Block a user