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 .. import Cryptography
from core.library.helper import Helper
import json
from .. import engine
# engine = create_engine(app.config['DATABASE_URI'],pool_size=5000,pool_pre_ping=True,pool_recycle=3600)
class UserModel():
def __init__(self):
try:
self.meta = MetaData()
self.users = Table("users", self.meta, autoload_with=engine)
self.categories = Table("abs_categories",self.meta,autoload_with=engine)
self.abstracts = Table("sa_abstracts", self.meta, autoload_with=engine)
except Exception as e:
print(e)
def get_society(self,society_id):
with engine.connect() as conn:
stmt = text("select * from societies where society_id = {}".format(society_id))
result = conn.execute(stmt).first()
conn.close()
return dict(result._mapping) if result else None
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 app_host = '{}' and app_type_id = 3".format(host))
result = conn.execute(stmt).first()
conn.close()
return dict(result._mapping) if result else None
def insert_new_user(self,email,society_id,user_society):
with engine.connect() as conn:
stmt = text("insert into users (member_type_id,email,society_id,user_society) values(1,'{}',{},'{}')".format(email,society_id,user_society))
results = conn.execute(stmt)
conn.commit()
stmt = text("select * from users where email = '{}' and society_id = {} and user_society = '{}'".format(email,society_id,user_society))
results = conn.execute(stmt).first()
conn.close()
return dict(results._mapping) if results else None
def insert_new_request_user(self,data,society_id):
with engine.connect() as conn:
stmt = text("select * from users where email = '{}' and society_id = {}".format(data['email'],society_id))
stmt_1 = text("insert into users (prefix,full_name,email,society_id) values('Dr.','{}','{}',{})".format(data["name"],data['email'],society_id))
results = conn.execute(stmt).first()
results = dict(results._mapping)if results else None
if results:
return results
else:
results = conn.execute(stmt_1)
conn.commit()
results = conn.execute(stmt).first()
results = dict(results._mapping)if results else None
conn.close()
if results :
return results
else:
return None
def get_state_and_country(self):
sets = []
try:
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_get_state_and_country")
while 1:
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
if cursor.description is None:
break
finally:
connection.close()
return sets
def get_state(self):
with engine.connect() as conn:
stmt = text("select * from states where country_id = 101 order by state_name asc")
result = conn.execute(stmt).all()
conn.close()
return [dict(r._mapping) for r in result] if result else None
def get_coountry(self):
with engine.connect() as conn:
stmt = text("select * from countries")
result = conn.execute(stmt).all()
conn.close()
return [dict(r._mapping) for r in result] if result else None
def get_country_data(self,country_id):
with engine.connect() as conn:
stmt = text("select * from states where country_id = {} order by state_name asc".format(country_id))
result = conn.execute(stmt).all()
conn.close()
return [dict(r._mapping) for r in result] if result else None
def count_whatsapp_num(self,whatsapp_number,user_id,society_id):
with engine.connect() as conn:
stmt = text("select count(*) from users where user_id <> :user_id and (mobile= :whatsapp_number or whatsapp_number=:whatsapp_number) and society_id = :society_id ")
result = conn.execute(stmt.bindparams(user_id=user_id,whatsapp_number=whatsapp_number,society_id=society_id))
results = result.first()
conn.close()
if results :
return results
else:
return None
def get_mobile_count(self,mobile,user_id,society_id):
with engine.connect() as conn:
stmt = text("select count(*) as mobile_count from users where mobile = {} and user_id != {} and society_id = {} ".format(mobile,user_id,society_id))
result = conn.execute(stmt).first()
results = dict(result._mapping) if result else None
conn.close()
return results["mobile_count"]
def get_user_data_by_uuid(self,uuid):
with engine.connect() as conn:
stmt = text("select * from users where user_uuid = '{}'".format(uuid))
result = conn.execute(stmt).first()
conn.close()
return dict(result._mapping) if result else None
def get_confe(self,conf_id,conf_key):
with engine.connect() as conn:
stmt = text("select c.*,sa.app_title,sa.app_url,app_host,sa.mail_setting_id,app_style,s.society_title,s.society_name,s.society_intial,sa.index_content as society_index_content,ms.* from conference c inner join societies s on s.society_id = c.society_id inner join society_applications sa on c.conf_id = sa.conf_id and sa.app_type_id = 3 inner join mail_setting ms on ms.mail_setting_id=sa.mail_setting_id where c.conf_id = {} and c.conf_key = '{}'".format(conf_id,conf_key))
result = conn.execute(stmt).first()
conn.close()
# results = [dict(r) for r in result] if result else None
return dict(result._mapping) if result else None
def get_users_email_data(self,email,society_id,society_name):
with engine.connect() as conn:
stmt = text("select * from users where email = '{}' and society_id = {} and user_society = '{}'".format(email,society_id,society_name))
results = conn.execute(stmt).first()
conn.close()
return dict(results._mapping) if results else None
def get_members_email_data(self,email,society_id):
with engine.connect() as conn:
stmt = text("select * from users where email = '{}' and society_id = {} and member_type_id in (1,6) and user_society in ('APOS','TOS')".format(email,society_id))
result = conn.execute(stmt).first()
conn.close()
return dict(result._mapping) if result else None
def get_otp_random(self,user_id):
with engine.connect() as conn:
stmt = text("select otp from users where user_id = {} ".format(user_id))
result = conn.execute(stmt).first()
conn.close()
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).first()
conn.close()
return dict(select_result._mapping) if select_result else None
def get_member(self,user_id):
with engine.connect() as conn:
stmt = text("select * from users where user_id = {} ".format(user_id))
result = conn.execute(stmt).first()
conn.close()
return dict(result._mapping) if result else None
def get_users_member_no(self,ids):
with engine.connect() as conn:
stmt = text("select user_id,membership_no,concat(ifnull(prefix,' '),ifnull(full_name,' ')) as full_name,email,mobile from users where user_id = {} ;".format(ids))
result = conn.execute(stmt).one_or_none()
conn.close()
return dict(result._mapping) if result else None
def get_categories(self,abs_type,conf_id):
with engine.connect() as conn:
if abs_type == "VT":
stmt_2 = text("select * from abs_categories where is_{} = 1 and forum_is_visible = 0 and conf_id = {} order by category_id".format(abs_type,conf_id))
else:
stmt_2 = text("select * from abs_categories where is_{} = 1 and segment is not null and conf_id = {} order by category_id".format(abs_type,conf_id))
result = conn.execute(stmt_2).all()
conn.close()
return [dict(r._mapping) for r in result] if result else None
def get_categories_by_user(self,abs_type,conf_id,user_id):
with engine.connect() as conn:
stmt_2 = text(f"select *,ac.category_id from abs_categories ac inner join map_abs_category mas on mas.category_id=ac.category_id inner join abs_types ats on ats.abs_type_id=mas.abs_type_id where is_active=1 and mas.conf_id={conf_id} and ats.abs_type='{abs_type}' and ac.category_id not in (select ifnull(category_id,0) from abstracts where conf_id = {conf_id} and abs_type = '{abs_type}' and user_id = {user_id} and abs_status_id not in (0,3,4)) order by order_no asc;")
result = conn.execute(stmt_2).all()
conn.close()
return [dict(r._mapping) for r in result] if result else None
def get_categories_v1(self,abs_type):
with engine.connect() as conn:
stmt_2 = text("select * from abs_categories ac inner join map_abs_category mas on mas.category_id=ac.category_id inner join sa_abs_types ats on ats.abs_type_id=mas.sa_abs_type_id where is_active=1 and ats.abs_type='{}' order by order_no asc,display_name;".format(abs_type))
result = conn.execute(stmt_2).all()
conn.close()
return [dict(r._mapping) for r in result] if result else None
def get_categories_bo(self,abs_type,conf_id):
with engine.connect() as conn:
stmt_2 = text("select * from abs_categories where conf_id = {};".format(conf_id))
result = conn.execute(stmt_2).all()
conn.close()
return [dict(r._mapping) for r in result] if result else None
def new_abs(self,user_id,abs_type,role_id,created_at):
with engine.connect() as conn:
stmt = self.abstracts.insert().values(user_id=user_id,abs_type=abs_type,created_at=created_at)
result = conn.execute(stmt)
conn.commit()
# abs_id = result.inserted_primary_key if result.inserted_primary_key[0] else None
# print('pk - abs_id',abs_id)
# if abs_id:
# abs_id = abs_id[0]
# else:
stmt1 = text(f"select abs_id from sa_abstracts where abs_type='{abs_type}' and user_id ={user_id} order by abs_id desc limit 1")
result = conn.execute(stmt1).first()
abs_id = result.abs_id
print('select - abs_id - ',abs_id)
stmt = text("insert into sa_topics (user_id,abs_id,role_id,created_at) VALUES('{}','{}',{},'{}')".format(user_id,abs_id,role_id,str(created_at)))
result = conn.execute(stmt)
conn.commit()
conn.close()
return abs_id
def steps_data(self,ids):
with engine.connect() as conn:
stmt = self.abstracts.select().where(self.abstracts.c.abs_id.in_([ids]))
result = conn.execute(stmt).first()
conn.close()
return dict(result._mapping) if result else None
def steps_2_data(self,ids):
with engine.connect() as conn:
stmt = text('select ab.abs_id,abs_type,abs_no,title,synopsis,abs_status_id,resume,methods,results,file_name,path from abstracts ab left join abs_uploads abu on ab.abs_id = abu.abs_id where ab.abs_id = {} '.format(ids))
result = conn.execute(stmt).all()
conn.close()
return [dict(r._mapping) for r in result] if result else None
def check_abs_id(self,abs_id):
with engine.connect() as conn:
stmt=text("select count(*) as check_abs_id from abstracts where abs_id ={};".format(abs_id))
result=conn.execute(stmt).first()
conn.close()
return dict(result._mapping) if result else None
def update_step(self,data,abs_id):
with engine.connect() as conn:
stmt = self.abstracts.update().values(data).where(self.abstracts.c.abs_id.in_([abs_id]))
result = conn.execute(stmt)
conn.commit()
conn.close()
return None
def get_search_data_presenting(self,user_type,role_id,search,abs_type,society_id):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_search_coi_v1",[user_type,role_id,search,abs_type,society_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()
connection.close()
if results :
return results
else :
return None
def get_search_data(self,search,role_id,abs_type,society_id):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_search_coi_v1",[None,role_id,search,abs_type,society_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()
connection.close()
if results :
return results
else :
return None
def get_search_session_judges(self,search,society_id,conf_id):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_search_session_judges",[search,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()
connection.close()
if results :
return results
else :
return None
def get_search_data_bo(self,search,role_id,abs_type,society_id):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_search_bo",[None,role_id,search,abs_type,society_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()
connection.close()
if results :
return results
else :
return None
def get_abs_types_for_participate_role_counts(self,conf_id):
with engine.connect() as conn:
stmt = text(f'select a.abs_type,t.title from abstracts a left join abs_types t on a.abs_type = t.abs_type where a.conf_id = {conf_id} and a.abs_type not in ("FT","CP") group by a.abs_type;')
result = conn.execute(stmt).all()
conn.close()
return [dict(r._mapping) for r in result] if result else None
def usp_get_participate_role_counts(self,conf_id,search,abs_type,abs_status):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_get_podium_presence_counts",[conf_id,search,abs_type,abs_status])
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
def get_ratified_member_count(self,abs_id):
with engine.connect() as conn:
# and membership_no <= 27309
stmt = text("select count(*) as ratified_count from abs_topics ab inner join users u on ab.user_id = u.user_id where abs_id = {} and member_type_id in (1,6) and user_society = 'AIOS';".format(abs_id))
result = conn.execute(stmt).first()
results = dict(result._mapping) if result else None
conn.close()
return results["ratified_count"]
def get_category_by_id(self,ids):
with engine.connect() as conn:
stmt = text("select display_name from abs_categories where category_id={}".format(ids))
result = conn.execute(stmt).first()
results = dict(result._mapping) if result else None
conn.close()
return results["display_name"]
def get_presentation_type(self,ids):
with engine.connect() as conn:
stmt = text("select type from abs_presentation_type where presentation_type_id = {}".format(ids))
result = conn.execute(stmt).first()
results = dict(result._mapping) if result else None
conn.close()
return results["type"]
def get_user_data(self,user_id):
with engine.connect() as conn:
stmt = text("select * from users where user_id = {}".format(user_id))
result = conn.execute(stmt).first()
conn.close()
return dict(result._mapping) if result else None
def get_consent_count_email(self,topic_id):
with engine.connect() as conn:
stmt1 = text("select user_id from abs_topics where topic_id = {}".format(topic_id))
result = conn.execute(stmt1).first()
results = dict(result._mapping) if result else None
user_id = results["user_id"]
stmt = text("select count(distinct(abs_id))as consent_count from abs_topics where user_id={} and abs_id not in (select distinct(abs_id) from abstracts where user_id = {} ) and consent_status_id = 2 and role_id = 33 ;".format(user_id,user_id))
result = conn.execute(stmt).first()
results = dict(result._mapping) if result else None
conn.close()
return results["consent_count"]
def check_coi_count(self,abs_id):
with engine.connect() as conn:
stmt = text(" select count(distinct user_id) as coi_count from abs_topics where abs_id = {};".format(abs_id))
result = conn.execute(stmt).first()
results = dict(result._mapping) if result else None
conn.close()
return results["coi_count"]
def check_fp_PA_count(self,user_id):
with engine.connect() as conn:
stmt = text("select count(*) as PA_count from abs_topics where user_id = {} and role_id = 35".format(user_id))
result = conn.execute(stmt).first()
results = dict(result._mapping) if result else None
conn.close()
return results["PA_count"]
def get_date_config(self):
with engine.connect() as conn:
stmt = text("select * from sa_abs_types where is_visible = 1 and is_abs = 1;")
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
conn.close()
return results
def get_abstract_home(self,user_id,abs_type):
sets = []
try:
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_sa_abstract_home",[user_id,abs_type])
while 1:
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
if cursor.description is None:
break
finally:
connection.close()
return sets
def get_abstract_home_v1(self,user_id,abs_type,confe_id):
sets = []
try:
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_abstract_home_v1",[user_id,abs_type,confe_id])
while 1:
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
if cursor.description is None:
break
finally:
connection.close()
return sets
def get_next_previous_data_eva(self,abs_id,user_id,eva_abs_type):
sets = []
try:
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_next_previous_eva_v1",[abs_id,user_id,eva_abs_type])
while 1:
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
if cursor.description is None:
break
finally:
connection.close()
return sets
def get_guidelines(self,abs_type,conf_id):
with engine.connect() as conn:
stmt = text('select * from abs_settings where setting_key = "{}_guideline_html" and conf_id = {}'.format(abs_type,conf_id))
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
conn.close()
return results
def dashboard_content(self,user_id):
with engine.connect() as conn:
stmt = text(f"""select abt.abs_type,abt.abs_icons,count(ab.abs_type)as abs_count,setting_value as total_count,abt.title,abt.start_date,abt.end_date,abs_type_url,abs_description
from sa_abs_types abt
left join sa_abstracts ab on abt.abs_type = ab.abs_type and ab.user_id = {user_id} and abs_status_id >= 1
left join sa_settings abset on concat(abt.abs_type,"_count") = abset.setting_key
where abt.is_visible = 1 and is_abs = 1 or abt.user_id = {user_id}
group by abt.abs_type order by abt.order_by;""")
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
conn.close()
return results
def get_daily_report(self,date,conf_id):
sets = []
try:
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_get_abs_trigger_day_reports",[date,conf_id])
while 1:
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
if cursor.description is None:
break
finally:
connection.close()
return sets
def check_abs_types(self,now_date,conf_id):
with engine.connect() as conn:
stmt = text(f'select * from abs_types where conf_id = {conf_id} and is_abs = 1 and "{now_date.strftime("%Y-%m-%d")}" between start_date and end_date ;')
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
conn.close()
return results
def check_eva_abs_types(self,now_date,conf_id):
with engine.connect() as conn:
stmt = text(f'select * from abs_types where conf_id = {conf_id} and abs_type like "%VAL%" and "{now_date.strftime("%Y-%m-%d")}" between start_date and end_date ;')
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
conn.close()
return results
def getAllConfForTriggerReport(self):
with engine.connect() as conn:
stmt = text("select * from m_app_type mat "+
" inner join society_applications sa on sa.app_type_id=mat.app_type_id"+
" inner join conference c on c.conf_id=sa.conf_id where mat.app_type_id=3 and sa.is_daily_report_mail=1")
result = conn.execute(stmt).all()
conn.close()
return [dict(r._mapping) for r in result] if result else None
def get_trigger_report_emails_data(self):
with engine.connect() as conn:
stmt = text("select group_concat(c.conf_id) as conf_id,group_concat(c.conf_key) as conf_key,t.full_name,t.email,t.is_separate_mail from trigger_daily_reports_mails t inner join society_applications s on t.conf_id = s.conf_id and s.app_type_id=3 inner join conference c on s.conf_id = c.conf_id where t.is_abs = 1 and t.is_active = 1 and s.is_daily_report_mail = 1 group by t.email,t.is_separate_mail")
result = conn.execute(stmt).all()
conn.close()
return [dict(r._mapping) for r in result] if result else None
def get_abstract_data(self,conf_id,abs_no,abs_type):
sets = []
try:
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_abstract_view",[conf_id,abs_no,abs_type])
while 1:
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
if cursor.description is None:
break
finally:
connection.close()
return sets
def get_commitment_data_search(self,conf_id,search_word):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_get_commiment_users_search_public",[conf_id,search_word])
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
def get_mail_templates(self,template_name):
with engine.connect() as conn:
stmt = text(f"SELECT * FROM mail_templates where template_name = '{template_name}' and find_in_set(4,conf_ids) and app_type_id=3 and is_active=1;")
result = conn.execute(stmt).first()
conn.close()
# result = dict(result._mapping) if result else None
return result
def get_daily_mail_templates(self,template_name):
with engine.connect() as conn:
stmt = text(f"SELECT * FROM mail_templates where template_name = '{template_name}' and app_type_id=3 and is_active=1;")
result = conn.execute(stmt).first()
conn.close()
# result = dict(result._mapping) if result else None
return result
def get_template(self,template_name,conf_id):
with engine.connect() as conn:
stmt = text(f"SELECT * FROM abs_templates where template_name='{template_name}' and conf_id = {conf_id}")
result = conn.execute(stmt).first()
result = dict(result._mapping) if result else None
conn.close()
return result
# Harini for KSOS23
def get_search_data_presenting_v1(self,user_type,role_id,search,abs_type,abs_id,society_id):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_search_coi_v2",[user_type,role_id,search,abs_type,abs_id,society_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()
connection.close()
if results :
return results
else :
return None
def get_abs_awards(self,abs_type,conf_id):
with engine.connect() as conn:
stmt_2 = text("select * from abs_awards where is_active=1 and conf_id={} and abs_type='{}' order by order_no;".format(conf_id,abs_type))
result = conn.execute(stmt_2).all()
results = [dict(r._mapping) for r in result] if result else None
conn.close()
return results
def get_programsheet_data(self,conf_date,conf_id,user_id):
sets = []
try:
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_get_programsheet_data",[conf_id,conf_date,user_id])
while 1:
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
if cursor.description is None:
break
finally:
connection.close()
return sets
def get_session_view_data(self,session_id):
sets = []
try:
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_get_session_view_data",[session_id])
while 1:
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
if cursor.description is None:
break
finally:
connection.close()
return sets
#check email is already exist or not
def check_email(self,email,society_id):
with engine.connect() as conn:
stmt = self.users.select().where(self.users.c.email.in_([email])).where(self.users.c.user_society.in_(['AIOS'])).where(self.users.c.society_id.in_([society_id]))
conn.close()
return conn.execute(stmt).first()
#check mobile is already exist or not
def check_mobile(self,mobile,society_id):
with engine.connect() as conn:
stmt = text("select * from users where (mobile= :mobile or whatsapp_number=:mobile) and society_id=:society_id and user_society = 'AIOS';")
result = conn.execute(stmt.bindparams(mobile=mobile,society_id=society_id))
conn.close()
return result.first()
#count email is already exist or not
def count_email(self,user_id,email,society_id):
with engine.connect() as conn:
stmt = text("select count(*) from users where user_id <> :user_id and email= :email and society_id=:society_id and user_society = 'AIOS';")
result = conn.execute(stmt.bindparams(user_id=user_id,email=email,society_id=society_id))
results = result.first()
conn.close()
if results :
return results
else:
return None
def get_abstract_data_for_consent(self,abs_id,conf_id):
with engine.connect() as conn:
stmt = text(f"select a.abs_id,a.abs_type,a.abs_no,a.title,concat(ifnull(cu.prefix,''),ifnull(cu.full_name,'')) as chief_author ,concat(ifnull(u.prefix,''),ifnull(u.full_name,'')) as presenting_author from abstracts a inner join abs_topics t on a.abs_id = t.abs_id and role_id in (32,35) inner join users u on t.user_id = u.user_id inner join users cu on a.user_id = cu.user_id where conf_id = {conf_id} and abs_status_id = 2 and a.abs_id = {abs_id}; ")
result = conn.execute(stmt).first()
results = dict(result._mapping) if result else None
conn.close()
return results
def save_abstract_consent_responce(self,abs_id,consent_status,conf_id):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_save_podium_consent",[abs_id,conf_id,consent_status])
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
def get_settings_by_key(self,setting_key,conf_id):
with engine.connect() as conn:
stmt = text(f"select *,DATE_FORMAT(setting_value, '%d-%m-%Y') as last_date from abs_settings where conf_id = {conf_id} and setting_key = '{setting_key}'")
result = conn.execute(stmt).first()
results = dict(result._mapping) if result else None
return results
def save_hydepark_consent_responce(self,abs_id,conf_id):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_save_hydepark_consent",[abs_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()
connection.close()
if results :
return results
else :
return None
def get_ic_hangouts(self,conf_id):
with engine.connect() as conn:
stmt_2 = text(f"""select concat(abs_type,abs_no) as abstract_type,title,concat(ifnull(u.prefix,''),u.full_name) as fullname,au.path,au.file_name from abstracts a
inner join abs_topics t on a.abs_id = t.abs_id and role_id = 32
inner join users u on t.user_id = u.user_id
inner join abs_uploads au on a.abs_id = au.abs_id
where conf_id = {conf_id} and abs_type = "IC" and abs_status_id = 2 order by abs_no;""")
result = conn.execute(stmt_2).all()
results = [dict(r._mapping) for r in result] if result else None
conn.close()
return results
app.jinja_env.globals.update(UserModel=UserModel)
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists