Sindbad~EG File Manager
from sqlalchemy import create_engine, MetaData, Table, insert, select,update,delete,text
from sqlalchemy.sql import and_, or_
from core import app
import json
# engine = create_engine(app.config['DATABASE_URI'])
engine = create_engine(app.config['DATABASE_URI'],pool_size=5000,pool_pre_ping=True,pool_recycle=3600)
engine_conf = create_engine(app.config['DATABASE_URI_CONF'],pool_size=5000,pool_pre_ping=True,pool_recycle=3600)
class ConfAppModel():
def __init__(self):
try:
self.meta = MetaData()
self.conference = Table("conference", self.meta, autoload_with=engine)
self.addons = Table("addons", self.meta, autoload_with=engine)
self.trigger_daily_reports_mails = Table("trigger_daily_reports_mails", self.meta, autoload_with=engine)
self.users = Table("users", self.meta, autoload_with=engine)
self.user_payment = Table("user_payment", self.meta, autoload_with=engine)
# self.delegates = Table("delegates", self.meta, autoload_with=engine)
self.conf_reminder = Table("conf_reminder", self.meta, autoload_with=engine_conf)
self.notification_email_mapping = Table("notification_email_mapping", self.meta, autoload_with=engine_conf)
except Exception as e:
print("table not found",e)
def get_conf(self,conf_id,conf_key):
with engine.connect() as conn:
stmt = text("select sa.*,ms.*,c.* from conference c inner join societies s on s.society_id = c.society_id inner join society_applications sa on sa.conf_id = c.conf_id and sa.app_type_id = 2 left join mail_setting ms on ms.mail_setting_id = sa.mail_setting_id where c.conf_id ='"+str(conf_id)+"' and c.conf_key="+conf_key+" and sa.app_type_id = 2 ;")
result = conn.execute(stmt).first()
conn.close()
results = [dict(r._mapping) for r in result] if result else None
if results :
return results
else:
return None
def get_setting_value_notuse(self,curr_date):
with engine.connect() as conn:
stmt = text("select c.conf_id,c.conf_key,c.conf_name ,c.conf_name_full_form,c.conf_title,DATE_FORMAT(c.conf_start_time , '%d-%m-%Y') AS conf_start_time,"
+ " DATE_FORMAT(c.conf_end_time , '%d-%m-%Y') as conf_end_time, DATE_FORMAT( c.reg_start_on , '%d-%m-%Y') as reg_start_on,DATE_FORMAT( c.reg_end_on , '%d-%m-%Y') as reg_end_on,"
+" c.header_logo , count(*) as reg_count,datediff( date(c.conf_start_time) , '"+curr_date+"' ) as day_different from delegates d "
+" inner join conference c on c.conf_id = d.conference_id and c.is_active = 1 "
+" inner join delegates_addons da on da.delegate_id = d.delegate_id inner join addons a on a.addon_id = da.addon_id "
+" inner join user_payment up on up.unique_id = da.unique_id "
+" where c.conf_start_time > '" +curr_date +"' and c.is_active = 1 and d.delegate_no is not null and d.delegate_no > 0 and da.reg_status = 2 and a.addon_type_id in (1) group by d.conference_id order by c.conf_start_time;")
# stmt=text("SELECT distinct * FROM conference AS c INNER JOIN society_applications AS sa ON sa.conf_id = c.conf_id and sa.app_type_id = 2 where c.is_active = 1 order by c.conf_id ;")
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
conn.close()
if results :
return results
else:
return None
# def get_setting_value(self,curr_date,old_date):
# with engine.connect() as conn:
# stmt = text("select c.conf_id,c.conf_key,c.conf_name ,c.conf_name_full_form,c.conf_title,DATE_FORMAT(c.conf_start_time , '%d-%m-%Y') AS conf_start_time,"
# + " DATE_FORMAT(c.conf_end_time , '%d-%m-%Y') as conf_end_time, DATE_FORMAT( c.reg_start_on , '%d-%m-%Y') as reg_start_on,DATE_FORMAT( c.reg_end_on , '%d-%m-%Y') as reg_end_on,"
# +" c.header_logo , count(*) as reg_count,"
# # +" datediff( date(c.conf_start_time) , '"+curr_date+"' ) as day_different "
# + " case when date(c.conf_start_time) < '"+curr_date+"' then 0 else datediff( date(c.conf_start_time) , '"+curr_date+"' ) end as day_different "
# +" from delegates d "
# +" inner join conference c on c.conf_id = d.conference_id "
# +" inner join delegates_addons da on da.delegate_id = d.delegate_id inner join addons a on a.addon_id = da.addon_id "
# +" inner join user_payment up on up.unique_id = da.unique_id "
# +" where c.conf_start_time > '" +old_date +"' and d.delegate_no is not null and d.delegate_no > 0 and da.reg_status = 2 and a.addon_type_id in (1) and c.conf_id not in (8) group by d.conference_id order by c.conf_start_time;")
# print(stmt)
# # stmt=text("SELECT distinct * FROM conference AS c INNER JOIN society_applications AS sa ON sa.conf_id = c.conf_id and sa.app_type_id = 2 where c.is_active = 1 order by c.conf_id ;")
# result = conn.execute(stmt).all()
# results = [dict(r._mapping) for r in result] if result else None
# if results :
# return results
# else:
# return None
def get_setting_value(self,curr_date,old_date):
with engine.connect() as conn:
stmt = text ("select c.conf_id,c.conf_key,c.conf_name_full_form , case when c.society_id =31 then group_concat('Abinava Events - ',c.conf_name) else c.conf_name end as conf_name,c.conf_title,DATE_FORMAT(c.conf_start_time , '%d-%m-%Y') AS conf_start_time,"
+ " DATE_FORMAT(c.conf_end_time , '%d-%m-%Y') as conf_end_time, DATE_FORMAT( c.reg_start_on , '%d-%m-%Y') as reg_start_on,DATE_FORMAT( c.reg_end_on , '%d-%m-%Y') as reg_end_on,"
+ " c.header_logo , case when d.delegate_id is null then 0 else count(*) end as reg_count,"
# datediff( date(c.conf_start_time) , '"+curr_date+"' ) as day_different,
+ " case when date(c.conf_start_time) < '"+curr_date+"' then 0 else datediff( date(c.conf_start_time) , '"+curr_date+"' ) end as day_different "
+" from conference c "
+" left join delegates d on c.conf_id = d.conference_id and d.del_status_id =2 "
+" left join delegates_addons da on da.delegate_id = d.delegate_id and da.reg_status=2 "
+" left join addons a on a.addon_id = da.addon_id and a.addon_type_id=1 "
+" left join user_payment up on up.unique_id = da.unique_id "
+" where c.conf_start_time >'" +old_date +"' group by c.conf_id order by c.conf_start_time;")
# stmt=text("SELECT distinct * FROM conference AS c INNER JOIN society_applications AS sa ON sa.conf_id = c.conf_id and sa.app_type_id = 2 where c.is_active = 1 order by c.conf_id ;")
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
conn.close()
if results :
return results
else:
return None
def get_society_data(self):
with engine.connect() as conn:
stmt=text("select * from societies; ")
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
conn.close()
if results :
return results
else:
return None
######### multiple result set
def get_addon_data(self,conf_id):
sets = []
try:
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_get_addons_data",[conf_id])
while 1:
#(column_name, type_, ignore_, ignore_, ignore_, null_ok, column_flags)
names = [c[0] for c in cursor.description]
set_ = []
while 1:
row_raw = cursor.fetchone()
if row_raw is None:
break
row = dict(zip(names, row_raw))
set_.append(row)
sets.append(list(set_))
if cursor.nextset() is None:
break
# nextset() doesn't seem to be sufficiant to tell the end.
if cursor.description is None:
break
finally:
# Return the connection to the pool (won't actually close).
connection.commit()
connection.close()
return sets
# SELECT * FROM trigger_daily_reports_mails where active_conf_list_mail = 1 ;
def activeConfMailIdList(self):
with engine.connect() as conn:
stmt =text("SELECT distinct email, full_name FROM trigger_daily_reports_mails where active_conf_list_mail = 1 ;")
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
conn.close()
if results :
return results
else:
return None
# end bo setting
#start portal access report
def get_conference(self):
with engine.connect() as conn:
stmt=text("select * from conference as c left join societies s on s.society_id = c.society_id where is_active=1;")
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
conn.close()
if results :
return results
else:
return None
def get_portal_access_data(self,start_date,end_date,conf_id):
sets = []
try:
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_conf_delegate_portal_access_report_with_count",[start_date,end_date,conf_id])
while 1:
#(column_name, type_, ignore_, ignore_, ignore_, null_ok, column_flags)
names = [c[0] for c in cursor.description]
set_ = []
while 1:
row_raw = cursor.fetchone()
if row_raw is None:
break
row = dict(zip(names, row_raw))
set_.append(row)
sets.append(list(set_))
if cursor.nextset() is None:
break
# nextset() doesn't seem to be sufficiant to tell the end.
if cursor.description is None:
break
finally:
# Return the connection to the pool (won't actually close).
connection.commit()
connection.close()
# print(sets)
return sets
#start portal access report
def get_delegate_dataConfApps(self,search_data,search_del_mem,conf_id):
sets = []
try:
connection = engine_conf.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_get_del_details",[search_data,search_del_mem,conf_id])
while 1:
#(column_name, type_, ignore_, ignore_, ignore_, null_ok, column_flags)
names = [c[0] for c in cursor.description]
set_ = []
while 1:
row_raw = cursor.fetchone()
if row_raw is None:
break
row = dict(zip(names, row_raw))
set_.append(row)
sets.append(list(set_))
if cursor.nextset() is None:
break
# nextset() doesn't seem to be sufficiant to tell the end.
if cursor.description is None:
break
finally:
# Return the connection to the pool (won't actually close).
connection.commit()
connection.close()
# print(sets)
return sets
# addon model start
def get_conf_conf_app(self,conf_id,conf_key):
with engine.connect() as conn:
stmt = text("select sa.*,ms.*,c.* from conference c inner join societies s on s.society_id = c.society_id inner join society_applications sa on sa.conf_id = c.conf_id and sa.app_type_id = 2 left join mail_setting ms on ms.mail_setting_id = sa.mail_setting_id where c.conf_id ="+str(conf_id)+" and c.conf_key='"+conf_key+"' and sa.app_type_id = 2 ;")
result = conn.execute(stmt).first()
conn.close()
if result :
return dict(result._mapping)
else:
return None
def get_confrence_data(self,conf_id,conf_key):
with engine.connect() as conn:
stmt=text("select * from conference where conf_id ="+str(conf_id)+" and conf_key ='"+conf_key+"' ;")
result = conn.execute(stmt).first()
conn.close()
if result :
return dict(result._mapping)
else:
return None
def bo_get_numerotec_team_members(self,conf_id):
with engine.connect() as conn:
stmt =text("select * from numerotec_team_members where is_delegate = 1 and find_in_set("+str(conf_id)+",conf_ids);")
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
conn.close()
if results :
return results
else:
return None
def update_conference_data(self,conf_id,data,curr_dt):
with engine.connect() as conn:
stmt = self.conference.update().where(self.conference.c.conf_id.in_([conf_id])).values(data)
# stmt = (update(self.conference).where(self.conference.c.conf_id == conf_id).values(data))
result = conn.execute(stmt)
conn.commit()
stmt_2 = text("SELECT * FROM conference where conf_id="+str(conf_id)+" and updated_at ='"+curr_dt+"';")
results = conn.execute(stmt_2).first()
conn.close()
if results :
return [dict(results._mapping)]
else:
return 'fail'
def update_addon_data(self,conf_id,addon_id,data_1,curr_dt):
with engine.connect() as conn:
stmt = self.addons.update().where(self.addons.c.addon_id.in_([addon_id]),self.addons.c.conference_id.in_([conf_id])).values(data_1)
result = conn.execute(stmt)
conn.commit()
stmt_1 =text("select * from addons where conference_id = '"+str(conf_id)+"' and updated_at = '"+curr_dt+"';")
results = conn.execute(stmt_1).first()
conn.close()
if results :
return [dict(results._mapping)]
else:
return 'fail'
def update_bulk_addon_data(self,conf_id,addon_id,data,updated_at):
with engine.connect() as conn:
stmt = 'UPDATE addons SET '
addon_id = addon_id
keyname = ["start_by","end_by","updated_at"]
for j in keyname:
stmt = stmt + j +" = case "
for i in data:
stmt = stmt + " When addon_id = '" + i["addon_id"] + "' then '" + i[j] +"'"
stmt = stmt + ' END, '
stmt = stmt[:-2]
stmt = stmt + ' Where conference_id = ' +str(conf_id)+' and addon_id in (\''+ "','".join(addon_id) +'\');'
result = conn.execute(stmt)
conn.commit()
stmt_1 =text("select * from addons where conference_id = '"+str(conf_id)+"' and updated_at = '"+updated_at+"' ;")
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
conn.close()
if results :
return results
else:
return 'fail'
def get_mail_template(self,template_name,conf_id):
with engine.connect() as conn:
stmt = text("select * from mail_templates where FIND_IN_SET ("+str(conf_id)+",conf_ids) and is_active=1 and template_name = '"+template_name+"' and app_type_id = 2;")
result = conn.execute(stmt).first()
conn.close()
if result :
return dict(result._mapping)
else:
return None
def search_trigger_mails_data(self,search,conf_id):
with engine.connect() as conn:
if conf_id and int(conf_id) > 0 :
where_con = " and (t.conf_id ="+ str(conf_id) + " )"
else :
where_con = " "
sql_stmt = "select t.*,c.conf_name from conference c inner join trigger_daily_reports_mails t on c.conf_id =t.conf_id WHERE c.is_active > 0 and t.is_del = 1 and ((t.full_name like '%"+search+"%') or (t.mobile like '%"+search+"%') or (t.email like '%"+search+"%')) "
stmt = text(sql_stmt + where_con)
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
conn.close()
if results :
return results
else:
return None
def search_user_mail_data(self,search,society_id):
with engine.connect() as conn:
if society_id and int(society_id) > 0 :
where_con = " and (u.society_id ="+ str(society_id) + " )"
else :
where_con = " "
sql_stmt = "select u.*,s.society_name from societies s inner join users u on s.society_id =u.society_id WHERE (1+1) and ((u.full_name like '%"+search+"%') or (u.mobile like '%"+search+"%') or(u.email like '%"+search+"%')) "
stmt = text(sql_stmt + where_con)
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
conn.close()
if results :
return results
else:
return None
# def get_soceity_with_scoiety_id(self,society_id):
# with engine.connect() as conn:
# conn = engine.connect()
# stmt = text("select * from societies;")
# result = conn.execute(stmt).all()
# results = [dict(r._mapping) for r in result] if result else None
# if results :
# return results
# else:
# return None
def getSocietydata(self):
with engine.connect() as conn:
conn = engine.connect()
stmt = text("select * from societies;")
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
conn.close()
if results :
return results
else:
return None
def get_users(self,user_id):
with engine.connect() as conn:
stmt = text("select * from users where user_id='"+str(user_id)+"';")
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
conn.close()
if results :
return results
else:
return None
def get_users_data(self,user_id):
with engine.connect() as conn:
stmt = text("select society_id,full_name,email,mobile,is_admin =1 from users where user_id ='"+str(user_id)+"' ;")
result = conn.execute(stmt).first()
conn.close()
if result :
return dict(result._mapping)
else:
return None
def get_conf_name(self,conf_id,conf_key):
with engine.connect() as conn:
stmt =text("select conf_name from conference where conf_id ="+str(conf_id)+" and conf_key = '"+conf_key+"';")
result = conn.execute(stmt).first()
conn.close()
if result :
return dict(result._mapping)
else:
return None
def insert_trigger_data(self,data):
with engine.connect() as conn:
result = conn.execute(self.trigger_daily_reports_mails.insert(),data)
conn.commit()
conn.close()
return result
def insert_user_data(self,data):
with engine.connect() as conn:
result = conn.execute(self.users.insert(),data)
conn.commit()
conn.close()
return result
def get_conference_data(self):
with engine.connect() as conn:
stmt = text("select * from conference where is_active=1;")
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
conn.close()
if results :
return results
else:
return None
def view_trigger_data(self,report_id):
with engine.connect() as conn:
stmt = text("select * from trigger_daily_reports_mails where report_id ='"+str(report_id)+"';")
result = conn.execute(stmt).first()
conn.close()
if result :
return dict(result._mapping)
else:
return None
def update_trigger_mail(self,report_id,data):
with engine.connect() as conn:
try:
stmt = self.trigger_daily_reports_mails.update().where(self.trigger_daily_reports_mails.c.report_id.in_([report_id])).values(data)
restult_1 = conn.execute(stmt)
conn.commit()
conn.close()
return "success"
except Exception as e:
conn.close()
return str(e)
# OTP Modal
def get_otp_pin_details(self,user_id,conf_id,email):
with engine_conf.connect() as conn:
stmt = text("select api_key,msg_id,email,status,reject_reason,queued_reason,created_at from mandrill_otp_mail_logs where user_id = "+str(user_id)+" and conf_id = "+str(conf_id)+" and email = '"+str(email)+"' order by created_at DESC Limit 1 ;")
result = conn.execute(stmt).first()
conn.close()
if result :
return dict(result._mapping)
else:
return None
# OTP Modal
# view tariff
def get_addon_name(self,conf_id):
with engine.connect() as conn:
stmt =text("select ifnull(addon_name,display_name) as addon_name from addons where is_visible = 1 and conference_id = "+str(conf_id)+" group by ifnull(addon_name,display_name) ;")
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
conn.close()
if results :
return results
else:
return None
def get_tariff_data(self,conf_id,addon_name):
with engine.connect() as conn:
if addon_name :
where_con = " and ifnull(a.addon_name,a.display_name) = '"+addon_name+"' order by a.start_by, a.addon_id ASC"
else :
where_con = " order by a.start_by, a.addon_id ASC"
sql_stmt = "select a.addon_id,a.addon_name,a.start_by as startby,a.end_by as endby,a.addon_reg_type,a.conference_id ,a.reg_type,a.amount,a.display_name,date_format(a.start_by , '%d-%m-%Y %H:%i:%s') as start_by ,date_format(a.end_by , '%d-%m-%Y %H:%i:%s') as end_by,ut.user_type,a.user_type_id from addons a left join user_types ut on ut.user_type_id = a.user_type_id where a.conference_id = "+str(conf_id)+" and a.is_visible =1 "
stmt =text(sql_stmt + where_con)
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
conn.close()
if results :
return results
else:
return None
# view tariff
def get_tariff_intimations(self,curr_date,next_date,conf_id):
connection = engine_conf.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_active_conf_list",[curr_date,next_date,conf_id])
if cursor.description :
columns = [column[0] for column in cursor.description]
results = []
for row in cursor.fetchall():
results.append(dict(zip(columns, row)))
cursor.close()
connection.commit()
connection.close()
if results :
return results
else :
return None
else :
cursor.close()
connection.commit()
connection.close()
return None
def get_is_admin(self,conf_id):
with engine.connect() as conn:
stmt = text("select c.conf_id,u.full_name,u.is_admin from users u inner join conference c on u.society_id = c.society_id where u.is_admin = 1 and c.conf_id = '"+str(conf_id)+"' and email like '%@numerotec.com%' ;")
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
conn.close()
if results :
return results
else:
return None
def get_incompleted_delegate_data_by_unique_id(self,conf_id,unique_id):
sets = []
try:
connection = engine_conf.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_get_incomplete_delegate_details_using_unique_id",[conf_id,unique_id])
while 1:
#(column_name, type_, ignore_, ignore_, ignore_, null_ok, column_flags)
names = [c[0] for c in cursor.description]
set_ = []
while 1:
row_raw = cursor.fetchone()
if row_raw is None:
break
row = dict(zip(names, row_raw))
set_.append(row)
sets.append(list(set_))
if cursor.nextset() is None:
break
# nextset() doesn't seem to be sufficiant to tell the end.
if cursor.description is None:
break
finally:
# Return the connection to the pool (won't actually close).
connection.commit()
connection.close()
return sets
def updatePayment(self,delegate_id,unique_id,data,data_1,dt_string):
self.delegates = Table("delegates",self.meta,schema=conf_schema, autoload_with= engine)
with engine.connect() as conn:
if unique_id and "null" not in unique_id :
stmt = self.user_payment.update().where(self.user_payment.c.unique_id.in_([unique_id])).values(data)
stmt_1 = self.delegates.update().where(self.delegates.c.delegate_id.in_([delegate_id])).values(data_1)
result = conn.execute(stmt)
result_1 = conn.execute(stmt_1)
conn.commit()
conn.close()
return "updated"
else :
return "Unique id missing"
# Get conf data for edit
def get_conf_data_for_edit(self,conf_id):
with engine.connect() as conn:
stmt =text("select * from conference where conf_id = "+str(conf_id)+" ;")
result = conn.execute(stmt).first()
conn.close()
if result :
return dict(result._mapping)
else:
return None
def update_conf(self,conf_id,data):
with engine.connect() as conn:
try:
stmt = self.conference.update().where(self.conference.c.conf_id.in_([conf_id])).values(data)
restult_1 = conn.execute(stmt)
conn.commit()
conn.close()
return "success"
except Exception as e:
conn.close()
return str(e)
def update_generate_conf_uuid(self,conf_id,updated_at):
with engine.connect() as conn:
try:
stmt = text("update conference set conf_uuid = (select uuid()), updated_at= '"+updated_at+"' where conf_id = "+str(conf_id)+" and conf_uuid is null;")
restult_1 = conn.execute(stmt)
conn.commit()
conn.close()
return "success"
except Exception as e:
conn.close()
return str(e)
#
def get_mail_data_by_delegateid(self,conf_id,delegate_id):
with engine_conf.connect() as conn:
stmt =text("select conf_id,delegate_id,api_key,email,msg_id,subject,date_format(created_at, '%d-%m-%Y %H:%i:%s') as created_at from mandrill_mail_logs where delegate_id = "+str(delegate_id)+" and conf_id = "+str(conf_id)+" ;")
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
conn.close()
if results :
return results
else:
return None
# ramya verify googlesheet count updated on 2023=07-06 11:40:00
def get_conf_id_conf_name(self):
with engine.connect() as conn:
conn = engine.connect()
stmt =text("select conf_id,conf_name from conference where is_active = 1;")
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
conn.close()
if results :
return results
else:
return None
def get_max_delegate_no(self,conf_id):
with engine.connect() as conn:
stmt =text("select max(d.delegate_no) as delegate_no ,max(up.receipt_no) as receipt_no from delegates d left join user_payment up on up.conf_id = d.conference_id where d.conference_id = "+str(conf_id)+" ;")
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
conn.close()
if results :
return results
else:
return None
# start delegate and detail
def get_edit_delegates(self,conf_id,delegate_id,conf_schema):
with engine.connect() as conn:
stmt=text("select * from "+str(conf_schema)+".delegates where conference_id = '"+str(conf_id)+"' and delegate_id = '"+str(delegate_id)+"' ;")
result = conn.execute(stmt).first()
conn.close()
if result :
return dict(result._mapping)
else:
return None
def conf_get_states(self):
with engine.connect() as conn:
stmt = text("SELECT * FROM states order by state_name asc;")
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
conn.close()
if results :
return results
else:
return None
def conf_get_country(self):
with engine.connect() as conn:
stmt = text("SELECT * FROM countries order by country_name asc;")
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
conn.close()
if results :
return results
else:
return None
def get_delegate(self,delegate_id,conf_schema):
with engine.connect() as conn:
stmt = text("select d.*,s.state_name from "+str(conf_schema)+".delegates d left join states s on d.state_id = s.state_id where delegate_id ='"+str(delegate_id)+"';")
result = conn.execute(stmt).first()
conn.close()
if result :
return dict(result._mapping)
else:
return None
def get_user_types(self,conf_id):
with engine.connect() as conn:
stmt = text("select a.conference_id,ut.user_type_id,ut.user_type from addons a inner join user_types ut on ut.user_type_id = a.user_type_id where a.conference_id = '"+conf_id+"' and a.addon_type_id = 1 group by a.user_type_id ;")
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
conn.close()
if results :
return results
else:
return None
def get_badge_model_conf(self,conf_id):
with engine.connect() as conn:
stmt = text("select * from badge_role where conf_id = '"+str(conf_id)+"' and is_visible > 0 ;")
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
conn.close()
if results :
return results
else:
return None
def get_edit_userpayment(self,conf_id,unique_id):
with engine.connect() as conn:
conn = engine.connect()
stmt=text("select * from user_payment where conf_id = "+str(conf_id)+" and unique_id = '"+str(unique_id)+"' ;")
result = conn.execute(stmt).first()
conn.close()
if result :
return dict(result._mapping)
else:
return None
def get_states_of_india(self,country_id):
with engine.connect() as conn:
stmt = text("select country_id,state_id,state_name from states where country_id = "+str(country_id)+" order by state_name asc;")
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
conn.close()
if results :
return results
else:
return None
def get_update_userpayment(self,conf_id,payment_id,data):
with engine.connect() as conn:
stmt = self.user_payment.update().where(self.user_payment.c.conf_id.in_([conf_id]),self.user_payment.c.payment_id.in_([payment_id])).values(data)
results = conn.execute(stmt)
conn.commit()
conn.close()
return "success" if results else "fail"
def update_delegate_detail(self,conference_id,delegate_id,data,conf_schema):
self.delegates = Table("delegates",self.meta,schema=conf_schema, autoload_with= engine)
with engine.connect() as conn:
stmt = self.delegates.update().where(self.delegates.c.conference_id.in_([conference_id]),self.delegates.c.delegate_id.in_([delegate_id])).values(data)
result = conn.execute(stmt)
conn.commit()
conn.close()
return "success" if result else "fail"
# start delegate and detail
# Created By Ramya on 2023-09-19
# Purpose : To update same details in society_application from conference index
def update_society_application(self,conf_id,conf_key,payment_api_url,call_payment_url,stylesheet,pg_appmaster_id,pg_is_test,app_url,is_gen_number,google_sheet_link,b_ref_prefix):
connection = engine_conf.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_update_conference_and_society_application",[(conf_id or None),(conf_key or None),(payment_api_url or None),(call_payment_url or None),(stylesheet or None),(pg_appmaster_id or None),(pg_is_test or None),(app_url or None),(is_gen_number or None),(google_sheet_link or None),(b_ref_prefix or None)])
if cursor.description :
columns = [column[0] for column in cursor.description]
results = []
for row in cursor.fetchall():
results.append(dict(zip(columns, row)))
cursor.close()
connection.commit()
connection.close()
if results :
return results[0]
else :
return None
else :
cursor.close()
connection.commit()
connection.close()
return None
def get_society_app_data_for_edit(self,conf_id):
with engine.connect() as conn:
stmt =text("select sa.* from conference c inner join society_applications sa "
+" on sa.conf_id = c.conf_id and sa.app_type_id= 2 where c.conf_id = "+str(conf_id)+" ;")
result = conn.execute(stmt).first()
conn.close()
if result :
return dict(result._mapping)
else:
return None
# start notification reminder
def insert_conf_reminder_data(self,data):
with engine_conf.connect() as conn:
result = conn.execute(self.conf_reminder.insert(),data)
conn.commit()
conn.close()
return result
def get_rem_notification_data(self,conf_id):
with engine_conf.connect() as conn:
stmt = text("select c.*,n.map_id,n.emails from conf_reminder c left join notification_email_mapping n ON c.reminder_id=n.reminder_id where c.conf_id= '"+str(conf_id)+"';")
result = conn.execute(stmt).all()
conn.close()
return [dict(r._mapping) for r in result] if result else None
def get_all_mail_data(self):
with engine.connect() as conn:
stmt = text("select report_id,email from trigger_daily_reports_mails where email like '%numerotec.com%' and is_del >0 group by email;")
result = conn.execute(stmt).all()
conn.close()
return [dict(r._mapping) for r in result] if result else None
def get_mail_data(self,reminder_id):
with engine_conf.connect() as conn:
stmt=text("select * from notification_email_mapping where reminder_id="+str(reminder_id)+" ;")
result = conn.execute(stmt).all()
conn.close()
return [dict(r._mapping) for r in result] if result else None
def get_selected_mail_data(self,conf_id):
with engine_conf.connect() as conn:
stmt=text("select * from notification_email_mapping where conf_id ="+str(conf_id)+";")
result = conn.execute(stmt).all()
conn.close()
return [dict(r._mapping) for r in result] if result else None
def insert_or_update_emails_data(self,data ,map_id):
with engine_conf.connect() as conn:
if map_id and int(map_id) > 0 :
stmt = self.notification_email_mapping.update().where(self.notification_email_mapping.c.map_id.in_([map_id])).values(data)
conn.execute(stmt)
else :
result = conn.execute(self.notification_email_mapping.insert(),data)
conn.commit()
conn.close()
return "success"
def reminder_notificatin_edit(self,reminder_id):
with engine_conf.connect() as conn:
stmt = text("select * from conf_reminder where reminder_id = '"+str(reminder_id)+"' ;")
result = conn.execute(stmt).first()
conn.close()
return dict(result._mapping) if result else 0
def delete_reminder_notification(self,reminder_id,conf_id):
with engine_conf.connect() as conn:
safe_stmt = text("SET SQL_SAFE_UPDATES = 0 ;")
conn.execute(safe_stmt)
stmt_1 = text("delete from notification_email_mapping where reminder_id = "+reminder_id+" ;")
conn.execute(stmt_1)
conn.commit()
stmt = self.conf_reminder.delete().where(self.conf_reminder.c.reminder_id.in_([reminder_id]))
result_delete= conn.execute(stmt)
conn.commit()
get_stmt = text("select c.*,n.map_id,n.emails from conf_reminder c left join notification_email_mapping n ON c.reminder_id=n.reminder_id where c.conf_id= '"+str(conf_id)+"';")
result_2 = conn.execute(get_stmt).all()
conn.close()
return [dict(r._mapping) for r in result_2] if result_2 else None
def update_reminder_notification_data(self,data,reminder_id,conf_id):
with engine_conf.connect() as conn:
stmt = self.conf_reminder.update().where(self.conf_reminder.c.reminder_id.in_([reminder_id])).values(data)
restult_1 = conn.execute(stmt)
conn.commit()
stmt_2 = text("select c.*,n.map_id,n.emails from conf_reminder c left join notification_email_mapping n ON c.reminder_id=n.reminder_id where c.conf_id= '"+str(conf_id)+"';")
result_2 = conn.execute(stmt_2).all()
conn.close()
return [dict(r._mapping) for r in result_2] if result_2 else ''
def get_rem_notification_mail_data(self,conf_id,dt_string):
with engine_conf.connect() as conn:
stmt = text("select * from conf_reminder where conf_id = "+str(conf_id)+" and reminder_date = date('"+str(dt_string)+"');")
result = conn.execute(stmt).all()
conn.close()
return [dict(r._mapping) for r in result] if result else None
def get_notification_email_mapping(self,conf_id):
with engine_conf.connect() as conn:
stmt = text("select * from notification_email_mapping where conf_id = "+str(conf_id)+";")
result = conn.execute(stmt).all()
conn.close()
return [dict(r._mapping) for r in result] if result else None
def get_conf_details_by_conf_id(self,conf_id):
with engine.connect() as conn:
stmt = text("select sa.*,ms.*,c.* from conference c inner join societies s on s.society_id = c.society_id inner join society_applications sa on sa.conf_id = c.conf_id and sa.app_type_id = 2 left join mail_setting ms on ms.mail_setting_id = sa.mail_setting_id where c.conf_id = 5 and sa.app_type_id = 2 ;")
result = conn.execute(stmt).first()
conn.close()
return dict(result._mapping) if result else None
#notification reminder end
# Surgical Strike
def get_surgical_strike_data(self,curr_date,old_date):
with engine.connect() as conn:
stmt = text("select c.conf_id,c.conf_key,c.conf_name ,c.conf_name_full_form,c.conf_title,DATE_FORMAT(c.conf_start_time , '%d-%m-%Y') AS conf_start_time,"
+ " DATE_FORMAT(c.conf_end_time , '%d-%m-%Y') as conf_end_time, DATE_FORMAT( c.reg_start_on , '%d-%m-%Y') as reg_start_on,DATE_FORMAT( c.reg_end_on , '%d-%m-%Y') as reg_end_on,"
+" c.header_logo , count(*) as reg_count,"
+ " case when date(c.conf_start_time) < '"+curr_date+"' then 0 else datediff( date(c.conf_start_time) , '"+curr_date+"' ) end as day_different "
+" from delegates d "
+" inner join conference c on c.conf_id = d.conference_id "
+" where c.conf_start_time > '" +old_date +"' and d.delegate_no is not null and d.delegate_no > 0 and c.conf_id = 46 ;")
result = conn.execute(stmt).first()
conn.close()
return dict(result._mapping) if result else None
# Surgical Strike
def get_conf_index(self):
with engine.connect() as conn:
stmt=text("select case when (date(c.conf_end_time) < '2024-01-03') then 0 else 1 end as is_conf_completed,c.* from conference as c left join societies s on s.society_id = c.society_id where is_active=1 order by c.conf_end_time DESC;")
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
conn.close()
if results :
return results
else:
return None
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists