Sindbad~EG File Manager
from flask import session
from flask import request, Blueprint, jsonify
from sqlalchemy import create_engine, select, MetaData, Table,text
from sqlalchemy.sql import and_, or_
from core import app
from .. import engine
# engine = create_engine(app.config['DATABASE_URI'],pool_pre_ping=True,pool_recycle=3600)
class DashboardModel():
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.m_payment_type = Table("m_payment_type", 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.admin_logs = Table("admin_logs", self.meta, autoload_with=engine)
self.trigger_daily_reports_mails = Table("trigger_daily_reports_mails", self.meta, autoload_with=engine)
self.export_filter_cols = Table("export_filter_cols", self.meta, autoload_with=engine)
self.badge_role = Table("badge_role", 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.delegate_attachments = Table("delegate_attachments", self.meta, autoload_with=engine)
self.reg_remark = Table("reg_remark", self.meta, autoload_with=engine)
self.mail_logs = Table("mail_logs", self.meta, autoload_with=engine)
except Exception as e:
print(e)
def get_all_addons_count(self,conf_id):
with engine.connect() as conn:
stmt = text("select a.addon_id,ut.user_type,a.addon_name,sum(da.amount) as total_amount,da.amount,count(d.delegate_id) as total_count,ut.user_type_id from delegates d inner join delegates_addons da on da.delegate_id =d.delegate_id inner join user_payment u on da.unique_id = u.unique_id inner join addons a on a.addon_id = da.addon_id inner join user_types ut on ut.user_type_id = d.reg_type_id where d.conference_id = "+str(conf_id)+" and d.del_status_id = 2 group by a.addon_id, ut.user_type,a.addon_name ;")
result = conn.execute(stmt)
return [dict(r._mapping) for r in result] if result else None
def get_addons_group_by(self,conf_id):
with engine.connect() as conn:
stmt = text("select * from addons where conference_id = "+str(conf_id)+" group by reg_type ;")
result = conn.execute(stmt)
return [dict(r._mapping) for r in result] if result else None
def get_tariff_group_by(self,conf_id):
with engine.connect() as conn:
stmt = text("select * from addons where conference_id = "+str(conf_id)+" group by addon_name ;")
result = conn.execute(stmt)
return [dict(r._mapping) for r in result] if result else None
def get_dashboard_data(self,conf_id):
sets = []
try:
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_bo_dashboard",[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.close()
return sets
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists