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
from flask import session
import json
from sqlalchemy import text
from .. import engine,engine_conf_db
import sqlite3
engine_sqlite = create_engine('sqlite:///primary_db_del.db')
# engine = create_engine(app.config['DATABASE_URI'],pool_size=5000,pool_pre_ping=True,pool_recycle=3600, future = True)
# engine = create_engine(app.config['DATABASE_URI'],pool_size=5000,pool_pre_ping=True,pool_recycle=3600, future = True)
# engine_conf_db = create_engine(app.config['DATABASE_URI_CONF'],pool_pre_ping=True,pool_recycle=3600, future = True)
class UserModel():
def __init__(self):
try:
self.meta = MetaData()
self.users = Table("users", self.meta, autoload_with=engine)
self.states = Table("states", self.meta, autoload_with=engine)
self.conference = Table("conference", self.meta, autoload_with=engine)
self.user_payment = Table("user_payment", self.meta, autoload_with=engine)
self.user_types = Table("user_types", self.meta, autoload_with=engine)
self.logs = Table("logs", self.meta, autoload_with=engine)
self.delegates = Table("delegates", self.meta, autoload_with=engine)
self.delegates_addons = Table("delegates_addons", self.meta, autoload_with=engine)
self.m_payment_type = Table("m_payment_type", self.meta, autoload_with=engine)
self.delegate_attachments = Table("delegate_attachments", self.meta, autoload_with=engine)
self.society_applications = Table("society_applications", self.meta, autoload_with=engine)
self.delegate_user_logs = Table("delegate_user_logs", self.meta, autoload_with=engine)
self.payment_logs = Table("payment_logs", self.meta, autoload_with=engine)
self.users_logs = Table("users_logs", self.meta, autoload_with=engine_conf_db)
self.mandrill_mail_logs = Table("mandrill_mail_logs", self.meta, autoload_with=engine_conf_db)
self.mandrill_otp_mail_logs = Table("mandrill_otp_mail_logs", self.meta, autoload_with=engine_conf_db)
self.user_roles = Table("user_roles", self.meta, autoload_with=engine)
self.roles = Table("roles", self.meta, autoload_with=engine)
self.app_style = Table("app_style", self.meta, autoload_with=engine)
except Exception as e:
print("table not found",e)
def get_conference_by_host(self,host):
with engine.connect() as conn:
stmt = text("select * from society_applications sa inner join conference c on sa.conf_id = c.conf_id where sa.app_host = '{}' and sa.app_type_id = 2 order by sa.conf_id desc".format(host))
result = conn.execute(stmt).first()
return dict(result._mapping) if result else None
def get_conference(self,conf_id,conf_key):
with engine.connect() as conn:
stmt = text("select * from conference where conf_id = '{}' and conf_key = '{}' ".format(conf_id,conf_key))
result = conn.execute(stmt).first()
return dict(result._mapping) if result else None
def Userdelegate_no_generate(self,unique_id,conf_id,role='DELEGATE'):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_completed_payment_res_and_gen_del_no_v3",[unique_id,conf_id,role])
if cursor.description :
columns = [column[0] for column in cursor.description]
results_1 = []
for row in cursor.fetchall():
results_1.append(dict(zip(columns, row)))
cursor.close()
connection.commit()
return results_1
else:
cursor.close()
connection.commit()
return None
def get_mobile_check(self,mobile,society_id):
with engine.connect() as conn:
stmt = text("select u.*,m.member_type from users u inner join m_member_type m on m.member_type_id = u.member_type_id where u.mobile = "+str(mobile)+" and u.society_id = "+str(society_id)+";")
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else 0
return results
def update_email(self,user_id,mobile,updated_at,society_id):
with engine.connect() as conn:
stmt = text("UPDATE users SET mobile='"+str(mobile)+"' ,updated_at='"+updated_at+"' WHERE user_id = "+str(user_id)+" and society_id = "+str(society_id)+" ;")
stmt1 = text("select * from users u inner join conference c on u.society_id = c.society_id inner join society_applications sa on sa.conf_id = c.conf_id and sa.app_type_id = 2 inner join m_member_type m on m.member_type_id = u.member_type_id where u.user_id ={} and c.society_id ={};".format(user_id,society_id))
result_1 = conn.execute(stmt)
conn.commit()
result = conn.execute(stmt1).fetchone()
return dict(result._mapping) if result else 'fail'
def receipt_no_generate_and_get(self,unique_id,conf_id):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_receipt_no_generate_and_get_payment_details_v2",[unique_id,conf_id])
if cursor.description :
columns = [column[0] for column in cursor.description]
results_1 = []
for row in cursor.fetchall():
results_1.append(dict(zip(columns, row)))
cursor.close()
connection.commit()
return results_1
else:
cursor.close()
connection.commit()
return None
def get_state_country_users_type(self,user_id,society_id,delegate_id,conf_id,parent_user_id,now):
sets = []
try:
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_register_data",[(user_id or None),(society_id or None),(delegate_id or None),(conf_id or None),(parent_user_id or None),(now or None)])
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.close()
return sets
def get_check_addons_UserModel(self,user_id,conf_id):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_tariff_changes",[(user_id or None),(conf_id or None)])
if cursor.description :
columns = [column[0] for column in cursor.description]
results_1 = []
for row in cursor.fetchall():
results_1.append(dict(zip(columns, row)))
cursor.close()
connection.commit()
return results_1
else :
cursor.close()
connection.commit()
return None
# def check_appliction_to_close_or_openUserModel(self,conf_id,curr_dt):
# with engine.connect() as conn:
# stmt = text("select count(*) from conference where conf_id = "+str(conf_id)+" and reg_end_on > '"+curr_dt+"' ;")
# result = conn.execute(stmt).fetchone()
# return dict(result._mapping) if result else None
def check_appliction_to_close_or_openUserModel(self,conf_id,curr_dt):
with engine.connect() as conn:
stmt = text("select count(*) as code from conference where conf_id = "+str(conf_id)+" and reg_end_on > '"+curr_dt+"' ;")
result = conn.execute(stmt).fetchone()
result = dict(result._mapping)
return result['code'] if result else None
def get_autologin_data(self,user_uuid,society_id):
with engine.connect() as conn:
stmt = text("select * from users u inner join conference c on u.society_id = c.society_id inner join m_member_type m on m.member_type_id = u.member_type_id where u.user_uuid = '"+user_uuid+"' and c.society_id = "+str(society_id)+" limit 1;")
result = conn.execute(stmt).first()
return dict(result._mapping) if result else None
def get_confUserModel(self,conf_id,conf_key):
with engine_sqlite.connect() as conn:
stmt = text("select c.conf_id,c.conf_name,c.conf_title,c.conf_key,c.username,c.badge_login_password,c.conf_uuid,c.regdesk_pin,c.conf_name_full_form,c.conf_domain,c.society_id,c.is_active,c.conf_start_time,c.conf_end_time,c.reg_start_on,c.reg_end_on,c.mail_header_logo,c.header_logo,c.header_text,c.index_content,c.backup_email_2,c.pg_appmaster_id,c.pg_is_test,c.payment_api_url,c.call_payment_url,c.stylesheet,c.favicon_url,c.tariff_url,c.is_email_enable,is_requried_fields,c.kc_del_session_table_name,c.kc_session_entry_table_name,c.del_table_name,c.fc_del_session_table_name,fc_session_entry_table_name,c.is_regdesk_open,c.signup_table,c.e_support_email,c.e_backup_emails,c.e_from_email,c.e_reply_name,c.e_reply_to,c.pg_details,s.society_id,sa.is_gen_number,sa.paymentgateway_api_url,sa.paymentgateway_appmaster_id,sa.paymentgateway_is_test,sa.app_url,s.clarity_script,ms.driver,ms.domain,ms.secret_key,c.addons_member_list,sa.del_subheader_text,dc.dt_text_color,dc.dt_background_color,dc.background_color,dc.background_tariff_color,dc.header_text_color,dc.header_background_color,dc.tr_background_color,dc.td_text_color,dc.footer_text_color,dc.footer_background_color,is_disable_otp,s.society_key,sa.additional_tariff,sa.app_host 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 left join daily_digest_mail_color_template dc on dc.conf_id = c.conf_id where c.conf_id = "+str(conf_id)+" and c.conf_key='"+str(conf_key)+"' and sa.app_type_id = 2 ;")
result = conn.execute(stmt)
result = result.fetchone()
return dict(result._mapping) if result else 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;")
results = conn.execute(stmt).all()
return [dict(r._mapping) for r in results] if results else None
def get_emailUserModel(self,email,society_id):
with engine.connect() as conn:
stmt=text("select * from users u inner join conference c on u.society_id = c.society_id inner join society_applications sa on sa.conf_id = c.conf_id and sa.app_type_id = 2 inner join m_member_type m on m.member_type_id = u.member_type_id where u.email = '"+email+"' and c.society_id = "+str(society_id)+";")
result = conn.execute(stmt).fetchone()
return dict(result._mapping) if result else None
def update_users_user_table(self,email,society_id,data):
with engine.connect() as conn:
stmt = self.users.update().where(self.users.c.email.in_([email]),self.users.c.society_id.in_([society_id])).values(data)
result = conn.execute(stmt)
conn.commit()
if result:
return 'success'
else :
return 'fail'
def getDataforPayments(self,unique_id):
with engine.connect() as conn:
stmt = text("select full_name ,email,mobile,amount,am_id,is_test,payment_for,unique_id,payment_id,"
+ " payment_method,delegate_ids from user_payment where unique_id = '"+unique_id+"' ;")
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
return results
def get_payment_link_incompleted_delegates(self,parent_user_id,unique_id,conf_id):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_get_payment_link_incompleted_delegates",[parent_user_id,unique_id,conf_id])
columns = [column[0] for column in cursor.description]
results = []
for row in cursor.fetchall():
results.append(dict(zip(columns, row)))
cursor.close()
connection.commit()
if results :
return results
else :
return None
# Added Status id
def UserupdatePayment(self,unique_id,data,dt_string):
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)
result = conn.execute(stmt)
if data.get('status') == 'success':
stmt2 = text("update delegates d inner join delegates_addons da on "
+ " da.delegate_id = d.delegate_id inner join user_payment up on up.unique_id COLLATE utf8mb4_general_ci = da.unique_id"
+ " set d.del_status_id = 2,d.registered_on = '"+dt_string+"' where da.unique_id = '"+unique_id+"' ");
result = conn.execute(stmt2)
conn.commit()
return "updated"
else :
return "Unique id missing"
def insert_users(self,data):
with engine.connect() as conn:
result = conn.execute(self.users.insert(), data)
conn.commit()
return result.lastrowid
# def insert_support_queries(self,data):
# with engine.connect() as conn:
# result = conn.execute(self.support_query.insert(), data)
# conn.commit()
# return result.lastrowid
def update_delegateUserModel(self,delegate_id,data):
with engine.connect() as conn:
stmt = self.delegates.update().where(self.delegates.c.delegate_id.in_([delegate_id])).values(data)
result = conn.execute(stmt)
conn.commit()
return 'success' if result else 'fail'
def 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
return results
def 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
return results
def get_addon_types(self,conf_id):
with engine.connect() as conn:
stmt = text("select group_concat(case when addon_type_id is null then '''' else concat('','',addon_type_id )end order by addon_type_id ASC) as addon_type_id, group_concat(case when addon_type is null then '' '' else concat('','',addon_type) end) as addon_type,show_member_types,show_conf_ids from addon_types where is_visible =1 and show_conf_ids like "+"'%"+str(conf_id)+"%'"+" ;")
result = conn.execute(stmt).fetchone()
return dict(result._mapping) if result else None
# result = conn.execute(stmt)
# results = [dict(r) for r in result] if result else None
# return results[0]
def get_addon_reg_typeUserModel(self,conf_id):
with engine.connect() as conn:
stmt = text("select * from addon_types where is_visible = 1 and FIND_IN_SET("+str(conf_id)+",show_conf_ids); ")
result = conn.execute(stmt).all()
return [dict(r._mapping) for r in result] if result else None
def get_addons(self,delegate_id,curr_dt,conf_id,user_type_ids = None,is_custom_addons = None):
with engine.connect() as conn:
user_type_where_con = "";
if user_type_ids:
user_type_where_con += " and (a.user_type_id in ("+user_type_ids+") or a.user_type_id is null )"
if is_custom_addons is None:
user_type_where_con += " and (a.is_custom_addon is null or a.is_custom_addon = 0) "
stmt = text("select a.*,ut.*,da.delegate_id,da.amount as del_amount,da.delegate_addon_id,da.reg_status from addons a "
+" left join user_types ut on ut.user_type_id = a.user_type_id"
+" left join delegates_addons da on da.addon_id = a.addon_id and da.delegate_id = "+str(delegate_id)+" "
+" where a.is_visible=1 AND '"+str(curr_dt)+"' between a.start_by and a.end_by "
+ user_type_where_con
+" and a.conference_id = "+str(conf_id)+" "
+" order by a.order_by;")
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
return results
def get_reg_type(self):
with engine.connect() as conn:
stmt = text("select * from user_types;")
result = conn.execute(stmt)
results = [dict(r._mapping) for r in result] if result else None
return results
def get_users(self,email,mobile):
with engine.connect() as conn:
stmt = text("select * from users where user_id = "+""+mobile+""+" or user_id = "+""+email+""+";")
result = conn.execute(stmt)
results = [dict(r._mapping) for r in result] if result else None
return results
def get_user(self,user_id,society_id,conf_id):
with engine.connect() as conn:
stmt = text("select u.*,r.role as user_role,d.delegate_no,d.ref_no,d.ref_no_only from users u inner join conference c on c.society_id = u.society_id left join user_roles ur on ur.society_id = u.society_id and c.conf_id = ur.conf_id and u.user_id = ur.user_id left join roles r on r.role_id = ur.role_id left join delegates d on c.conf_id = d.conference_id and d.user_id = u.user_id where u.user_id = "+str(user_id)+" and u.society_id = "+str(society_id)+" and c.conf_id = "+str(conf_id)+" ;")
result = conn.execute(stmt).fetchone()
return dict(result._mapping) if result else None
def get_search_user(self,search_input,society_id,conf_id):
with engine.connect() as conn:
profile_update_where_con = "";
if int(conf_id) == 52:
profile_update_where_con += " and u.profile_updated_at <= DATE_ADD(u.profile_updated_at, INTERVAL 1 YEAR) and u.member_type_id in (1,17) "
stmt = text("select u.*,s.state_name,d.delegate_no,d.delegate_id,group_concat(d.delegate_id) as delegate_ids ,"
+" group_concat(d.delegate_no) as delegate_nos, group_concat(d.delegate_no,':',d.delegate_id) as delegate_nos_ids,d.ref_no,d.del_status_id "
+ " from users u inner join conference c on c.society_id = u.society_id "
+" inner join society_applications sa on sa.conf_id = c.conf_id "
+" and sa.app_type_id = 2 left join delegates d on d.user_id = u.user_id "
+" and d.conference_id = "+str(conf_id)+" left join states s on u.state_id = s.state_id where c.conf_id = "+str(conf_id)+" and (u.email like "+"'%"+search_input+"%'"+" or u.full_name like "+"'%"+search_input+"%'"+" or u.mobile like "+"'%"+search_input+"%'"+" or u.city like "+"'%"+search_input+"%'"+" or u.membership_no like "+"'%"+search_input+"%'"+") and u.membership_no is not null and LENGTH(u.membership_no) > 1 and u.society_id = "+str(society_id)+" "+str(profile_update_where_con)+" group by u.user_id;")
#print(stmt)
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
return results
def get_users_valueUserModel(self,user_id,society_id,conf_id):
with engine.connect() as conn:
stmt = text("select * from users u inner join conference c on u.society_id = c.society_id inner join society_applications sa on sa.conf_id = c.conf_id and sa.app_type_id = 2 and c.conf_id ="+str(conf_id)+" inner join m_member_type m on m.member_type_id = u.member_type_id where u.user_id ="+str(user_id)+" and c.society_id = "+str(society_id)+";")
result = conn.execute(stmt).fetchone()
return dict(result._mapping) if result else None
# Added Status id
def get_check_exsits_delegate(self,user_id,parent_user_id,conf_id):
with engine.connect() as conn:
stmt = text("SELECT * FROM delegates where user_id = "+str(user_id)+" and parent_user_id = "+str(parent_user_id)+" and conference_id ="+str(conf_id)+";")
result = conn.execute(stmt).fetchone()
return dict(result._mapping) if result else None
def update_otp(self,otp,otp_sent_at,otp_expire_on,user_id):
with engine.connect() as conn:
sql = " UPDATE users SET "
if otp :
sql=sql+" otp = "+"'"+str(otp)+"'"+" ,"
if otp_sent_at :
sql=sql+" otp_sent_at = "+"'"+otp_sent_at+"'"+" ,"
if otp_expire_on :
sql=sql+" otp_expire_on = "+"'"+otp_expire_on+"'"+" "
sql=sql+" WHERE user_id = {} ;".format(user_id)
stmt = text(sql)
result = conn.execute(stmt)
conn.commit()
# result = result.fetchall()
if result:
return 'success'
else :
return None
def verified_otp(self,otp,otp_verified_at,user_id):
with engine.connect() as conn:
sql = " UPDATE users SET "
if otp :
sql=sql+" otp = NULL ,otp_expire_on = NULL, "
if otp_verified_at :
sql=sql+" otp_verified_at = "+"'"+otp_verified_at+"'"+" "
sql=sql+" WHERE user_id = {} ;".format(user_id)
stmt = text(sql)
result = conn.execute(stmt)
conn.commit()
if result:
return result
else :
return "failed"
def insert_delegateUserModel(self,data):
with engine.connect() as conn:
result = conn.execute(self.delegates.insert(), data)
conn.commit()
return result.lastrowid
def get_member_detailsUserModel(self,user_id,curr_dt,society_id,conf_id):
stmt = text("select u.*,s.state_name,a.display_name,a.amount,c.conf_id,r.role as user_role,ua.attach_file_name,concat(ua.attach_path,'/') as attach_path from users u "
+" left join states s on s.state_id = u.state_id"
+" inner join addons a on find_in_set(u.member_type_id,a.show_member_types)"
+" inner join user_types ut on ut.user_type_id = a.user_type_id"
+" inner join conference c on c.society_id = u.society_id"
+" inner join society_applications sa on sa.conf_id = c.conf_id and sa.app_type_id = 2 "
+" inner join societies soc on soc.society_id = c.society_id"
+" left join user_attachments ua on ua.user_id = u.user_id and ua.attach_type_id = soc.photograph_attach_type_id "
+" left join user_roles ur on ur.society_id = u.society_id and c.conf_id = ur.conf_id and u.user_id = ur.user_id "
+" left join roles r on r.role_id = ur.role_id"
+" where u.user_id= "+str(user_id)+" and a.is_visible=1 and c.conf_id = "+str(conf_id)+" AND '"+curr_dt+"' between a.start_by and a.end_by and u.society_id = "+str(society_id)+" "
+" order by a.addon_id;")
with engine.connect() as conn:
result = conn.execute(stmt).fetchone()
return dict(result._mapping) if result else None
def get_delegate(self,delegate_id):
with engine.connect() as conn:
stmt = text("select d.*,s.state_name,r.role as user_role from delegates d inner join conference c on c.conf_id = d.conference_id left join users u on u.user_id = d.user_id left join user_roles ur on ur.society_id = u.society_id and c.conf_id = ur.conf_id and u.user_id = ur.user_id left join roles r on r.role_id = ur.role_id left join states s on d.state_id = s.state_id where delegate_id = "+str(delegate_id)+";")
result = conn.execute(stmt).fetchone()
return dict(result._mapping) if result else None
def delete_delegateUserModel(self,delegate_id):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_delete_delegates",[delegate_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()
return results
else :
return None
# left join addons a on a.addon_id = da.addon_id
# """ insert or delete delegates_addons """
# def save_delegates_addonsUserModel(self,delegate_id,inser_dal_addon,delete_del_addon,now):
# sql_insert = ""
# sql_delete = ""
# with engine.connect() as conn:
# for d in inser_dal_addon:
# sql_insert = sql_insert + "insert into delegates_addons (delegate_id,addon_id,amount,original_amount,reg_status,created_at) values ({},{},{},{},{},'{}');".format(delegate_id,d['addon_id'],d['amount'],d['original_amount'],d['reg_status'],now)
# for da_id in delete_del_addon:
# sql_delete = sql_delete + "delete from delegates_addons where delegate_addon_id = {};".format(da_id)
# if sql_insert:
# insert_stmt = text(sql_insert)
# result = conn.execute(insert_stmt)
# conn.commit()
# if sql_delete:
# delete_stmt = text(sql_delete)
# result = conn.execute(delete_stmt)
# conn.commit()
# return True
""" insert or delete delegates_addons updated on 13-09-2023 """
def save_delegates_addonsUserModel(self,delegate_id,inser_dal_addon,delete_del_addon,now):
sql_insert = ""
sql_delete = ""
with engine.connect() as conn:
for d in inser_dal_addon:
sql_insert = " insert into delegates_addons (delegate_id,addon_id,amount,original_amount,reg_status,created_at) values ({},{},{},{},{},'{}');".format(delegate_id,d['addon_id'],d['amount'],d['original_amount'],d['reg_status'],now)
sql_insert_logs = " insert into delegates_addons_logs (delegate_id,addon_id,amount,original_amount,reg_status,created_at) values ({},{},{},{},{},'{}');".format(delegate_id,d['addon_id'],d['amount'],d['original_amount'],d['reg_status'],now)
if sql_insert:
insert_stmt = text(sql_insert)
result = conn.execute(insert_stmt)
insert_stmt_logs = text(sql_insert_logs)
results = conn.execute(insert_stmt_logs)
conn.commit()
for da_id in delete_del_addon:
sql_delete = " delete from delegates_addons where delegate_addon_id = {};".format(da_id)
if sql_delete:
delete_stmt = text(sql_delete)
result = conn.execute(delete_stmt)
conn.commit()
return True
""" Sridhar on 204/Mar 2022 """
def check_user_delegateUserModel(self,user_id,society_id,conf_id):
with engine.connect() as conn:
stmt = text("select count(*) as count from delegates where user_id= "+str(user_id)+" and society_id= "+str(society_id)+" and conference_id = "+str(conf_id)+";")
result = conn.execute(stmt).first()
result = dict(result._mapping)
if result:
return result["count"]
else:
return 0
def check_duplicate_delegateUserModel(self,delegate_ids,conf_id):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_registration_cart_validation",[delegate_ids,conf_id])
columns = [column[0] for column in cursor.description]
results = []
for row in cursor.fetchall():
results.append(dict(zip(columns, row)))
cursor.close()
connection.commit()
if results :
return results
else :
return None
# Will Check
def get_incompleted_delegates_by_parent_user_idUserModel(self,parent_user_id,unique_id,conf_id,reg_mode):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_get_incompleted_delegates_by_parent_user_id",[parent_user_id,unique_id,conf_id,reg_mode])
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()
return results
else :
cursor.close()
connection.commit()
return None
def get_completed_course_delegates_by_parent_user_id_UserModel(self,parent_user_id,conf_id):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_get_completed_course_delegates_by_parent_user_id",[parent_user_id,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()
return results
else :
cursor.close()
connection.commit()
return None
def get_completed_delegates_by_parent_user_id_UserModel(self,parent_user_id,conf_id):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_get_completed_delegates_by_parent_user_id_v2",[parent_user_id,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()
return results
else :
cursor.close()
connection.commit()
return None
def getdata(self,delegate_nos,from_del_no,to_del_no,search,user_type,status,From,to,orderby,order_type,limit,offset,conf_id,society_id):
# print(delegate_nos,from_del_no,to_del_no,search,user_type,status,From,to,orderby,order_type,limit,offset,conf_id,society_id)
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_bo_user_report",[(delegate_nos or None),(from_del_no or None),(to_del_no or None),(search or None),(user_type or None),status,(From or None),(to or None),orderby,order_type,limit,offset,conf_id,society_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()
return results
else :
cursor.close()
connection.commit()
return None
#-------------------- bo_users code ends here ------------------------------------------
def get_unique_id(self,app_type,cur_date):
with engine.connect() as conn:
stmt = text("select unique_id,conf_id FROM user_payment where am_id in (11,14) and (status != 'success' or status is null) and date(created_at) = '"+cur_date+"' and app_type = '"+app_type+"' ; ")
# stmt = text("SELECT unique_id,conf_id FROM user_payment where am_id in (11,14) and (status != 'success' or status is null) and app_type = 'DELEGATE' ; ")
results = conn.execute(stmt).all()
return [dict(r._mapping) for r in results] if results else None
def get_conf_id(self,unique_id):
with engine.connect() as conn:
stmt = text("SELECT c.* FROM user_payment up inner join conference c on c.conf_id = up.conf_id"
+ " inner join society_applications sa on sa.conf_id = c.conf_id and sa.app_type_id = 2 "
+ " where up.unique_id= '"+unique_id+"' and up.app_type = 'DELEGATE' ; ")
result = conn.execute(stmt).fetchone()
return dict(result._mapping) if result else None
def get_payment_method(self,conf_id):
with engine.connect() as conn:
stmt = text ("SELECT * from m_payment_type where is_visible =1 and is_delegate = 1 and conf_id= "+str(conf_id)+" and is_visible =1 and is_online_visible =1 order by order_by ASC;");
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
return results
def get_completed_waiting_delegates_by_parent_user_id(self,parent_user_id,conf_id):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_waiting_gen_delegate_no_v1",[parent_user_id,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()
return results
else :
cursor.close()
connection.commit()
return None
def get_delegate_attchment_details(self,conf_id,unique_id):
with engine.connect() as conn:
stmt=text("select * from delegates d inner join delegate_attachments da on da.delegate_id = d.delegate_id where da.unique_id = '"+unique_id+"' and d.conference_id = "+str(conf_id)+" ;")
result = conn.execute(stmt).first()
return dict(result._mapping) if result else None
def update_image(self,attach_id,data):
with engine.connect() as conn:
stmt = self.delegate_attachments.update().where(self.delegate_attachments.c.attach_id.in_([attach_id])).values(data)
result = conn.execute(stmt)
conn.commit()
if result:
return 'success'
else :
return 'fail'
def insert_image(self,data):
with engine.connect() as conn:
result = conn.execute(self.delegate_attachments.insert(), data)
conn.commit()
pk_id = [r for r in result.inserted_primary_key] if result.inserted_primary_key else None
return pk_id
def get_delegate_attach(self,attach_id):
with engine.connect() as conn:
stmt = text("select * from delegate_attachments where attach_id = "+str(attach_id)+" ;")
result = conn.execute(stmt).first()
return dict(result._mapping) if result else None
def delete_image(self,attach_id):
with engine.connect() as conn:
stmt = text("delete from delegate_attachments WHERE attach_id = "+str(attach_id)+";")
results = conn.execute(stmt)
conn.commit()
if results:
return 'success'
else :
return 'fail'
def updatePaymentData(self,unique_id,data):
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)
result = conn.execute(stmt)
conn.commit()
return "updated"
else :
return "Unique id missing"
def get_payment_content(self,payment_type,is_delegate,conf_id):
with engine.connect() as conn:
stmt = text ("select * from m_payment_type where is_visible =1 and is_delegate ="+str(is_delegate)+" and conf_id="+str(conf_id)+" and payment_type = '"+payment_type+"' and is_online_visible =1;");
# stmt = self.m_payment_type.select().where(self.m_payment_type.c.payment_type.in_([payment_type])).where(self.m_payment_type.c.is_delegate.in_([is_delegate])).where(self.m_payment_type.c.conf_id.in_([conf_id]))
result = conn.execute(stmt).first()
return dict(result._mapping) if result else None
def get_member(self,user_id):
with engine.connect() as conn:
stmt = text("select * from users where user_id = "+str(user_id)+";")
# stmt = select([self.users]).where(self.users.c.user_id.in_([user_id]))
result = conn.execute(stmt).first()
return dict(result._mapping) if result else None
# Added Status id
def update_reg_status(self,unique_id,delegate_ids,conf_id,dt_string):
with engine.connect() as conn:
stmt = text("update delegates_addons set reg_status = 3,updated_at = '"+str(dt_string)+"' where unique_id = '"+unique_id+"' ;")
result = conn.execute(stmt)
conn.commit()
# delegates table update status_id for Waiting for delegate no genereate.
stmt_1 = text("update delegates set del_status_id = 3,updated_at = '"+str(dt_string)+"' where delegate_id in ("+str(delegate_ids)+") and conference_id = "+str(conf_id)+" and del_status_id != 2 ;")
print("stmt_1")
print(stmt_1)
result = conn.execute(stmt_1)
conn.commit()
if result :
return 'success'
else:
return 'fail'
def get_image(self,delegate_id,conf_id,unique_id):
with engine.connect() as conn:
stmt = text("select das.*,up.utr_number from delegates d inner join delegates_addons da on da.delegate_id = d.delegate_id inner join delegate_attachments das on das.delegate_id = d.delegate_id inner join user_payment up on da.unique_id = up.unique_id where FIND_IN_SET(d.delegate_id,'{}') and d.conference_id = {} and das.unique_id = '{}' and da.unique_id = '{}' limit 1; ".format(delegate_id,conf_id,unique_id,unique_id));
# stmt = text("select das.* from delegates d inner join delegates_addons da on da.delegate_id = d.delegate_id inner join delegate_attachments das on das.delegate_id = d.delegate_id where d.delegate_id = {} and d.conf_id = {}; ".format(delegate_id,conf_id));
result = conn.execute(stmt).first()
return dict(result._mapping) if result else None
def get_rejected_upi_transaction_by_parent_user_id(self,parent_user_id,conf_id):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_rejected_upi_transaction_by_parent_user_id",[parent_user_id,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()
return results
else :
cursor.close()
connection.commit()
return None
def get_reject_remarks(self,unique_id,conf_id):
with engine.connect() as conn:
stmt = text("select * from delegate_user_logs where unique_id = '"+unique_id+"' and conf_id = "+str(conf_id)+" and is_lock = 0 order by id desc limit 1;")
result = conn.execute(stmt).first()
return dict(result._mapping) if result else None
def update_reject_remarks(self,unique_id,conf_id):
with engine.connect() as conn:
stmt = text("update delegate_user_logs set is_lock =1 where unique_id = '"+unique_id+"' and conf_id = "+str(conf_id)+" and is_lock = 0 order by id desc limit 1;")
result = conn.execute(stmt)
conn.commit()
return 'success' if result else 'fail'
def get_addons_data(self,addon_id,conf_id,now):
with engine.connect() as conn:
addon_id = "null" if not addon_id else addon_id
stmt = text("select a.addon_id,ut.* from user_types ut inner join addons a on a.user_type_id = ut.user_type_id "
+ " where a.addon_id ="+str(addon_id)+" and a.conference_id = "+str(conf_id)+
" and ut.is_mandatory_mc_no_state in (1,2) and a.is_visible=1 AND '"+str(now)+"' between a.start_by and a.end_by;")
result = conn.execute(stmt).fetchone()
return dict(result._mapping) if result else None
def get_user_data_by_uuid(self,society_id,user_uuid):
with engine.connect() as conn:
stmt = text("select * from users where society_id= '"+str(society_id)+"' and user_uuid = '"+user_uuid+"' ;")
result = conn.execute(stmt).all()
return [dict(r._mapping) for r in result] if result else None
def get_already_completed_delegates(self,conf_id):
with engine.connect() as conn:
stmt=text("SELECT delegate_no,ref_no,concat(ifnull(prefix,' '),case when prefix is null then full_name else concat(' ',full_name) end) as full_name,email,mobile from delegates where conference_id ="+str(conf_id)+" and (delegate_no is not null or ref_no is not null);")
result = conn.execute(stmt).all()
return [dict(r._mapping) for r in result] if result else None
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).fetchone()
return dict(result._mapping) if result else None
def insert_ccavenue_payment(self,ccavenue_data):
with engine.connect() as conn:
result = conn.execute(self.payment_logs.insert(), ccavenue_data)
conn.commit()
return result
def usp_del_tricon_workshop_update(self,unique_id,conf_id):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_tricon_workshop_update",[unique_id,conf_id])
if cursor.description :
columns = [column[0] for column in cursor.description]
results_1 = []
for row in cursor.fetchall():
results_1.append(dict(zip(columns, row)))
cursor.close()
connection.commit()
return results_1
else:
cursor.close()
connection.commit()
return None
def get_all_pending_data(self,conf_id,delegate_id,now,addon_ids):
# print(delegate_nos,from_del_no,to_del_no,receipt_nos,from_receipt_no,to_receipt_no,search,user_type,status,From,to,orderby,order_type,limit,offset,reg_mode,conf_id,society_id)
sets = []
try:
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_get_pending_addons_details",[conf_id,delegate_id,now,addon_ids])
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
#Code Updated On May 26 2023
# call usp_del_parent_completed_list(17, '2023-05-26 17:37:00');
def getDelParentCompletedList(self,conf_id,curr_dt):
# print(delegate_nos,from_del_no,to_del_no,receipt_nos,from_receipt_no,to_receipt_no,search,user_type,status,From,to,orderby,order_type,limit,offset,reg_mode,conf_id,society_id)
sets = []
try:
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_parent_completed_list",[conf_id,curr_dt])
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 insertLoginLogs(self,data):
with engine_conf_db.connect() as conn:
try:
result = conn.execute(self.users_logs.insert(), data)
conn.commit()
return "success"
except Exception as e:
return str(e)
def updateDelegateAddons(self,data_for_del_addons,unique_id,conf_id):
with engine.connect() as conn:
try:
stmt = self.delegates_addons.update().where(self.delegates_addons.c.unique_id.in_([unique_id])).values(data_for_del_addons)
conn.execute(stmt)
conn.commit()
return "success"
except Exception as e:
return str(e)
def getTNASIPaymentProof(self,unique_id,conf_id) :
with engine.connect() as conn:
stmt = text(" select d.delegate_id,concat(ifnull(d.prefix, ' '), d.full_name ) as full_name,d.pg_cert_path, d.pg_cert_name from delegates_addons da "
+ " inner join delegates d on d.delegate_id = da.delegate_id and d.conference_id = "+str(conf_id)+" "
+ " where da.unique_id = '"+unique_id+"' and d.del_status_id = 8 and d.pg_cert_path is not null and d.pg_cert_name is not null limit 1;")
result = conn.execute(stmt).first()
return dict(result._mapping) if result else None
def insert_mandrill_logs(self,data):
with engine_conf_db.connect() as conn:
result = conn.execute(self.mandrill_mail_logs.insert(), data)
conn.commit()
return result.lastrowid
def insert_mandrill_otp_logs(self,data):
with engine_conf_db.connect() as conn:
result = conn.execute(self.mandrill_otp_mail_logs.insert(), data)
conn.commit()
return result.lastrowid
def get_wetdrylab_open_close(self,conf_id):
with engine.connect() as conn:
stmt = text("select count(*) as display_addon from addon_types where find_in_set("+str(conf_id)+",show_conf_ids) and is_active = 1;;")
result = conn.execute(stmt).fetchone()
return dict(result._mapping) if result else None
def get_user_delegate_no(self,email,conf_id):
with engine.connect() as conn:
stmt = text("select * from delegates where email = '"+str(email)+"' and conference_id = "+str(conf_id)+" and (delegate_no is not null or ref_no is not null) limit 1 ;")
result = conn.execute(stmt).fetchone()
return dict(result._mapping) if result else None
def get_addons_limit_for_all(self,conf_id):
with engine.connect() as conn:
stmt=text("select a.user_type_id,a.addon_id,a.reg_type,a.display_name,count(da.addon_id) as limits from addons a inner join delegates_addons da on a.addon_id = da.addon_id inner join user_types ut on ut.user_type_id = a.user_type_id where a.conference_id = "+str(conf_id)+" and a.addon_type_id not in (1) and da.reg_status =2 group by a.reg_type;")
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
return results
def get_all_addons_data(self,conf_id):
with engine.connect() as conn:
stmt = text("select user_type_id,head_count,reg_type from addons where conference_id = "+str(conf_id)+" and addon_type_id not in (1);")
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
return results
# def get_count(self):
# stmt=text("SELECT count( delegate_id ) as total from delegates;")
# conn = engine.connect()
# result = conn.execute(stmt)
# result = result.fetchone()
# conn.close()
# return result.total if result else 0
def checking_unique_id_with_user_id(self,conf_id,unique_id,user_id):
with engine.connect() as conn:
stmt = text("select * from user_payment where conf_id = "+str(conf_id)+" and unique_id = '"+unique_id+"' and user_id = "+str(user_id)+";")
result = conn.execute(stmt).first()
return dict(result._mapping) if result else None
def get_incompleted_delegate_data_by_unique_id(self,conf_id,unique_id):
sets = []
try:
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_conf_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 get_inprogress_payment_delegates_by_parent_user_idUserModel(self,parent_user_id,unique_id,conf_id):
# print(parent_user_id,unique_id,conf_id)
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_get_payment_inprogress_delegates_by_parent_user_id",[parent_user_id,(unique_id or None),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()
return results
else :
cursor.close()
connection.commit()
return None
def UpdateInprogressDelegates(self,unique_id,dt_string,reg_status,conf_id,is_count_update=None):
with engine.connect() as conn:
if is_count_update:
stmt_1 = text("update delegates_addons set reg_status = "+str(reg_status)+",updated_at ='"+str(dt_string)+"' where unique_id = '"+unique_id+"' ;")
result_1 = conn.execute(stmt_1)
conn.commit()
else:
stmt = text("update delegates_addons set reg_status = "+str(reg_status)+",updated_at ='"+str(dt_string)+"' where unique_id = '"+unique_id+"' ;")
result = conn.execute(stmt)
conn.commit()
stmt_2 = text("select group_concat(d.delegate_id) as delegate_ids from delegates d inner join delegates_addons da on da.delegate_id = d.delegate_id where da.unique_id = '"+str(unique_id)+"' and d.conference_id = "+str(conf_id)+" ;")
result_2 = conn.execute(stmt_2).first()
delegate_ids = result_2.delegate_ids if result_2.delegate_ids else None
if delegate_ids:
stmt_3 = text("update delegates set del_status_id = "+str(reg_status)+",updated_at ='"+str(dt_string)+"' where delegate_id in ("+str(delegate_ids)+") and conference_id = "+str(conf_id)+" and del_status_id not in (2,3) ;")
result_3 = conn.execute(stmt_3)
conn.commit()
return True
def check_bo_access(self,email,app_type_id,society_id,conf_id):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_check_admin_access",[email,app_type_id,society_id,conf_id])
columns = [column[0] for column in cursor.description]
results = []
for row in cursor.fetchall():
results.append(dict(zip(columns, row)))
cursor.close()
connection.commit()
if results :
return results[0]
else :
return None
# app_style start here
def GetAppStyle(self,conf_id):
with engine.connect() as conn:
stmt = text("select * from app_style where conf_id = "+str(conf_id)+" ;")
result = conn.execute(stmt)
result = result.fetchone()
return dict(result._mapping) if result else None
# app_style end here
# PG Added
def get_pg_waiting_approval_delegates_by_parent_user_idUserModel(self,parent_user_id,unique_id,conf_id):
# print(parent_user_id,unique_id,conf_id)
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_get_pg_waiting_approval_delegates_by_parent_user_id",[parent_user_id,(unique_id or None),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()
return results
else :
cursor.close()
connection.commit()
return None
def get_pg_proof_data(self,conf_id,delegate_id,del_status_id):
with engine.connect() as conn:
stmt = text("select up.unique_id,d.* from delegates d "
+" inner join delegates_addons da on da.delegate_id = d.delegate_id"
+" inner join user_payment up on up.unique_id = da.unique_id"
+" where d.del_status_id = "+str(del_status_id)+" and d.conference_id = "+str(conf_id)+" and d.delegate_id = "+str(delegate_id)+" ;")
result = conn.execute(stmt)
result = result.fetchone()
return dict(result._mapping) if result else None
# PG Added
def Userdelegate_no_generate_with_pg(self,unique_id,conf_id,role='DELEGATE'):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_completed_payment_res_and_gen_del_no_with_pg",[unique_id,conf_id,role])
if cursor.description :
columns = [column[0] for column in cursor.description]
results_1 = []
for row in cursor.fetchall():
results_1.append(dict(zip(columns, row)))
cursor.close()
connection.commit()
return results_1
else:
cursor.close()
connection.commit()
return None
def get_user_register_content(self,conf_id):
with engine.connect() as conn:
stmt = text("select * from del_conf_content where conf_id = "+str(conf_id)+" and is_visible > 0 order by order_by asc ;")
results = conn.execute(stmt).all()
return [dict(r._mapping) for r in results] if results else None
def get_parent_user_id_count(self,conf_id,user_id):
with engine.connect() as conn:
stmt = text("select count(parent_user_id) as parent_user_id from delegates where conference_id = "+str(conf_id)+" and parent_user_id="+str(user_id)+";")
result = conn.execute(stmt).fetchone()
return dict(result._mapping) if result else None
def get_member_data(self,society_id,conf_id,where_con):
with engine.connect() as conn:
# stmt = text("select * from users where society_id = "+str(society_id)+" "+str(where_con)+" ;")
stmt = text("select u.*,s.state_name,d.delegate_no,d.delegate_id,group_concat(d.delegate_id) as delegate_ids ,"
+" group_concat(d.delegate_no) as delegate_nos,"
+" group_concat(d.delegate_no,':',d.delegate_id) as delegate_nos_ids,d.ref_no"
+" from users u inner join conference c on c.society_id = u.society_id"
+" inner join society_applications sa on sa.conf_id = c.conf_id "
+" and sa.app_type_id = 2 left join delegates d on d.user_id = u.user_id"
+" and (d.delegate_no is not null or d.ref_no is not null) and d.conference_id = "+str(conf_id)+""
+" left join states s on u.state_id = s.state_id where c.conf_id = "+str(conf_id)+" and u.membership_no is not null and LENGTH(u.membership_no) > 0 and u.society_id = "+str(society_id)+" "+str(where_con)+" group by u.user_id order by u.full_name asc;")
results = conn.execute(stmt).all()
return [dict(r._mapping) for r in results] if results else None
def get_duplicate_delegates_by_email_and_mobile(self,email,mobile,conf_id,parent_user_id,delegate_id):
sets = []
try:
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_non_member_duplicate_check_v1",[(email or None),(mobile or None),(conf_id or None),(parent_user_id or None),(delegate_id or None)])
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.close()
return sets
def get_delegate_data_using_user_uuid(self,user_uuid,conf_id):
with engine.connect() as conn:
stmt = text("select * from delegates where conference_id ="+str(conf_id)+" and (ref_no_only > 0 or delegate_no > 0) and user_uuid = '"+str(user_uuid)+"' ;")
result = conn.execute(stmt).fetchone()
return dict(result._mapping) if result else None
def getDataforPaymentsby_utr_number(self,conf_id,utr_number,payment_id):
with engine.connect() as conn:
stmt=text("select * from user_payment up inner join delegates_addons da on up.unique_id = up.unique_id inner join delegates d on d.delegate_id = da.delegate_id where up.conf_id = "+str(conf_id)+" and up.api_payment_id = '"+utr_number+"' and up.payment_id != '"+str(payment_id)+"' and d.del_status_id in(3,2);")
result = conn.execute(stmt).first()
return dict(result._mapping) if result else None
# Bo Layout data start here
def get_bo_layout_data(self,society_id,conf_id,admin_email,app_type_id):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_get_app_menu",[society_id,conf_id,admin_email,app_type_id])
if cursor.description :
columns = [column[0] for column in cursor.description]
results_1 = []
for row in cursor.fetchall():
results_1.append(dict(zip(columns, row)))
cursor.close()
connection.commit()
return results_1
else:
cursor.close()
connection.commit()
return None
# Bo Layout data end here
def getEmailandPasswordUserModel(self,email,password,society_id):
with engine.connect() as conn:
stmt=text("select * from users u inner join conference c on u.society_id = c.society_id inner join society_applications sa on sa.conf_id = c.conf_id and sa.app_type_id = 2 inner join m_member_type m on m.member_type_id = u.member_type_id where u.email = '"+email+"' and c.society_id = "+str(society_id)+" and u.password = '"+str(password)+"' ;")
result = conn.execute(stmt).fetchone()
return dict(result._mapping) if result else None
def get_mobile_check_for_password(self,mobile,user_id,society_id):
with engine.connect() as conn:
stmt = text("select * from users where mobile = {} and user_id != {} and society_id = {} limit 1;".format(mobile,user_id,society_id))
result = conn.execute(stmt).one_or_none()
return [dict(result._mapping)] if result else None
def update_member(self,user_id,data):
with engine.connect() as conn:
stmt = self.users.update().values(data).where(self.users.c.user_id.in_([user_id]))
result = conn.execute(stmt)
conn.commit()
select_stmt = text("select * from users where user_id = "+str(user_id)+" ")
select_result = conn.execute(select_stmt).one_or_none()
return dict(select_result._mapping) if select_result else None
def getPaymentAddons(self,conf_id,unique_id):
with engine.connect() as conn:
stmt=text("select group_concat(distinct a.addon_type_id) as addon_type_id from delegates_addons da "
+" inner join addons a on a.addon_id = da.addon_id "
+" where unique_id = '"+str(unique_id)+"' and a.conference_id = "+str(conf_id)+" group by da.unique_id;")
result = conn.execute(stmt).one_or_none()
return dict(result._mapping) if result else None
def get_additional_addon_count(self,conf_id):
with engine.connect() as conn:
stmt=text("select a.addon_id,a.session_name,a.display_name,a.author_name,a.day,a.start_time,a.end_time, "
+" a.head_count,(a.head_count-count(da.delegate_id)) as delegate_count,ats.addon_type "
+" from addons a "
+" left join delegates_addons da on a.addon_id = da.addon_id and da.reg_status in (2,3) "
+" left join addon_types ats on ats.addon_type_id = a.addon_type_id where a.is_visible = 1 "
+" and a.conference_id = "+str(conf_id)+" and a.addon_type_id in(24) "
+" group by a.addon_id order by ats.addon_type DESC,a.addon_name ,a.day ;")
result = conn.execute(stmt).all()
return [dict(r._mapping) for r in result] if result else None
def get_total_reg_addon_count(self,delegate_id,conf_id):
with engine.connect() as conn:
stmt=text("select count(da.delegate_id) as total_reg_count from delegates d inner join delegates_addons da on da.delegate_id = d.delegate_id inner join addons a on a.addon_id = da.addon_id where d.conference_id = "+str(conf_id)+" and d.delegate_id = "+str(delegate_id)+" and d.del_status_id = 2 and da.reg_status in (2,3) and a.addon_type_id not in (1);")
result = conn.execute(stmt).one_or_none()
return dict(result._mapping) if result else None
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists