Sindbad~EG File Manager
from flask import Flask, request, Blueprint, jsonify, redirect, url_for,flash, render_template,session,Response,jsonify,json
from core.model.BadgeMatrixModel import BadgeMatrixModel
from random import randint
from .. import Cryptography,Auth,RouteGroup,Helper,Custom
from core.library.email import EMAIL
import math
from datetime import timedelta,date,datetime
from flask import session, app
from os import listdir
import io
import csv
import ast
import requests,mandrill,json,math
import base64
import flask
from num2words import num2words
from werkzeug.utils import secure_filename
import boto3, botocore
from botocore.exceptions import ClientError
import webbrowser
import os #use for new instance of chrome
import urllib.parse
from io import BytesIO
import xlsxwriter
from xlsxwriter import Workbook
import xlwt
from collections import defaultdict
app = Blueprint('badge_matrix', __name__)
@app.route("/<int:conf_id>/<conf_key>/conf_badge_matrix" , methods=['GET','POST'])
@RouteGroup.conf_required
# @RouteGroup.bologin_required
def ConfBadgeMatrix(conf_id,conf_key):
conf = BadgeMatrixModel().get_conf(conf_id,conf_key)
if conf :
conf_schema = conf['conf_schema']
add_default_show = 0
if conf_schema != 'ref_number':
msg , status = update_role_id_for_delegate_number(conf_id,conf_key)
if status == 2 :
return msg
add_default_show = 0
get_data = BadgeMatrixModel().get_conf_badge_matrix(conf_id)
for index,value in enumerate(get_data):
if index == 0 :
badge_type = value[0]
if index == 1 :
check_badge_matrix_exist = value[0]
if index == 2 :
data = value
if data :
if data[0]['b_id'] and data[0]['b_id'] == None:
data = None
else :
data = data
if index == 3 :
badge_role_db = value
if index == 4 :
total_reg_count = value
if index == 5 :
m_badge_type = value
if index == 6 :
exist_data = value
max_end_no = 0
if index == 7 :
not_added_badge_type = value
if data :
is_add_new_record = 1
else :
is_add_new_record = 0
if badge_type['badge_type'] == "del_number":
if check_badge_matrix_exist['check_badge_matrix_exist'] is None :
add_default_show = 1
else :
add_default_show = 0
badge_type = badge_type['badge_type']
return render_template('badge_matrix/badge_matrix_index.html',str=str,conf=conf,conf_id=conf_id,conf_key= conf_key,is_add_new_record=is_add_new_record,data=data,badge_role=badge_role_db,m_badge_type=m_badge_type,add_default_show=add_default_show,max_end_no = max_end_no,not_added_badge_type=not_added_badge_type,badge_type=badge_type,exist_data=exist_data)
else :
return "Invalid URL"
def update_role_id_for_delegate_number(conf_id,conf_key):
conf = BadgeMatrixModel().get_conf(conf_id,conf_key)
if conf:
if conf['is_gen_number'] != 'ref_number':
conf_schema = conf['conf_schema']
is_gen_number = conf['is_gen_number']
now = datetime.now()
curr_dt = now.strftime("%Y-%m-%d %H:%M:%S")
check_role = BadgeMatrixModel().check_role_id_mapped_or_not(conf_id)
get_delegate_roles = BadgeMatrixModel().get_delegate_roles(conf_id,conf_schema)
if check_role is None:
if get_delegate_roles :
for r in get_delegate_roles :
role = r['role']
delegate_nos = r['delegate_nos']
if role :
data = {'b_role': role,'conf_id': conf_id,'created_at' : curr_dt}
b_role_id = BadgeMatrixModel().insertBadgeRole(data)
update_del_data = BadgeMatrixModel().update_delegate_role_id(conf_id,delegate_nos,curr_dt,is_gen_number,b_role_id,conf_schema,role)
else :
return 'failed',2
return 'success',1
else :
if get_delegate_roles :
for r in get_delegate_roles :
role = r['role']
delegate_nos = r['delegate_nos']
get_role = BadgeMatrixModel().get_role_by_name(conf_id,role)
if get_role :
b_role_id = get_role['b_role_id']
if get_role :
update_del_data = BadgeMatrixModel().update_delegate_role_id(conf_id,delegate_nos,curr_dt,is_gen_number,b_role_id,conf_schema,role)
else :
if role :
data = {'b_role': role,'conf_id': conf_id,'created_at' : curr_dt}
b_role_id = BadgeMatrixModel().insertBadgeRole(data)
update_del_data = BadgeMatrixModel().update_delegate_role_id(conf_id,delegate_nos,curr_dt,is_gen_number,b_role_id,conf_schema,role)
return 'success',1
return 'success',1
else :
return 'no conference',2
@app.route('/<int:conf_id>/<conf_key>/add_new_matrix',methods =["GET","POST"])
@RouteGroup.conf_required
# @RouteGroup.bologin_required
def AddNewMatrix(conf_id,conf_key):
try:
conf = BadgeMatrixModel().get_conf(conf_id,conf_key)
conf_schema = conf['conf_schema']
now = datetime.now()
curr_dt = now.strftime("%Y-%m-%d %H:%M:%S")
msg = ""
status = ""
post_type = request.values.get('post_type')
add_default_show = 0
if post_type == "get":
is_first_rec = request.values.get("is_first_rec")
if str(is_first_rec) == "first_record" :
is_add_new_record = 1
else :
is_add_new_record = 0
msg = "Add new matrix"
status = 1
elif post_type == "default":
get_del_data = BadgeMatrixModel().get_del_reg_count(conf_id,conf_schema)
badge_type = request.values.get('badge_type[]' or "EXISTING DELEGATE NUMBERS") or "EXISTING DELEGATE NUMBERS"
roles = request.values.getlist('select_role[]' or get_del_data['role_ids']) or get_del_data['role_ids']
if roles :
roles = (",".join(roles))
role_order_type = request.values.get('role_order_type' or "mixed") or "mixed"
start_no = request.values.get('start_no' or get_del_data['start_no']) or get_del_data['start_no']
end_no = request.values.get('end_no' or get_del_data['end_no']) or get_del_data['end_no']
is_view_spot_reg= request.values.get('is_view_spot_reg' or 0) or 0
allocation_badge_count = request.values.get('allocation_badge_count' or 0) or 0
is_add_new_record = 1
data = {'conf_id':conf_id,'is_existing_del_number':1,'badge_type':badge_type,'roles':roles,'start_no':start_no,'end_no':end_no,'role_order_type':role_order_type,'allocation_badge_count':allocation_badge_count,'is_view_spot_reg':is_view_spot_reg,'created_at':curr_dt}
badge_type_id = BadgeMatrixModel().insert_conf_badge_matrix(data)
update_del_data = BadgeMatrixModel().update_del_badge_type(conf_id,badge_type_id,conf_schema)
if badge_type_id and int(badge_type_id) > 0:
set_order_by = BadgeMatrixModel().update_role_order_by(conf_id,get_del_data['role_ids'])
msg = "Added Successfully"
status = 2
else:
msg = str(badge_type_id)
status = 3
elif post_type == "post":
is_add_new_record = 1
badge_type = request.values.get('badge_type[]' or None) or None
roles = request.values.getlist('select_role[]' or None) or None
if roles :
roles = (",".join(roles))
if roles != 0 :
roles = roles
else:
data = {'b_role': 'DELEGATE','conf_id': conf_id,'created_at' : curr_dt}
insert_role = BadgeMatrixModel().insertBadgeRole(data)
roles = insert_role
role_order_type = request.values.get('role_order_type' or None) or None
start_no = request.values.get('start_no' or None) or None
end_no = request.values.get('end_no' or None) or None
is_view_spot_reg= request.values.get('is_view_spot_reg' or 1) or 1
allocation_badge_count = request.values.get('allocation_badge_count' or None) or None
data = {'conf_id':conf_id,'badge_type':badge_type,'roles':roles,'start_no':start_no,'end_no':end_no,'role_order_type':role_order_type,'allocation_badge_count':allocation_badge_count,'is_view_spot_reg':is_view_spot_reg,'created_at':curr_dt}
insert_data = BadgeMatrixModel().insert_conf_badge_matrix(data)
if insert_data and int(insert_data) > 0:
if is_view_spot_reg == 1 :
set_order_by = BadgeMatrixModel().update_role_order_by(conf_id,roles)
msg = "Added Successfully"
status = 2
else:
msg = str(insert_data)
status = 3
html_data = get_badge_matrix_data(conf,conf_id,conf_key,is_add_new_record,add_default_show)
data = {"html_data" : html_data, "status" : status,"msg" : msg }
json_data = json.dumps(data,default=str)
return json_data
except Exception as e:
data = {"msg" : str(e) , "status" :401 }
json_data= json.dumps(data,default=str)
return json_data
return json.dumps(data,default = str)
@app.route('/<int:conf_id>/<conf_key>/update_matrix',methods =["GET","POST"])
@RouteGroup.conf_required
# @RouteGroup.bologin_required
def UpdateMatrix(conf_id,conf_key):
try:
conf = BadgeMatrixModel().get_conf(conf_id,conf_key)
now = datetime.now()
curr_dt = now.strftime("%Y-%m-%d %H:%M:%S")
msg = ""
status = ""
is_add_new_record = 1
b_id = request.values.get('b_id')
add_default_show = 0
if b_id and int(b_id) == 1 :
badge_type = request.values.get('badge_type' or None) or None
else:
badge_type = request.values.get('badge_type[]' or None) or None
allocation_badge_count = request.values.get('allocation_badge_count' or None) or None
roles = request.values.getlist('select_role[]' or None) or None
role_order_type = request.values.get('role_order_type' or None) or None
start_no = request.values.get('start_no' or None) or None
end_no = request.values.get('end_no' or None) or None
is_view_spot_reg = request.values.get('is_view_spot_reg' or 0) or 0
if roles :
roles = (",".join(roles))
data = {'badge_type':badge_type,'roles':roles,'start_no':start_no,'end_no':end_no,'role_order_type':role_order_type,'allocation_badge_count':allocation_badge_count,'is_view_spot_reg':is_view_spot_reg,'updated_at':curr_dt}
update_data = BadgeMatrixModel().update_conf_badge_matrix(b_id,data)
if update_data == "success":
if is_view_spot_reg == 1 :
set_order_by = BadgeMatrixModel().update_role_order_by(conf_id,roles)
msg = "Updated Successfully"
status = 2
else:
msg = str(update_data)
status = 3
html_data = get_badge_matrix_data(conf,conf_id,conf_key,is_add_new_record,add_default_show)
data = {"html_data" : html_data, "status" : status,"msg" : msg }
json_data = json.dumps(data,default=str)
return json_data
except Exception as e:
data = {"msg" : str(e) , "status" :401 }
json_data= json.dumps(data,default=str)
return json_data
return json.dumps(data,default = str)
@app.route('/<int:conf_id>/<conf_key>/cancel_new_conf_badge_matrix',methods =["GET","POST"])
@RouteGroup.conf_required
# @RouteGroup.bologin_required
def CancelNewConfBadgeMatrix(conf_id,conf_key):
try:
conf = BadgeMatrixModel().get_conf(conf_id,conf_key)
is_add_new_record = request.values.get('is_add_new_record')
add_default_show = request.values.get('add_default_show')
html_data = get_badge_matrix_data(conf,conf_id,conf_key,is_add_new_record,add_default_show)
data = {"html_data" : html_data, "status" : 1,"msg" : "" }
json_data = json.dumps(data,default=str)
return json_data
except Exception as e:
data = {"msg" : str(e) , "status" :401 }
json_data= json.dumps(data,default=str)
return json_data
return json.dumps(data,default = str)
@app.route('/<int:conf_id>/<conf_key>/get_del_reg_count',methods =["GET","POST"])
@RouteGroup.conf_required
# @RouteGroup.bologin_required
def GetDelRegCount(conf_id,conf_key):
try:
msg = ""
status = ""
conf = BadgeMatrixModel().get_conf(conf_id,conf_key)
conf_schema = conf['conf_schema']
roles = request.values.getlist('roles[]' or None) or None
if roles :
roles = (",".join(roles))
count = BadgeMatrixModel().get_role_wise_reg_count(conf_id,roles,conf_schema)
data = {'count':count['reg_count'],"msg":"Count fetched Successfully","status":1}
else :
data = {'count':0,"msg":"","status":2}
json_data = json.dumps(data,default=str)
return json_data
except Exception as e:
data = {"msg" : str(e) , "status" :401 }
json_data= json.dumps(data,default=str)
return json_data
return json.dumps(data,default = str)
@app.route('/check_start_end_del_number',methods =["GET","POST"])
def CheckStartEndDelNumber():
try:
msg = ""
status = ""
conf_id = request.values.get('conf_id' or None) or None
start_no = request.values.get('start_no' or None) or None
end_no = request.values.get('end_no' or None) or None
b_id = request.values.get('b_id' or None) or None
check_data = BadgeMatrixModel().check_start_end_del_number(conf_id,start_no,end_no,b_id)
for index,value in enumerate(check_data):
if index == 0 :
check_data_db = value[0]
if ((check_data_db['s_no_exist'] == None) and (check_data_db['e_no_exist'] == None)and (check_data_db['s_no_series'] == None)and (check_data_db['e_no_series'] == None) ):
data = {'check_data':check_data_db,"msg":"Allow","status":1}
else:
data = {'check_data':check_data_db,"msg":"Delegate Number already exists","status":2}
json_data = json.dumps(data,default=str)
return json_data
except Exception as e:
data = {"msg" : str(e) , "status" :401 }
json_data= json.dumps(data,default=str)
return json_data
return json.dumps(data,default = str)
@app.route('/<int:conf_id>/<conf_key>/view_delegate_record',methods =["GET","POST"])
@RouteGroup.conf_required
# @RouteGroup.bologin_required
def ViewDelegateRecord(conf_id,conf_key):
try:
msg = ""
status = ""
is_update = None
b_id = request.values.get('b_id' or None) or None
view_type = request.values.get('list_type' or None) or None
if b_id and int(b_id) > 0 :
data = BadgeMatrixModel().get_usp_del_delno_generate_v2(conf_id,None,b_id,view_type)
for index,value in enumerate(data):
if index == 0 :
rolewise_count = value
if index == 1 :
data_db = value
if data_db :
data_len = len(data_db)
html_data = render_template('badge_matrix/delegate_table.html',data=data_db,data_len=data_len,count=rolewise_count)
data = {'html_data':html_data,"msg":"success","status":1}
else :
data = {"msg":"No Data","status":2}
json_data = json.dumps(data,default=str)
return json_data
except Exception as e:
data = {"msg" : str(e) , "status" :401 }
json_data= json.dumps(data,default=str)
return json_data
return json.dumps(data,default = str)
@app.route('/<int:conf_id>/<conf_key>/generate_delegate_number',methods =["GET","POST"])
@RouteGroup.conf_required
# @RouteGroup.bologin_required
def GenerateDelegateNumber(conf_id,conf_key):
try:
conf = BadgeMatrixModel().get_conf(conf_id,conf_key)
conf_schema = conf['conf_schema']
now = datetime.now()
curr_dt = now.strftime("%Y-%m-%d %H:%M:%S")
view_type = "generated"
is_add_new_record = 1
add_default_show = 0
msg = ""
status = ""
b_id = request.values.get('b_id' or None) or None
is_update = request.values.get('is_update' or None) or None
is_spot = request.values.get('is_spot' or 0) or 0
is_update = int(is_update)
if b_id :
if is_update and int(is_update)==1:
badge_data = BadgeMatrixModel().get_usp_del_delno_generate_v2(conf_id,is_update,b_id,view_type)
msg = "Delegate number generated successfully"
status = 1
elif is_spot and int(is_spot) == 1 :
get_badge_data = BadgeMatrixModel().get_badge_data_by_id(conf_id,b_id)
start_no = get_badge_data['start_no']
end_no = get_badge_data['end_no']
delno_range = int(len(range(int(start_no),int(end_no))))
badge_limit = get_badge_data['allocation_badge_count']
badge_limit = int(badge_limit)
role = get_badge_data['b_role']
role_id = get_badge_data['b_role_id']
society_id = conf['society_id']
start_no = int(start_no) if start_no else start_no
end_no = int(end_no) if end_no else end_no
alloted_count = int(start_no) + int(badge_limit)
is_view_spot_reg = get_badge_data['is_view_spot_reg']
if end_no < start_no :
msg = "Please enter valid delegate number to insert. 'To' delegate number must be greater than 'From' delegate number"
status = 2
already_exists_data = BadgeMatrixModel().get_delegate_already_exists(start_no,end_no,conf_id,conf_schema)
if already_exists_data:
msg = "Delegate number "+str(start_no)+" to "+str(end_no) + " Records already exists";
status = 2
else:
insert_stmt = ""
list1 = []
count = start_no
for i in range(start_no, end_no+1):
list1.append(count)
count = count + 1
total_count = len(list1)
if int(badge_limit) > int(total_count) :
msg = "Allocated number is greater than "+str(start_no)+" to "+str(end_no) + " ";
status = 2
else :
count = 0
for i in range(start_no,alloted_count):
if int(count) <= int(badge_limit) :
if is_view_spot_reg and int(is_view_spot_reg) == 2 :
insert_stmt = "insert into "+str(conf_schema)+".delegates (delegate_no,conference_id,role,role_id,society_id,member_type_id,del_status_id,is_spot,inprogress_spot_reg,badge_type_id,created_at) values("+str(i)+","+str(conf_id) +",'" +str(role)+"',"+str(role_id)+","+str(society_id)+",2,10,1,1,"+str(b_id)+",'"+curr_dt+"');"
else :
insert_stmt = "insert into "+str(conf_schema)+".delegates (delegate_no,conference_id,role,role_id,society_id,member_type_id,del_status_id,is_spot,badge_type_id,created_at) values("+str(i)+","+str(conf_id) +",'" +str(role)+"',"+str(role_id)+","+str(society_id)+",2,10,1,"+str(b_id)+",'"+curr_dt+"');"
# print(insert_stmt)
count = int(count)+1
insert_records = BadgeMatrixModel().insert_update_delete_records(insert_stmt)
# insert_records = 'success'
if insert_records=="success":
update_data = {'del_no_gen_on':curr_dt,'updated_at':curr_dt}
update_conf_badge_matrix = BadgeMatrixModel().update_conf_badge_matrix(b_id,update_data)
msg = str(count) +" Records Inserted succesfully "
status = 1
else:
msg = insert_records
status = 2
else:
msg = "Failed to generate delegate number"
status = 2
html_data = get_badge_matrix_data(conf,conf_id,conf_key,is_add_new_record,add_default_show)
data = {"html_data":html_data,"msg":msg,"status":status}
else :
data = {"msg":"No Data","status":2}
json_data = json.dumps(data,default=str)
return json_data
except Exception as e:
data = {"msg" : str(e) , "status" :401 }
json_data= json.dumps(data,default=str)
return json_data
return json.dumps(data,default = str)
def get_badge_matrix_data(conf,conf_id,conf_key,is_add_new_record,add_default_show):
conf_schema = conf['conf_schema']
# if conf_schema != 'ref_number':
# msg , status = update_role_id_for_delegate_number(conf_id,conf_key)
# if status == 2 :
# return msg
get_data = BadgeMatrixModel().get_conf_badge_matrix(conf_id)
for index,value in enumerate(get_data):
if index == 0 :
badge_type = value[0]
if index == 1 :
check_badge_matrix_exist = value[0]
if index == 2 :
data = value
if data :
if data[0]['b_id'] and data[0]['b_id'] == None:
data = None
else :
data = data
if index == 3 :
badge_role_db = value
if index == 4 :
total_reg_count = value
if index == 5 :
m_badge_type = value
if index == 6 :
exist_data = value
max_end_no = 0
if index == 7 :
not_added_badge_type = value
if is_add_new_record is None and add_default_show is None :
if data :
is_add_new_record = 1
else :
is_add_new_record = 0
if badge_type['badge_type'] == "del_number":
if check_badge_matrix_exist['check_badge_matrix_exist'] is None :
add_default_show = 1
else :
add_default_show = 0
else:
is_add_new_record = is_add_new_record
add_default_show = add_default_show
badge_type = badge_type['badge_type']
if get_data :
html_data = render_template('badge_matrix/badge_matrix_table.html',str=str,conf=conf,conf_id=conf_id,conf_key= conf_key,data=data,is_add_new_record=is_add_new_record,badge_role=badge_role_db,total_reg_count=total_reg_count,m_badge_type=m_badge_type,add_default_show=add_default_show,max_end_no = max_end_no,not_added_badge_type=not_added_badge_type,badge_type=badge_type,exist_data=exist_data)
return html_data
else :
return "No-data"
@app.route('/check_max_del_no', methods = ["GET", "POST"])
def CheckMaxDelNo():
try:
conf_id = request.values.get('conf_id')
conf_key = request.values.get('conf_key')
conf = BadgeMatrixModel().get_conf(conf_id,conf_key)
conf_schema = conf['conf_schema']
max_del_no = BadgeMatrixModel().check_max_del_no(conf_id,conf_schema)
max_cbm_no = int(max_del_no['max_conf_del_no'])
max_del_no = int(max_del_no['max_del_no'])
if int(max_del_no) < int(max_cbm_no):
max_no = max_cbm_no
elif int(max_del_no) > int(max_cbm_no):
max_no = max_del_no
else:
max_no = max_del_no
data = {"max_del_no":max_no,"msg":"success","status":1}
json_data = json.dumps(data,default=str)
return json_data
except Exception as e:
data = {"msg" : str(e) , "status" :401 }
json_data= json.dumps(data,default=str)
return json_data
return json.dumps(data,default = str)
@app.route('/<int:conf_id>/<conf_key>/restore_delegate_details', methods = ["GET", "POST"])
@RouteGroup.conf_required
# @RouteGroup.bologin_required
def RestoreDelegateTable(conf_id,conf_key):
try:
conf = BadgeMatrixModel().get_conf(conf_id,conf_key)
conf_schema = conf['conf_schema']
now = datetime.now()
curr_dt = now.strftime("%Y-%m-%d %H:%M:%S")
stmt = ""
is_add_new_record = 1
add_default_show = 0
if conf :
b_ids = request.values.get('b_ids')
get_matrix_data = BadgeMatrixModel().get_matrix_badge_data_by_ids(conf_id,b_ids)
if get_matrix_data:
for i in get_matrix_data:
stmt = ""
if int(i['is_view_spot_reg']) == 1 :
stmt = stmt + " delete from "+str(conf_schema)+".delegates where conference_id = "+str(conf_id)+" and delegate_no between "+i['start_no']+" and "+i['end_no']+";"
stmt2 = stmt + " update conf_badge_matrix set updated_at = '"+str(curr_dt)+"',del_no_gen_on= null where conf_id = "+str(conf_id)+" and b_id = "+str(i['b_id'])+" ;"
elif int(i['is_view_spot_reg']) == 0 :
stmt2 = stmt + " update "+str(conf_schema)+".delegates d inner join conf_badge_matrix c on c.conf_id = d.conference_id and c.b_id = d.badge_type_id set d.delegate_no= null,d.badge_type_id= null,c.del_no_gen_on= null,c.del_no_restore_on= '"+str(curr_dt)+"',c.updated_at= '"+str(curr_dt)+"' , d.updated_at= '"+str(curr_dt)+"' where d.delegate_no is not null and d.conference_id = "+str(conf_id)+" and d.badge_type_id = "+str(i['b_id'])+" ;"
else :
pass
reset_table = BadgeMatrixModel().insert_update_delete_records(stmt2)
html_data = get_badge_matrix_data(conf,conf_id,conf_key,is_add_new_record,add_default_show)
if reset_table == "success":
data = {"html_data":html_data,"msg":'Restored Successfully',"status":1}
else:
data = {"html_data":html_data,"msg":str(reset_table),'status':2}
json_data = json.dumps(data,default=str)
return json_data
except Exception as e:
data = {"msg" : str(e) , "status" :401 }
json_data= json.dumps(data,default=str)
return json_data
return json.dumps(data,default = str)
@app.route('/<int:conf_id>/<conf_key>/delete_conf_badge_matrix', methods = ["GET", "POST"])
@RouteGroup.conf_required
# @RouteGroup.bologin_required
def DeleteConfBadgeMatrix(conf_id,conf_key):
try:
conf = BadgeMatrixModel().get_conf(conf_id,conf_key)
now = datetime.now()
curr_dt = now.strftime("%Y-%m-%d %H:%M:%S")
stmt = ""
if conf :
b_id = request.values.get('b_id')
delete_data = BadgeMatrixModel().delete_conf_badge_matrix(b_id,conf_id)
if delete_data is None :
is_add_new_record = 0
add_default_show = 0
else:
is_add_new_record = 1
add_default_show = 0
html_data = get_badge_matrix_data(conf,conf_id,conf_key,is_add_new_record,add_default_show)
data = {"html_data":html_data,"msg":'Deleted Successfully',"status":1}
json_data = json.dumps(data,default=str)
return json_data
except Exception as e:
data = {"msg" : str(e) , "status" :401 }
json_data= json.dumps(data,default=str)
return json_data
return json.dumps(data,default = str)
@app.route('/<int:conf_id>/<conf_key>/save_all_conf_badge_matrix', methods = ["GET", "POST"])
@RouteGroup.conf_required
# @RouteGroup.bologin_required
def SaveAllConfBadgeMatrix(conf_id,conf_key):
try:
conf = BadgeMatrixModel().get_conf(conf_id,conf_key)
is_add_new_record = 1
add_default_show = 0
now = datetime.now()
curr_dt = now.strftime("%Y-%m-%d %H:%M:%S")
x = range(10)
get_values = ['b_id','start_no','end_no','badge_type','select_role','role_order_type','allocation_badge_count','is_view_spot_reg']
for n in x:
for j in get_values :
data = {}
if j == 'b_id' :
b_id = request.values.get('data['+str(n)+'][b_id]')
if b_id is not None:
start_no = request.values.get('data['+str(n)+'][start_no]')
end_no = request.values.get('data['+str(n)+'][end_no]')
badge_type = request.values.get('data['+str(n)+'][badge_type]')
select_role = request.values.get('data['+str(n)+'][select_role]')
role_order_type = request.values.get('data['+str(n)+'][role_order_type]')
allocation_badge_count = request.values.get('data['+str(n)+'][allocation_badge_count]')
is_view_spot_reg = request.values.get('data['+str(n)+'][is_view_spot_reg]')
if start_no :
data['start_no'] = start_no
if end_no :
data['end_no']= end_no
if badge_type :
data['badge_type']= badge_type
if select_role :
data['roles']= select_role
if role_order_type :
data['role_order_type']= role_order_type
if allocation_badge_count :
data['allocation_badge_count']= allocation_badge_count
if is_view_spot_reg :
data['is_view_spot_reg']= is_view_spot_reg
else:
pass
if b_id :
if b_id == 'new' :
data['created_at'] = curr_dt
data['conf_id'] = conf_id
insert_new_data = BadgeMatrixModel().insert_conf_badge_matrix(data)
else :
data['updated_at'] = curr_dt
update_all_data = BadgeMatrixModel().update_conf_badge_matrix(b_id,data)
else:
pass
html_data = get_badge_matrix_data(conf,conf_id,conf_key,is_add_new_record,add_default_show)
data = {"html_data":html_data,"msg":'Saved all successfully',"status":1}
json_data = json.dumps(data,default=str)
return json_data
except Exception as e:
data = {"msg" : str(e) , "status" :401 }
json_data= json.dumps(data,default=str)
return json_data
return json.dumps(data,default = str)
@app.route('/<int:conf_id>/<conf_key>/reset_delegate_details', methods = ["GET", "POST"])
@RouteGroup.conf_required
# @RouteGroup.bologin_required
def ResetDelegateTable(conf_id,conf_key):
try:
conf = BadgeMatrixModel().get_conf(conf_id,conf_key)
conf_schema = conf['conf_schema']
now = datetime.now()
curr_dt = now.strftime("%Y-%m-%d %H:%M:%S")
is_add_new_record = 1
add_default_show = 0
stmt = ""
if conf :
get_matrix_data = BadgeMatrixModel().get_matrix_badge_data(conf_id)
if get_matrix_data:
for i in get_matrix_data:
stmt = ""
if int(i['is_view_spot_reg']) == 1 :
stmt = stmt + " delete from "+str(conf_schema)+".delegates where conference_id = "+str(conf_id)+" and delegate_no between "+i['start_no']+" and "+i['end_no']+";"
stmt2 = stmt + " update conf_badge_matrix set updated_at = '"+str(curr_dt)+"',del_no_gen_on= null where conf_id = "+str(conf_id)+" and b_id = "+str(i['b_id'])+" ;"
elif int(i['is_view_spot_reg']) == 0 :
stmt2 = stmt + " update "+str(conf_schema)+".delegates d inner join conf_badge_matrix c on c.conf_id = d.conference_id and c.b_id = d.badge_type_id set d.delegate_no= null,d.badge_type_id= null,d.role_id= null,c.del_no_gen_on= null,c.updated_at= '"+str(curr_dt)+"' , d.updated_at= '"+str(curr_dt)+"' where d.delegate_no is not null and d.conference_id = "+str(conf_id)+" and d.badge_type_id = "+str(i['b_id'])+" ;"
else :
pass
reset_table = BadgeMatrixModel().insert_update_delete_records(stmt2)
if reset_table == "success":
# stmt = "Delete from conf_badge_matrix where conf_id = "+str(conf_id)+" ; "
# reset_table = BadgeMatrixModel().insert_update_delete_records(stmt1)
flash("Table reseted successfully","successMsg")
else:
flash(str(reset_table),"errorMsg")
return redirect(url_for('badge_matrix.ConfBadgeMatrix',conf_id=conf_id,conf_key=conf_key))
else :
return "Invalid URL"
except Exception as e:
return str(e)
@app.route('/<int:conf_id>/<conf_key>/get_check_existing_delegate_number', methods = ["GET", "POST"])
@RouteGroup.conf_required
# @RouteGroup.bologin_required
def GetCheckExistingDelegateNumber(conf_id,conf_key):
try:
conf = BadgeMatrixModel().get_conf(conf_id,conf_key)
conf_schema = conf['conf_schema']
now = datetime.now()
curr_dt = now.strftime("%Y-%m-%d %H:%M:%S")
if conf :
is_update_end_no = request.values.get('is_update_end_no' or 0) or 0
if int(is_update_end_no) == 1 :
b_id = request.values.get('b_id')
end_no = request.values.get('end_no')
update_data = {'end_no':end_no,"updated_at":curr_dt}
update_conf_badge_matrix = BadgeMatrixModel().update_conf_badge_matrix(b_id,update_data)
data = {'end_no':end_no,"msg":"Updated Successfully","status":1}
else :
is_gen_number = conf['is_gen_number'] or "del_number"
if is_gen_number == 'del_number':
get_max_del_no = BadgeMatrixModel().get_max_del_no(conf_id,conf_schema)
b_id = get_max_del_no['b_id']
max_del_no = get_max_del_no['max_del_no']
end_no = get_max_del_no['end_no']
if int(end_no) < int(max_del_no) :
update_data = {'end_no':max_del_no,"updated_at":curr_dt}
update_conf_badge_matrix = BadgeMatrixModel().update_conf_badge_matrix(b_id,update_data)
get_max_del_no = BadgeMatrixModel().get_max_del_no(conf_id,conf_schema)
max_del_no = get_max_del_no['max_del_no']
end_no = get_max_del_no['end_no']
data = {"max_del_no":max_del_no,'end_no':end_no,"msg":"success","status":1}
else:
data = {"msg":"ref_number","status":2}
json_data = json.dumps(data,default=str)
return json_data
else :
data = {"msg":"Invalid URL","status":2}
json_data = json.dumps(data,default=str)
return json_data
except Exception as e:
data = {"msg" : str(e) , "status" :401 }
json_data= json.dumps(data,default=str)
return json_data
# Rolelist option start - ----------------------------------- ------------------
@app.route('/<int:conf_id>/<conf_key>/role_index', methods = ["GET", "POST"])
@RouteGroup.conf_required
# @RouteGroup.bologin_required
def RoleIndex(conf_id,conf_key):
try:
conf = BadgeMatrixModel().get_conf(conf_id,conf_key)
conf_schema = conf['conf_schema']
if conf :
get_role_data = BadgeMatrixModel().getRole(conf_id,conf_schema)
table_data = render_template('badge_matrix/role_index_table.html',data=get_role_data,conf_id= conf_id, conf_key =conf_key,conf=conf)
html_data = render_template('badge_matrix/role_index.html',conf_id= conf_id, conf_key =conf_key,table_data=table_data,conf_name=conf['conf_name'],conf=conf)
data = {"html_data":html_data,"msg":"success","status":1}
else :
data = {"html_data":'',"msg":"No Data","status":2}
json_data = json.dumps(data,default=str)
return json_data
except Exception as e:
data = {"msg" : str(e) , "status" :401 }
json_data= json.dumps(data,default=str)
return json_data
return json.dumps(data,default = str)
@app.route('/edit_role/<int:b_role_id>',methods = ["GET","POST"])
def EditRole(b_role_id):
try:
output = BadgeMatrixModel().getRole_id(b_role_id)
if output :
data = {"edit_data":output[0],"msg":"","status":1}
else :
data = {"edit_data":'',"msg":"","status":2}
json_data = json.dumps(data,default=str)
return json_data
except Exception as e:
data = {"msg" : str(e) , "status" :401 }
json_data= json.dumps(data,default=str)
return json_data
return json.dumps(data,default = str)
@app.route('/<int:conf_id>/<conf_key>/delete_role/<int:b_role_id>' ,methods = ["GET","POST"])
def DeleteRole(conf_id,conf_key,b_role_id):
try:
conf = BadgeMatrixModel().get_conf(conf_id,conf_key)
conf_schema = conf['conf_schema']
output = BadgeMatrixModel().deleteBadgeRole(b_role_id)
get_role_data = BadgeMatrixModel().getRole(conf_id,conf_schema)
table_data = render_template('badge_matrix/role_index_table.html',data=get_role_data,conf_id= conf_id, conf_key =conf_key)
html_data = render_template('badge_matrix/role_index.html',conf_id= conf_id, conf_key =conf_key,table_data=table_data)
data = {"html_data":html_data,"msg":"Deleted Successfully","status":1}
json_data = json.dumps(data,default=str)
return json_data
except Exception as e:
data = {"msg" : str(e) , "status" :401 }
json_data= json.dumps(data,default=str)
return json_data
return json.dumps(data,default = str)
@app.route('/<int:conf_id>/<conf_key>/post_add_role',methods = ["GET","POST"])
def PostAddRole(conf_key,conf_id):
try:
conf = BadgeMatrixModel().get_conf(conf_id,conf_key)
conf_schema = conf['conf_schema']
now = datetime.now()
curr_dt = now.strftime("%Y-%m-%d %H:%M:%S")
msg = ""
status = ""
print(request.values)
role = request.values.get("role")
b_role_id = request.values.get("b_role_id")
is_display_at_spot = request.values.get("is_display_at_spot")
is_update = request.values.get("is_update")
if is_update and int(is_update) == 1 :
data = {'b_role' : role,"is_display_at_spot":is_display_at_spot,'updated_at' : curr_dt}
output = BadgeMatrixModel().updateBadgeRole(b_role_id,data)
if output == "success":
msg = "Updated Successfully !"
status = 1
else:
msg = str(output)
status = 2
else:
data = {'b_role': role,"is_display_at_spot":is_display_at_spot,'conf_id': conf_id,'created_at' : curr_dt}
insert_role = BadgeMatrixModel().insertBadgeRole(data)
if insert_role :
msg = "Added Successfully !"
status = 1
else:
msg = str(insert_role)
status = 2
get_role_data = BadgeMatrixModel().getRole(conf_id,conf_schema)
table_data = render_template('badge_matrix/role_index_table.html',data=get_role_data,conf_id= conf_id, conf_key =conf_key)
html_data = render_template('badge_matrix/role_index.html',conf_id= conf_id, conf_key =conf_key,table_data=table_data,conf_name=conf['conf_name'],conf=conf)
data = {"html_data":html_data,"msg":msg,"status":status}
json_data = json.dumps(data,default=str)
return json_data
except Exception as e:
data = {"msg" : str(e) , "status" :401 }
json_data= json.dumps(data,default=str)
return json_data
return json.dumps(data,default = str)
@app.route('/<int:conf_id>/<conf_key>/role_changes', methods = ["GET", "POST"])
@RouteGroup.conf_required
# @RouteGroup.bologin_required
def RoleChanges(conf_id,conf_key):
try:
conf = BadgeMatrixModel().get_conf(conf_id,conf_key)
if conf :
role = BadgeMatrixModel().get_role_ids(conf_id)
data = {"role":role,"msg":"","status":1}
else :
data = {"html_data":'',"msg":"No Data","status":2}
json_data = json.dumps(data,default=str)
return json_data
except Exception as e:
data = {"msg" : str(e) , "status" :401 }
json_data= json.dumps(data,default=str)
return json_data
return json.dumps(data,default = str)
# Rolelist option end ------------------ ------------------
# Role update option start ------------------ ------------------
@app.route('/<int:conf_id>/<conf_key>/role_update_form', methods = ["GET", "POST"])
@RouteGroup.conf_required
# @RouteGroup.bologin_required
def RoleUpdateForm(conf_id,conf_key):
try:
conf = BadgeMatrixModel().get_conf(conf_id,conf_key)
conf_schema = conf['conf_schema']
if conf :
role = BadgeMatrixModel().getRole(conf_id,conf_schema)
user_types=BadgeMatrixModel().get_conf_user_types(conf_id)
html_data = render_template('badge_matrix/role_update_form.html',conf_id= conf_id, conf_key =conf_key,conf=conf,role=role,user_types=user_types)
data = {"html_data":html_data,"msg":"","status":1}
else :
data = {"html_data":'',"msg":"No Data","status":2}
json_data = json.dumps(data,default=str)
return json_data
except Exception as e:
data = {"msg" : str(e) , "status" :401 }
json_data= json.dumps(data,default=str)
return json_data
return json.dumps(data,default = str)
@app.route("/<int:conf_id>/<conf_key>/get_dele_nos" , methods=['GET','POST'])
@RouteGroup.conf_required
# @RouteGroup.bologin_required
def GetDeleNos(conf_id,conf_key):
try:
conf = BadgeMatrixModel().get_conf(conf_id,conf_key)
is_gen_number = conf['is_gen_number']
delegate_nos = request.values.get('delegate_nos',None)
is_role_condition = request.values.get('is_role_condition') or None # 1 0r 0
role_condition = request.values.get('role_condition') or None # not_in / in / null
is_badge_role = request.values.get('is_badge_role') or None # 1 / 0
is_role_update = request.values.get('is_role_update') or None # 1 / 0
role_ids = request.values.getlist('role_ids[]') or None
if role_ids :
role_ids = (",".join(role_ids))
reg_type_id = request.values.get('reg_type_id',None) or None
if reg_type_id :
get_data = BadgeMatrixModel().get_delegate_no_by_reg_type(conf_id,conf.get('conf_schema'),is_gen_number,reg_type_id)
delegate_nos = ','.join(str(item['delegate_nos']) for item in get_data)
else :
delegate_nos = delegate_nos
if delegate_nos:
delegate_nos,from_del_no,to_del_no = conv_dele_no(delegate_nos)
else:
text_placeholder = None
delegate_nos,from_del_no,to_del_no = None,None,None
get_data = BadgeMatrixModel().get_delegate_details_by_del_nos(delegate_nos,from_del_no,to_del_no,conf_id,is_role_condition,role_condition,role_ids,is_badge_role,is_role_update)
for index,value in enumerate(get_data):
if index == 0:
data = value
if index == 1:
role_not_updated_count = value[0]
if index == 2:
role_updated_count = value[0]
html = render_template('badge_matrix/role_update_table.html',data=data,conf=conf,conf_id=conf_id,conf_key= conf_key)
if html:
data ={ 'msg':'','status':1,'html_data':html,'delegate_nos':delegate_nos,'role_not_updated_count':role_not_updated_count['role_not_updated'],'role_updated_count':role_updated_count['role_updated']}
else:
data ={ 'msg':'Data not found','status':0,'data':'','delegate_nos':delegate_nos,'role_not_updated_count':role_not_updated_count['role_not_updated'],'role_updated_count':role_updated_count['role_updated']}
json_data = json.dumps(data,default=str)
return json_data
except Exception as e:
data = {"msg" : str(e) , "status" :401 }
json_data= json.dumps(data,default=str)
return json_data
return json.dumps(data,default = str)
@app.route("/<int:conf_id>/<conf_key>/update_delegate_role" , methods=['GET','POST'])
@RouteGroup.conf_required
# @RouteGroup.bologin_required
def UpdateDelegateRole(conf_id,conf_key):
conf = BadgeMatrixModel().get_conf(conf_id,conf_key)
conf_schema = conf['conf_schema']
now = datetime.now()
dt_string = now.strftime("%Y-%m-%d %H:%M:%S")
delegate_nos = request.values.get('delegate_nos',None)
update_only_badge_role = request.values.get('update_only_badge_role')
updated_at = dt_string
is_gen_number = conf['is_gen_number']
is_role_condition = request.values.get('is_role_condition') or None # 1 0r 0
role_condition = request.values.get('role_condition') or None # not_in / in / null
is_badge_role = request.values.get('is_badge_role') or None # 1 / 0
is_role_update = request.values.get('is_role_update') or None # 1 / 0
role_ids = request.values.getlist('role_ids[]') or None
if role_ids :
role_ids = (",".join(role_ids))
if delegate_nos:
delegate_nos,from_del_no,to_del_no = conv_dele_no(delegate_nos)
else:
text_placeholder = None
delegate_nos,from_del_no,to_del_no = None,None,None
b_role_id = request.values.get('role',None) or None
if b_role_id:
role_data = BadgeMatrixModel().getRole_id(b_role_id)
role = role_data[0]['b_role']
if update_only_badge_role and int(update_only_badge_role) in [1] :
update = BadgeMatrixModel().update_delegate_role(conf_id,role,delegate_nos,updated_at,is_gen_number,b_role_id,conf_schema)
if update_only_badge_role and int(update_only_badge_role) in [1,2] :
request_data = request.values
structured_data = {}
for key, value in request_data.items():
keys = key.replace(']', '').split('[')
current = structured_data
for part in keys[:-1]:
current = current.setdefault(part, {})
current[keys[-1]] = value
# Extract dele_ids
dele_ids = [
item['value'] for item in structured_data.get('update_data', {}).values()
if item.get('name') == 'dele_ids'
]
if dele_ids:
update_stmt = ''
for i in dele_ids:
get_value = 'badge_role_'+str(i)
is_onchange= 'is_onchange_'+str(i)
get_values = [
item['value'] for item in structured_data.get('update_data', {}).values()
if item.get('name') == str(get_value)
]
get_is_onchange_values = [
item['value'] for item in structured_data.get('update_data', {}).values()
if item.get('name') == str(is_onchange)
]
if get_values[0] and int(get_is_onchange_values[0]) == 1:
update_stmt = update_stmt + " update "+str(conf_schema)+".delegates set badge_role = '"+str(get_values[0])+"' ,updated_at = '"+str(dt_string)+"' where delegate_id = "+str(i)+" and conference_id = "+str(conf_id)+"; "
elif get_values[0] =='' and int(get_is_onchange_values[0]) == 1:
update_stmt = update_stmt + " update "+str(conf_schema)+".delegates set badge_role = NULL where delegate_id = "+str(i)+" and conference_id = "+str(conf_id)+"; "
if update_stmt :
update_ = BadgeMatrixModel().common_update_query(update_stmt)
get_data = BadgeMatrixModel().get_delegate_details_by_del_nos(delegate_nos,from_del_no,to_del_no,conf_id,is_role_condition,role_condition,role_ids,is_badge_role,is_role_update)
for index,value in enumerate(get_data):
if index == 0:
data = value
if index == 1:
role_not_updated_count = value[0]
if index == 2:
role_updated_count = value[0]
html = render_template('badge_matrix/role_update_table.html',data=data,conf=conf,conf_id=conf_id,conf_key= conf_key)
data ={ 'msg':"Updated Successfully..",'status':1,'html':html,'role_not_updated_count':role_not_updated_count['role_not_updated'],'role_updated_count':role_updated_count['role_updated']}
return jsonify(data)
def conv_dele_no(value):
delegate_nos = None
from_del_no = None
to_del_no = None
if ',' in value or len(value) == 1 :
delegate_nos = value
elif '-' in value:
result = value.split('-')
if result and len(result)>0:
from_del_no = result[0] if result[0] else None
to_del_no = result[1] if result[1] else None
else:
delegate_nos = value
return delegate_nos,from_del_no,to_del_no
# Role update option end ------------------ ------------------
@app.route("/<int:conf_id>/<conf_key>/total_role_wise_count" , methods=['GET','POST'])
@RouteGroup.conf_required
# @RouteGroup.bologin_required
def TotalRoleWiseCount(conf_id,conf_key):
try:
conf = BadgeMatrixModel().get_conf(conf_id,conf_key)
conf_schema = conf['conf_schema']
data = BadgeMatrixModel().get_rolewise_count(conf_id,conf_schema)
data_list = []
other_list = []
spot_data_list = []
for r in data:
if int(r["del_status_id"]) == 2 :
data_list.append(r)
elif int(r["del_status_id"]) == 10 :
spot_data_list.append(r)
else :
other_list.append(r)
html = render_template('badge_matrix/rolewise_count_table.html',data=data_list,conf=conf,conf_id=conf_id,conf_key= conf_key,other_list=other_list,spot_data_list=spot_data_list)
data = { 'msg':'','status':1,'html_data':html} if data else { 'msg':'Data not found','status':0,'data':'','html_data':html}
json_data = json.dumps(data,default=str)
return json_data
except Exception as e:
data = {"msg" : str(e) , "status" :401 }
json_data= json.dumps(data,default=str)
return json_data
return json.dumps(data,default = str)
@app.route("/<int:conf_id>/<conf_key>/view_extra_spot_record" , methods=['GET','POST'])
@RouteGroup.conf_required
# @RouteGroup.bologin_required
def ViewExtraSpotRecord(conf_id,conf_key):
try:
conf = BadgeMatrixModel().get_conf(conf_id,conf_key)
conf_schema = conf['conf_schema']
b_id = request.values.get('b_id')
max_del_no = BadgeMatrixModel().get_badge_spot_data(conf_id,b_id,conf_schema)
cbm_data = BadgeMatrixModel().get_cbm_data(conf_id,b_id)
html = render_template('badge_matrix/insert_extra_spot_delno_form.html',max_del_no=max_del_no,cbm_data=cbm_data,conf=conf,conf_id=conf_id,conf_key= conf_key)
data = { 'msg':'','status':1,'html_data':html} if cbm_data else { 'msg':'Data not found','status':0,'data':'','html_data':html}
json_data = json.dumps(data,default=str)
return json_data
except Exception as e:
data = {"msg" : str(e) , "status" :401 }
json_data= json.dumps(data,default=str)
return json_data
return json.dumps(data,default = str)
@app.route("/<int:conf_id>/<conf_key>/insert_extra_spot_record" , methods=['GET','POST'])
@RouteGroup.conf_required
# @RouteGroup.bologin_required
def InsertExtraSpotRecord(conf_id,conf_key):
try:
conf = BadgeMatrixModel().get_conf(conf_id,conf_key)
conf_schema = conf['conf_schema']
now = datetime.now()
curr_dt = now.strftime("%Y-%m-%d %H:%M:%S")
b_id = request.values.get('b_id')
extra_count = request.values.get('extra_count')
max_del_no = BadgeMatrixModel().get_badge_spot_data(conf_id,b_id,conf_schema)
cbm_data = BadgeMatrixModel().get_badge_data_by_id(conf_id,b_id)
start_no = max_del_no['max_del_no'] + 1
end_no = cbm_data['end_no']
delno_range = int(len(range(int(start_no),int(end_no))))
role = cbm_data['b_role']
role_id = cbm_data['b_role_id']
society_id = conf['society_id']
start_no = int(start_no) if start_no else start_no
end_no = int(end_no) if end_no else end_no
alloted_count = int(start_no) + int(extra_count)
is_view_spot_reg = cbm_data['is_view_spot_reg']
insert_stmt = ""
list1 = []
count = start_no
for i in range(start_no, end_no+1):
list1.append(count)
count = count + 1
total_count = len(list1)
if int(extra_count) > int(total_count) :
msg = "Enter a number lesser than "+str(total_count)+" or Enter "+str(total_count)+" ";
status = 2
else :
count = 0
for i in range(start_no,alloted_count):
if int(count) <= int(extra_count) :
if is_view_spot_reg and int(is_view_spot_reg) ==2 :
insert_stmt = "insert into "+str(conf_schema)+".delegates (delegate_no,conference_id,role,role_id,society_id,member_type_id,del_status_id,is_spot,badge_type_id,inprogress_spot_reg,created_at) values("+str(i)+","+str(conf_id) +",'" +str(role)+"',"+str(role_id)+","+str(society_id)+",2,10,1,1,"+str(b_id)+",'"+curr_dt+"');"
else :
insert_stmt = "insert into "+str(conf_schema)+".delegates (delegate_no,conference_id,role,role_id,society_id,member_type_id,del_status_id,is_spot,badge_type_id,created_at) values("+str(i)+","+str(conf_id) +",'" +str(role)+"',"+str(role_id)+","+str(society_id)+",2,10,1,"+str(b_id)+",'"+curr_dt+"');"
# print(insert_stmt)
count = int(count)+1
insert_records = BadgeMatrixModel().insert_update_delete_records(insert_stmt)
# insert_records = "success"
if insert_records=="success":
update_data = {'del_no_gen_on':curr_dt,'updated_at':curr_dt}
update_conf_badge_matrix = BadgeMatrixModel().update_conf_badge_matrix(b_id,update_data)
msg = str(count) +" Records Inserted succesfully "
status = 1
else:
msg = insert_records
status = 2
is_add_new_record = 1
add_default_show = 0
html_data = get_badge_matrix_data(conf,conf_id,conf_key,is_add_new_record,add_default_show)
data = {"html_data":html_data,"msg":msg,"status":status}
json_data = json.dumps(data,default=str)
return json_data
except Exception as e:
data = {"msg" : str(e) , "status" :401 }
json_data= json.dumps(data,default=str)
return json_data
return json.dumps(data,default = str)
# commitment generate and update created by Aravinth 17.11.2023 17:30 Recreated by Ramya on 2025-01-09
@app.route('/<int:conf_id>/<conf_key>/view_commitment',methods=["GET"])
@RouteGroup.conf_required
def ViewCommitment(conf_id,conf_key):
conf = BadgeMatrixModel().get_conf(conf_id,conf_key)
if conf:
data,overall_count,status,update_status = compare_user_and_del_data(conf_id,conf_key,None,None,None)
return render_template('badge_matrix/generate_commitment.html',conf_id=conf_id,conf_key=conf_key,conf=conf,overall_count=overall_count,data=data)
else:
return "<h4 style = 'color:red'; > Invalid URL </h4>"
def compare_user_and_del_data(conf_id,conf_key,is_update,update_type,delegate_ids):
update_status = None
status = None
getConfData = BadgeMatrixModel().get_conf(conf_id,conf_key)
get_data_gen_comm_count = BadgeMatrixModel().get_gen_comm_count(conf_id,is_update,update_type,delegate_ids)
for index,value in enumerate(get_data_gen_comm_count):
if index == 0:
all_no_userid_data = value
if index == 1:
email_match_data = value
if index == 2:
mobile_match_data = value
if index == 3:
membership_no_match_data = value
if index == 4:
overall_count = value[0]
if index == 5:
status = value[0]
if index == 6:
update_status = value[0]
all_data = render_template('badge_matrix/users_match_table.html',data=all_no_userid_data,conf=getConfData,conf_id=conf_id,conf_key= conf_key,data_type="all_data")
email_match_data = render_template('badge_matrix/users_match_table.html',data=email_match_data,conf=getConfData,conf_id=conf_id,conf_key= conf_key,data_type="email_match")
mobile_match_data = render_template('badge_matrix/users_match_table.html',data=mobile_match_data,conf=getConfData,conf_id=conf_id,conf_key= conf_key,data_type="mobile_match")
membership_no_match_data = render_template('badge_matrix/users_match_table.html',data=membership_no_match_data,conf=getConfData,conf_id=conf_id,conf_key= conf_key,data_type="membership_no_match")
data = {'all_match_data':all_data,'email_match_data':email_match_data,'mobile_match_data':mobile_match_data,'membership_no_match_data':membership_no_match_data}
return data,overall_count,status,update_status
@app.route('/<int:conf_id>/<conf_key>/generate_commitments',methods=["GET","POST"])
@RouteGroup.conf_required
def GenerateCommitments(conf_id,conf_key):
user_id = None
report_type = None
start_date = None
end_date = None
try:
getConfData = BadgeMatrixModel().get_conf(conf_id,conf_key)
if getConfData :
get_view_commitment = BadgeMatrixModel().getCommitment(user_id,report_type,start_date,end_date,conf_id)
for index,value in enumerate(get_view_commitment):
if index == 0:
all_details = value
if index == 1:
commitments_data = value
if commitments_data:
generate_total_count = "Generated Commitment Count : "+str(len(commitments_data))
else:
generate_total_count = None
data = {"generate_total_count" : generate_total_count ,"status" : 1 , "msg" : "Successfully Generated."}
return json.dumps(data,default=str)
else:
return "<h4 style= 'color:red' ; > Invalid URL </h4>"
except Exception as e:
data = {"generate_data" : "","msg" : str(e), "status" : 401}
return json.dumps(data,default=str)
@app.route('/<int:conf_id>/<conf_key>/update_commitment',methods = ["GET","POST"])
@RouteGroup.conf_required
def UpdateCommitment(conf_id,conf_key):
now = datetime.now()
current_dt = now.strftime("%Y-%m-%d %H:%M:%S")
count = 0
try:
getConfData = BadgeMatrixModel().get_conf(conf_id,conf_key)
if getConfData :
del_table_name = getConfData['conf_schema'] +".delegates"
update_commitment = BadgeMatrixModel().UpdateCommitments(conf_id,del_table_name,current_dt)
if update_commitment:
updated_total_commitment_count = "Updated Commitment Count : "+str(update_commitment['total_commitment_count'])
else:
updated_total_commitment_count = None
data = {"updated_total_commitment_count" : updated_total_commitment_count ,"status" : 1 , "msg" : "Successfully updated."}
return json.dumps(data,default=str)
else:
return "<h4 style= 'color:red' ; > Invalid URL </h4>"
except Exception as e:
data = {"update_data" : "","msg" : str(e), "status" : 401}
return json.dumps(data,default=str)
@app.route('/<int:conf_id>/<conf_key>/update_user_id_to_delegate',methods = ["GET","POST"])
@RouteGroup.conf_required
def UpdateUserIdtoDelegate(conf_id,conf_key):
try:
conf = BadgeMatrixModel().get_conf(conf_id,conf_key)
data_type = request.values.get('data_type')
delegate_ids= request.values.get('ids')
data,overall_count,status,update_status = compare_user_and_del_data(conf_id,conf_key,1,data_type,delegate_ids)
data = {"data":data,'overall_count':overall_count,"status" : 1 , "msg" : "success"}
return json.dumps(data,default=str)
except Exception as e:
data = {"html_data" : "","msg" : str(e), "status" : 401}
return json.dumps(data,default=str)
#end
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists