Sindbad~EG File Manager
from flask import request, Blueprint, jsonify, redirect, url_for,flash, render_template,session,json,render_template_string,Response
from core.model.AbstractAdminModel import AbstractAdminModel
from .. import Cryptography,Helper,Auth,RouteGroup,floder_name,template_path,backoff_template,cpanel_api_url,cpanel_username,cpanel_password,cpanel_api_token,a2host_username,a2host_domain,a2host_api_token
from datetime import timedelta,date,datetime,time
import os,sys
from flask import make_response
from os.path import join, dirname, realpath
import ast
from collections import defaultdict
import math
from core import app
from core.library.helper import Helper
from core.library.email import EMAIL
from core.library.bravo import Bravo
import shutil
import glob
import uuid
import re
from urllib.parse import urlparse
import urllib.parse
import requests
from requests.auth import HTTPBasicAuth
app = Blueprint('abstract_admin', __name__)
# @app.route('/tes123')
# def Testdata():
# return "success"
# @app.route('/login')
# def Login():
# if Auth.check():
# return redirect(url_for('abstract_admin.IndexPage'))
# else:
# return render_template('abstract_templates/master_table_login.html')
# @app.route('/post_login')
# def PostLogin():
# username=request.values.get('username') or None
# password=request.values.get('password') or None
# if username=="admin" and password=="12345":
# data={'username':username,'password':password}
# Auth.login(data)
# return redirect(url_for('abstract_admin.IndexPage'))
# else:
# flash("Invalid username or password.." , "errorMsg")
# return redirect(url_for('abstract_admin.Login'))
# @app.route('/index')
# @app.route('/index/<society_id>')
# #@RouteGroup.login_required
# def IndexPage(society_id=None):
# get_conference = AbstractAdminModel().Get_Conference(society_id)
# get_new_conference = AbstractAdminModel().Get_new_conference(society_id)
# get_society = AbstractAdminModel().Get_Society()
# get_delegate_role = AbstractAdminModel().GetDeleRole()
# data = {'society_id':society_id}
# # print(data)
# return render_template('abstract_templates/index.html',get_conference=get_conference,get_new_conference=get_new_conference,get_society=get_society,data=data,get_delegate_role=get_delegate_role)
# #@RouteGroup.login_required
# @app.route('/index_page')
# def Index():
# society_id = request.values.get("society_id") or None
# get_conference = AbstractAdminModel().Get_Conference(society_id)
# get_new_conference = AbstractAdminModel().Get_new_conference(society_id)
# get_society = AbstractAdminModel().Get_Society()
# html_data = render_template('abstract_templates/filter_conf.html',get_conference=get_conference,get_new_conference=get_new_conference,get_society=get_society)
# data = {'html_data':html_data,"msg" : "success" ,"status" : 1 }
# json_data = json.dumps(data,default = str)
# return json_data
#@RouteGroup.login_required
@app.route('/abstract_app_list')
def AbstractAppList():
# user_mail = Auth.user().get('admin_email')
userdata = Auth.user()
if userdata and userdata['admin_email']:
apps = AbstractAdminModel().get_abstract_applications(userdata['admin_email'])
societies = AbstractAdminModel().get_societies()
count = AbstractAdminModel().get_abstract_status_count()
return render_template('abstract_templates/abs_app_list.html',apps=apps,societies=societies,count=count)
else:
return redirect(url_for("dashboard.AdminPanelLogin"))
# @app.route('/insert_new_user_data_by_society_id/<society_id>', methods = ["GET", "POST"])
# def insert_new_user_data_by_society_id(society_id):
# userdata = Auth.user()
# super_admin_email = userdata['admin_email']
# userdata = Auth.user()
# if userdata and userdata['admin_email']:
# insert_data = AbstractAdminModel().insert_new_user_data_by_society_id(super_admin_email,society_id) #add new user by society
# # get_user_uuid = AdminAccessModel().get_user_uuid(super_admin_email,society_id)
# user_uuid = insert_data['user_uuid']
# data_1 = {"user_uuid":user_uuid,"status" : 1 , "msg" : "Updated Successfully"}
# else:
# data_1 = {"user_uuid":"","status" : 2 , "msg" : "Updated Failed"}
# return json.dumps(data_1 ,default=str)
@app.route('/<conf_id>/<society_id>/application_config')
def AbstractAdmin(conf_id,society_id):
is_page=1
get_conference = AbstractAdminModel().GetConference(society_id,conf_id)
get_mail_setting_id = AbstractAdminModel().Get_Mail_Setting_id()
get_society_appl_data = AbstractAdminModel().Get_Society_App_Data(conf_id)
# get_mail_temp_name = AbstractAdminModel().GetMailTempName()
# return render_template('abstract_templates/master_table_form.html',conf_id=conf_id,society_id=society_id,get_society_appl_data=get_society_appl_data,get_mail_setting_id=get_mail_setting_id,get_conference=get_conference)
return render_template('abstract_templates/application_config.html',conf_id=conf_id,society_id=society_id,get_society_appl_data=get_society_appl_data,get_mail_setting_id=get_mail_setting_id,get_conference=get_conference,is_page=is_page)
@app.route('/<int:conf_id>/post_society_application',methods=["POST"])
def PostSocietyApplication(conf_id):
now = datetime.now()
current_dt = now.strftime("%Y-%m-%d %H:%M:%S")
app_title = request.values.get('app_title')
app_urls = request.values.get('app_url')
if app_urls:
app_url=app_urls
else:
app_url=request.values.get('default_app_url')
app_host =request.values.get("app_host")
society_id =request.values.get('society_id')
# is_autologin =request.values.get('is_autologin')
mail_setting_id =request.values.get('mail_setting_id')
soc_app_is_active =request.values.get('soc_app_is_active')
app_style =request.values.get('app_style')
data={
'app_type_id' :3,
'app_title' :app_title,
'app_url' :app_url,
'is_autologin' :1,
'society_id' :society_id,
'conf_id' :conf_id,
'is_active' :soc_app_is_active,
'created_at' :current_dt,
'mail_setting_id' :mail_setting_id,
'app_style' :app_style,
'app_host' :app_host
}
insert_society_app = AbstractAdminModel().Insert_Society_App(data)
flash("Successfully Inserted." , "successMsg")
data = {"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
#@RouteGroup.login_required
@app.route('/<int:conf_id>/<int:society_id>/abs_type')
def AbsType(conf_id,society_id):
is_page = 2
now = datetime.now()
current_dt = now.strftime("%Y-%m-%d %H:%M:%S")
get_conference = AbstractAdminModel().GetConference(society_id,conf_id)
get_abs_type = AbstractAdminModel().Get_Abs_Types(conf_id)
Get_All_Abs_Types = AbstractAdminModel().Get_All_Abs_Types(conf_id)
get_guideline = AbstractAdminModel().GetGuideline(conf_id)
# get_society_appl_data = AbstractAdminModel().Get_Society_App_Data(conf_id)
get_Abs_Categories_id = AbstractAdminModel().Get_Abs_Categories_id()
get_cate_list_society = AbstractAdminModel().GetCategoryWiseList(society_id)
# schedule_data = AbstractAdminModel().get_schedule_data(conf_id)
return render_template('abstract_templates/abs_type.html',conf_id=conf_id,society_id=society_id,get_abs_type=get_abs_type,get_conference=get_conference,get_Abs_Categories_id=get_Abs_Categories_id,Get_All_Abs_Types=Get_All_Abs_Types,get_cate_list_society=get_cate_list_society,get_guideline=get_guideline,current_dt=current_dt,is_page=is_page)
@app.route('/<int:conf_id>/update_abs_guidline',methods=["POST"])
def UpdateAbsGuideline(conf_id):
setting_key = request.values.get('setting_key')
setting_value = request.values.get('setting_value')
setting_id = request.values.get('setting_id')
data={
'setting_key' :setting_key,
'setting_value' :setting_value
}
abs_guidline = AbstractAdminModel().UpdateGuideline(data,setting_id)
flash("Inserted successfully","successMsg")
data = {"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
@app.route('/<int:conf_id>/post_abs_type',methods=["POST"])
def PostAbsType(conf_id):
now =datetime.now()
current_dt =now.strftime("%Y-%m-%d %H:%M:%S")
abs_type =request.values.get('abs_type')
title =request.values.get('title_abs')
start_date =request.values.get('start_date')
end_date =request.values.get('end_date')
abs_type_description =request.values.get('abs_type_description')
# abs_type_url =request.values.get('abs_type_url')
is_visible =request.values.get('abs_type_is_visible')
button_name =request.values.get('button_name')
# is_abs =request.values.get('is_abs')
abs_icon =request.values.get('abs_icon')
order_by =request.values.get('order_by')
data={
'abs_type' :abs_type,
'conf_id' :conf_id,
'title' :title,
'start_date' :start_date,
'end_date' :end_date,
'description' :abs_type_description,
# 'abs_type_url' :abs_type_url,
'is_visible' :is_visible,
'order_by' :order_by,
'button_name' :button_name,
'is_abs' :1,
'abs_icons' :abs_icon,
'created_at' :current_dt,
'abs_type_url': 'main.AbstractsIndex'
}
check_abs_type_already_exsist=AbstractAdminModel().CheckAlreadyExsist(abs_type,conf_id)
if check_abs_type_already_exsist["total_count"]>0:
# flash(str(abs_type)+" Already Exists" , "errorMsg")
data = {"msg" : "fail" ,"status" : 0 }
json_data = json.dumps(data,default = str)
return json_data
else:
insert_abs_type=AbstractAdminModel().Insert_abs_type(data)
flash("Successfully Updated." , "successMsg")
data = {"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
@app.route('/<int:conf_id>/post_abs_setting',methods=["POST"])
def PostAbsSetting(conf_id):
Setting_key =request.values.get('Setting_key')
Setting_value =request.values.get('Setting_value')
title =request.values.get('title')
society_id =request.values.get('society_id')
description =request.values.get('description')
error_Msg =request.values.get('error_Msg')
abs_setting_conf_id =request.values.get('abs_setting_conf_id')
is_active =request.values.get('is_active')
is_html =request.values.get('is_html')
abs_type =request.values.get('abs_type')
# title =request.values.get('title')
data={
'setting_key' :Setting_key,
'setting_value' :Setting_value,
'title' :title,
'society_id' :society_id,
'description' :description,
'error_msg' :error_Msg,
'conf_id' :abs_setting_conf_id,
'is_active' :is_active,
'is_html' :is_html,
'conf_id' :conf_id,
}
# print(data)
insert_abs_setting=AbstractAdminModel().Insert_ABS_Setting(data)
flash("Successfully Inserted." , "successMsg")
data = {"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
# #@RouteGroup.login_required
# @app.route('/<int:conf_id>/<int:society_id>/abs_categories',methods=["POST","GET"])
# def GetAbsCategory(conf_id,society_id):
# get_abs_categoires=AbstractAdminModel().Get_Abs_Categories(conf_id)
# return render_template('abstract_templates/abs_categoires.html',get_abs_categoires=get_abs_categoires,conf_id=conf_id,society_id=society_id)
# @app.route('/<int:conf_id>/post_abs_categories',methods=["POST"])
# def PostAbsCategories(conf_id):
# name =request.values.get('name')
# parent_category_id =request.values.get('parent_category_id')
# parent_category =request.values.get('parent_category')
# display_name =request.values.get('display_name')
# segment =request.values.get('segment')
# is_parent =request.values.get('is_parent')
# data={
# 'name':name,
# 'parent_category_id':parent_category_id,
# 'parent_category' :parent_category,
# 'is_parent' :is_parent,
# 'display_name' :display_name,
# 'segment' :segment,
# 'conf_id' :conf_id
# }
# insert_abs_categories=AbstractAdminModel().Insert_abs_categories(data)
# if insert_abs_categories=='success':
# flash("Successfully Inserted." , "successMsg")
# data = {"msg" : "success" ,"status" : 1 }
# json_data = json.dumps(data,default = str)
# return json_data
#@RouteGroup.login_required
@app.route('/<int:conf_id>/<int:society_id>/<abs_type>/abs_setting_data',methods=["POST","GET"])
def GetAbsSettingData(conf_id,society_id,abs_type):
if abs_type=='IC':
get_society_data = AbstractAdminModel().get_societies_byid(society_id)
society_name=get_society_data["society_name"]
else:
society_name = None
get_abs_setting_data = AbstractAdminModel().Get_Abs_Setting_Data(conf_id,abs_type,society_name)
get_conference = AbstractAdminModel().GetConference(society_id,conf_id)
get_abs_setting = AbstractAdminModel().GetAllAbsSetting(abs_type,conf=None)
return render_template('abstract_templates/abs_setting_table.html',get_abs_setting_data=get_abs_setting_data,conf_id=conf_id,society_id=society_id,abs_type=abs_type,get_conference=get_conference,get_abs_setting=get_abs_setting)
#@RouteGroup.login_required
@app.route('/<abs_type>/get_dupl_abs_setting_data',methods=["POST","GET"])
def GetDuplicateAbsSetting(abs_type):
conf = request.values.get('conf')
get_abs_setting = AbstractAdminModel().GetAllAbsSetting(abs_type,conf)
html_data=render_template('/abstract_templates/abs_setting_duplicate.html',get_abs_setting=get_abs_setting)
# print(html_data)
data ={"html_data":html_data,"msg":"success","status":1}
json_data = json.dumps(data,default = str)
return json_data
@app.route('/<conf_id>/update_society_application',methods=["POST"])
def UpdateSocietyApplication(conf_id):
now = datetime.now()
current_dt = now.strftime("%Y-%m-%d %H:%M:%S")
app_type_id = request.values.get("app_type_id")
app_title = request.values.get('app_title')
app_urls = request.values.get("app_url")
if app_urls:
app_url = app_urls
else:
app_url = request.values.get('default_app_url')
mail_setting_id = request.values.get("mail_setting_id")
app_style = request.values.get("app_style")
# print(app_style)
app_id = request.values.get("app_id")
app_host = request.values.get("app_host")
soc_app_is_active = request.values.get("soc_app_is_active")
if soc_app_is_active=='1':
soc_app_is_active=1
else:
soc_app_is_active=0
data={
'app_type_id' :3,
'app_title' :app_title,
'app_url' :app_url,
'mail_setting_id' :mail_setting_id,
'is_active' :soc_app_is_active,
'app_style' :app_style,
'app_host' :app_host
}
print(data)
print(app_id)
update_society_app=AbstractAdminModel().update_society_app(conf_id,app_id,data)
# flash("Successfully Updated." , "successMsg")
data = {"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
@app.route('/<int:conf_id>/update_abs_setting',methods=["POST"])
def UpdateAbsSetting(conf_id):
setting_key =request.values.get("setting_key")
setting_value =request.values.get("setting_value")
title =request.values.get("title")
description =request.values.get("description")
error_msg =request.values.get("error_msg")
setting_id =request.values.get("setting_id")
is_active =request.values.get("is_active")
if is_active=='':
is_active=0
data={
'setting_key' :setting_key,
'setting_value' :setting_value,
'title' :title,
'description' :description,
'error_msg' :error_msg,
'is_active' :is_active,
'conf_id' :conf_id
}
update_abs_setting=AbstractAdminModel().Update_Abs_Setting(setting_id,data)
data = {"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
@app.route('/<int:conf_id>/update_abs_category',methods=["POST","GET"])
def Update_Abs_Category(conf_id):
category_id =request.values.get("category_id")
name =request.values.get("name")
display_name =request.values.get("display_name")
parent_category_id =request.values.get("parent_category_id")
parent_category =request.values.get("parent_category")
segment =request.values.get("segment")
is_parent =request.values.get("is_parent")
if is_parent=='':
is_parent=0
data={
'name' :name,
'display_name' :display_name,
'parent_category_id' :parent_category_id,
'parent_category' :parent_category,
'segment' :segment,
'is_parent' :is_parent,
'conf_id' :conf_id
}
update_abs_category=AbstractAdminModel().UpdateAbsCategory(category_id,data)
flash("Updated Successfully","successMsg")
data = {"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
@app.route('/<int:conf_id>/get_abs_types',methods=["POST","GET"])
def GetAbsTypes(conf_id):
abs_type_id = request.values.get('abs_type_id')
get_abs_type = AbstractAdminModel().GetAbsTypes(abs_type_id)
data = {'html_data':get_abs_type,"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
@app.route('/<int:conf_id>/get_map_catergory_data',methods=["POST","GET"])
def Get_map_catergory_data(conf_id):
abs_type_id = request.values.get('abs_type_id')
# print(abs_type_id)
get_m_abs_categoires = AbstractAdminModel().Get_Map_Categories(conf_id,abs_type_id)
html_data = render_template('abstract_templates/map_abs_category_table.html',get_m_abs_categoires=get_m_abs_categoires)
# print(html_data)
data = {"html_data":html_data,"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
@app.route('/<int:conf_id>/insert_map_caterories',methods=["POST","GET"])
def InsertMapCaterories(conf_id):
abs_type_id = request.values.get('abs_type_id')
category_id = request.values.get('category_id')
order_no = request.values.get('order_no')
is_active = 1
display_name=request.values.get('display_name') or None
if display_name:
category = AbstractAdminModel().usp_insert_abs_cate_data(display_name,conf_id)
category_id = category[0]["category_id"]
else:
category_id = request.values.get('category_id')
data={
'abs_type_id' :abs_type_id,
'category_id' :category_id,
'conf_id' :conf_id,
'is_active' :is_active,
'order_no' :order_no,
'display_name' :display_name
}
# print(data)
check_already_exsist = AbstractAdminModel().CheckMapCategExsist(conf_id,abs_type_id,category_id)
if check_already_exsist:
flash = 1
pass
else:
flash = 2
insert_map_catergory = AbstractAdminModel().Insert_Map_catergory(data)
get_m_abs_categoires = AbstractAdminModel().Get_Map_Categories(conf_id,abs_type_id)
html_data = render_template('abstract_templates/map_abs_category_table.html',get_m_abs_categoires=get_m_abs_categoires)
data = {"html_data":html_data,"msg" : "success" ,"status" : 1,"flash":flash}
json_data = json.dumps(data,default = str)
return json_data
@app.route('/<int:conf_id>/delete_map_category',methods=["POST","GET"])
def DeleteMapCategory(conf_id):
m_abs_category_id = request.values.get('m_abs_category_id')
abs_type_id = request.values.get('abs_type_id')
delete_map_category = AbstractAdminModel().Delete_Map_Category(m_abs_category_id)
get_m_abs_categoires= AbstractAdminModel().Get_Map_Categories(conf_id,abs_type_id)
html_data = render_template('abstract_templates/map_abs_category_table.html',get_m_abs_categoires=get_m_abs_categoires)
data = {"html_data":html_data,"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
@app.route('/<int:conf_id>/update_abs_type',methods=["POST","GET"])
def UpdateAbsType(conf_id):
abs_type =request.values.get('abs_type')
title =request.values.get('title')
start_date =request.values.get('start_date')
end_date =request.values.get('end_date')
abs_type_id =request.values.get('abs_type_id')
order_by =request.values.get('order_by')
is_visible =request.values.get('is_visible')
data={
'abs_type' :abs_type,
'conf_id' :conf_id,
'title' :title,
'start_date':start_date,
'end_date' :end_date,
'order_by' :order_by,
'is_visible':is_visible
}
check_abs_type_already_exsist=AbstractAdminModel().CheckAlreadyExsistUpdate(abs_type_id,abs_type,conf_id)
if check_abs_type_already_exsist["total_count"]>0:
flash(str(abs_type)+" Already Exists" , "errorMsg")
data = {"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
else:
flash("Successfully Updated" , "successMsg")
update_abs_types=AbstractAdminModel().UpdateAbsType(abs_type_id,data)
data = {"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
@app.route('/<int:conf_id>/delete_abs_type',methods=["POST","GET"])
def DeleteAbsTypes(conf_id):
abs_type_id = request.values.get('abs_type_id')
abs_type = request.values.get('abs_type')
delete_abs_type = AbstractAdminModel().Delete_Abs_Type(abs_type_id,abs_type,conf_id)
data = {"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
@app.route('/<int:conf_id>/<society_id>/delete_categoirs',methods=["POST"])
def DeleteCategoirs(conf_id,society_id):
category_id = request.values.get('category_id')
delete_catergory = AbstractAdminModel().Delete_Category(category_id)
flash("Deleted Successfully","errorMsg")
data = {"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
@app.route('/logout')
def Logout():
Auth.logout()
# print(Auth.logout())
session.pop('_flashes', None)
return redirect(url_for('abstract_admin.Login'))
@app.route('/<int:society_id>/insert_new_conference_fun',methods=["POST"])
def InsertNewConferenceFun(society_id):
conf_name = request.form.get('conf_name') or None
conf_key = request.form.get('conf_key') or None
conf_title = request.form.get('conf_title') or None
conf_name = request.form.get('conf_name') or None
conf_end = request.form.get('conf_end') or None
conf_start = request.form.get('conf_start') or None
e_backup_emails = request.form.get('e_backup_emails') or None
e_from_email = request.form.get('e_from_email') or None
data={
'conf_name' :conf_name,
'conf_title' :conf_title,
'conf_key' :conf_key,
'conf_start_time':conf_start,
'conf_end_time' :conf_end,
'society_id' :society_id,
'e_backup_emails' :e_backup_emails,
'e_from_email' :e_from_email
}
# print(data)
insert_conference=AbstractAdminModel().Insert_conference(data)
data = {"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
@app.route('/<int:conf_id>/daily_report',methods=["POST"])
def DailyReport(conf_id):
full_name = request.values.get('full_name')
email = request.values.get('email')
mobile = request.values.get('mobile')
start_date = request.values.get('start_date')
end_date = request.values.get('end_date')
# is_abs = request.values.get('is_abs')
data={
'full_name' :full_name,
'email' :email,
'mobile' :mobile,
'start_date' :start_date,
'end_date' :end_date,
'is_abs' :1,
'conf_id' :conf_id,
'is_active' :1
}
# print(data)
insert_daily_report=AbstractAdminModel().InsertDailyReport(data)
data = {"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
#@RouteGroup.login_required
@app.route('/<conf_id>/<society_id>/view_mail_report')
def ViewMailReport(conf_id,society_id):
is_page = 3
get_society_appl_data = AbstractAdminModel().Get_Society_App_Data(conf_id)
get_mail_report = AbstractAdminModel().GetMailReport(conf_id)
get_all_mail_report = AbstractAdminModel().GetAllMailReport()
if get_mail_report:
return render_template('/abstract_templates/mail_daily_report_table.html',conf_id=conf_id,get_mail_report=get_mail_report,society_id=society_id,get_society_appl_data=get_society_appl_data,is_page=is_page,get_all_mail_report=get_all_mail_report)
else:
return render_template('/abstract_templates/mail_daily_report_table.html',conf_id=conf_id,society_id=society_id,get_society_appl_data=get_society_appl_data,is_page=is_page,get_all_mail_report=get_all_mail_report)
@app.route('/get_daily_report_data',methods=["GET"])
def GetDailyReportData():
report_id = request.values.get('report_id')
get_mail_report = AbstractAdminModel().GetMailReportData(report_id)
data = {"html_data":get_mail_report,"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
@app.route('/update_mail_report_data',methods=["POST"])
def UpdateMailReportData():
full_name = request.values.get('full_name')
email = request.values.get('email')
mobile = request.values.get('mobile')
start_date = request.values.get('start_date')
end_date = request.values.get('end_date')
report_id = request.values.get('report_id')
is_active = request.values.get('is_active')
data={
'full_name' :full_name,
'email' :email,
'mobile' :mobile,
'start_date' :start_date,
'end_date' :end_date,
'is_active' : is_active
}
update_mail_report=AbstractAdminModel().UpdateMailReportDatas(data,report_id)
data = {"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
@app.route('/<report_id>/delete_report_data',methods=['POST'])
def DeleteReportData(report_id):
delete_report=AbstractAdminModel().DeleteMailReportData(report_id)
data = {"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
#@RouteGroup.login_required
@app.route('/<conf_id>/<society_id>/abs_template')
def AbsTemplate(conf_id,society_id):
is_page = 5
get_all_abs_templ=AbstractAdminModel().GetAbsTemplates()
abs_tem_data = AbstractAdminModel().AbsTemplateData(conf_id)
return render_template('/abstract_templates/abs_template.html',conf_id=conf_id,society_id=society_id,abs_tem_data=abs_tem_data,get_all_abs_templ=get_all_abs_templ,is_page=is_page)
@app.route('/insert_abs_template',methods=["POST"])
def InsertAbsTemplate():
conf_id=request.values.get('conf_id')
tem_name=request.values.get('tem_name')
abs_type=request.values.get('abs_type')
tem_data=request.values.get('tem_data')
data={
'template_name' :tem_name,
'template_data' :tem_data,
'abs_type' :abs_type,
'conf_id' :conf_id
}
insert_abs_tem = AbstractAdminModel().InsertAbsTemData(data)
data = {"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
@app.route('/get_abs_tem_data',methods=["POST","GET"])
def GetAbsTemData():
tem_id = request.values.get('tem_id')
get_abs_tem_data = AbstractAdminModel().GetTemData(tem_id)
data = {"html_data":get_abs_tem_data,"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
@app.route('/update_abs_template',methods=["POST"])
def UpdateAbsTemplate():
tem_name=request.values.get('tem_name')
abs_type=request.values.get('abs_type')
tem_data=request.values.get('tem_data')
tem_id=request.values.get('tem_id')
data={
'template_name':tem_name,
'template_data':tem_data,
'abs_type':abs_type
}
update_abs_tem=AbstractAdminModel().UpdateAbsTem(data,tem_id)
data = {"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
@app.route('/get_abs_type_data',methods=["POST","GET"])
def GetAbsTypeData():
abs_type_id = request.values.get('abs_type_id')
get_abs_type = AbstractAdminModel().GetAbsTypesData(abs_type_id)
data = {"html_data":get_abs_type,"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
@app.route('/edit_abs_setting_data',methods=["POST"])
def EditAbsSettingData():
setting_id = request.values.get('setting_id')
get_abs_sett_data = AbstractAdminModel().GetAbsSettData(setting_id)
data = {"html_data":get_abs_sett_data,"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
@app.route('/<conf_id>/add_abs_type_conference',methods=["POST"])
def AddAbsTypeConf(conf_id):
society_id = request.values.get('society_id')
select_conf_id = request.values.get('select_conf_id') or None
abs_type_ids = request.values.get('abs_type_id')
abs_types = request.values.get('abs_types')
# print(abs_types)
abs_type_id_val = str(abs_type_ids)[1:-1]
abs_type_id = abs_type_id_val.replace('"', '')
abs_types = str(abs_types)[1:-1]
a = abs_types.replace('"', '')
abs_type_1 = a.replace(',', '|')
duration ="IC" in abs_type_1
if duration == True:
get_society_data= AbstractAdminModel().Get_Society_name(society_id)
abs_type = abs_type_1+"|^"+get_society_data[0]["society_name"]+"_duration"
else:
abs_type=abs_type_1
# print(abs_type)
# print(conf_id,abs_type_id,abs_type,select_conf_id)
add_abs_data = AbstractAdminModel().DuplicateAbstractData(conf_id,abs_type_id,abs_type,select_conf_id)
# print(add_abs_data)
data = {"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
@app.route('/<conf_id>/<society_id>/add_abs_setting_data',methods=["POST"])
def AddAbsSettingData(conf_id,society_id):
abs_setting_id = request.values.get('abs_setting_id')
abs_type = request.values.get('abs_type')
setting_id = str(abs_setting_id)[1:-1]
ids = request.values.get('id')
if ids != "1":
add_abs_sett = AbstractAdminModel().AddAbsSetting(conf_id,setting_id,abs_type)
else:
check_abs_setting_exists=AbstractAdminModel().CheckAbsSettingAlreadyExsist(setting_id,conf_id)
lst =[]
if check_abs_setting_exists:
for x in check_abs_setting_exists:
lst.append(x["setting_key"])
res = ast.literal_eval(abs_setting_id)
result = [v for v in res if v not in lst] or None
if result is not None:
val = []
for i in result:
data='("'+str(i)+'", null, null,'+str(society_id)+',null, null, 1, null, '+str(conf_id)+')'
val.append(data)
vals =''
for i in val:
vals += str(i)+','
stmt_1 = "INSERT INTO abs_settings(setting_key, setting_value, title, society_id, description, error_msg, is_active, is_html,conf_id) values"+vals
stmt = stmt_1.rstrip(',')
add_abs_sett = AbstractAdminModel().InsertAbsSettingData(stmt)
else:
result_1 = [v for v in res if v in lst]
listToStr = ', '.join([str(elem) for elem in result_1])
flash(listToStr+" is already Exists","errorMsg")
data = {"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
@app.route('/delete_abs_setting_data',methods=["POST"])
def DeleteAbsSettingData():
setting_id = request.values.get('setting_id')
dele_abs_set_data = AbstractAdminModel().DeleteAbsSetting(setting_id)
data = {"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
@app.route('/<conf_id>/add_map_category',methods=["POST"])
def AddMapCategory(conf_id):
conf = request.values.get('conf')
m_abs_category_id = str(conf)[1:-1]
abs_type_id = request.values.get('app_type_id')
abs_type = request.values.get('app_type')
add_map_category = AbstractAdminModel().AddMapCategoryData(conf_id,m_abs_category_id,abs_type_id,abs_type)
get_m_abs_categoires = AbstractAdminModel().Get_Map_Categories(conf_id,abs_type_id)
html_data = render_template('abstract_templates/map_abs_category_table.html',get_m_abs_categoires=get_m_abs_categoires)
data = {"html_data":html_data,"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
@app.route('/<conf_id>/<society_id>/view_mail_templates')
def ViewMailTemplates(conf_id,society_id):
is_page = 4
get_society_appl_data = AbstractAdminModel().Get_Society_App_Data(conf_id)
get_mail_temp_name = AbstractAdminModel().GetMailTempName()
get_mail_temp = AbstractAdminModel().GetMailTemp(conf_id)
get_conference = AbstractAdminModel().GetConference(society_id,conf_id)
already_mail_temp = AbstractAdminModel().GetAlreadyInsertTemplate(conf_id)
return render_template('abstract_templates/mail_temp.html',get_mail_temp=get_mail_temp,conf_id=conf_id,society_id=society_id,get_mail_temp_name=get_mail_temp_name,get_conference=get_conference,get_society_appl_data=get_society_appl_data,data=already_mail_temp,is_page=is_page)
@app.route('/<conf_id>/<mail_template_id>/get_mail_templ_data',methods=["POST"])
def GetMailTemplData(conf_id,mail_template_id):
get_mail_data = AbstractAdminModel().GetMailData(mail_template_id)
data = {"html_data":get_mail_data,"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
@app.route('/<conf_id>/add_mail_template_data',methods=["POST"])
def AddMailTemplateData(conf_id):
now =datetime.now()
current_dt =now.strftime("%Y-%m-%d %H:%M:%S")
temp_name =request.values.get('temp_name')
subj_type =request.values.get('subj_type')
subject =request.values.get('subject')
MT_is_layout =request.values.get('MT_is_layout')
MT_is_active =request.values.get('MT_is_active')
is_send_backup =request.values.get('is_send_backup')
mail_tem_duplicate =request.values.get('mail_tem_duplicate')
data={
'template_name' :temp_name,
'subject_type' :subj_type,
'subject' :subject,
'is_layout' :MT_is_layout,
'is_active' :MT_is_active,
'is_send_backup':is_send_backup,
'mail_content' :mail_tem_duplicate,
'conf_ids' :conf_id,
'created_at' :current_dt,
'mail_type' :'jinja',
'app_type_id' :3
}
check_already_exsist=AbstractAdminModel().CheckAlreadyExsistMailTemp(conf_id,temp_name)
if check_already_exsist['count']>0:
flash(str(temp_name)+" Already Exists","errorMsg")
data = {"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
else:
flash("Added successfully","successMsg")
insert_mail_template=AbstractAdminModel().InsertMailTempl(data)
data = {"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
@app.route('/<conf_id>/<mail_template_id>/update_mail_template_data',methods=["POST"])
def UpdateMailTemplateData(conf_id,mail_template_id):
now =datetime.now()
current_dt =now.strftime("%Y-%m-%d %H:%M:%S")
temp_name =request.values.get('temp_name')
subj_type =request.values.get('subj_type')
subject =request.values.get('subject')
MT_is_layout =request.values.get('MT_is_layout')
MT_is_active =request.values.get('MT_is_active')
is_send_backup =request.values.get('is_send_backup')
mail_tem_duplicate =request.values.get('mail_tem_duplicate')
data={
'template_name' :temp_name,
'subject_type' :subj_type,
'subject' :subject,
'is_layout' :MT_is_layout,
'is_active' :MT_is_active,
'is_send_backup':is_send_backup,
'mail_content' :mail_tem_duplicate,
'conf_ids' :conf_id,
'updated_at' :current_dt,
'mail_type' :'jinja',
'app_type_id' :3
}
CheckAlreadyExsistMailTempUpdate=AbstractAdminModel().CheckAlreadyExsistMailTempUpdate(conf_id,temp_name,mail_template_id)
if CheckAlreadyExsistMailTempUpdate['count']>0:
flash(str(temp_name)+" Already Exists","errorMsg")
# update_mail_temp = AbstractAdminModel().UpdateMailTemp(mail_template_id,data)
data = {"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
else:
flash("Updated successfully","successMsg")
update_mail_temp = AbstractAdminModel().UpdateMailTemp(mail_template_id,data)
data = {"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
@app.route('/get_mail_temp_data',methods=["POST"])
def GetMailTempData():
conf = request.values.get('conf') or None
get_mail_data = AbstractAdminModel().GetConfMailData(conf)
html_data = render_template('abstract_templates/mail_template_dup.html',get_mail_data=get_mail_data)
data = {"html_data":html_data,"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
@app.route('/get_dupl_abs_type_data',methods=["POST"])
def GetDuplicateAbsTypeData():
conf = request.values.get('conf') or None
get_abs_type = AbstractAdminModel().GetConfAbsTypeData(conf)
html_data = render_template('abstract_templates/abs_type_dup.html',get_abs_type=get_abs_type)
data = {"html_data":html_data,"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
@app.route('/<conf_id>/insert_mail_tem_dup',methods=["POST"])
def InsertMailTemDup(conf_id):
now = datetime.now()
current_dt = now.strftime("%Y-%m-%d %H:%M:%S")
mail_template_id = request.values.get('mail_template_id')
# print(mail_template_id)
data = mail_template_id.replace('[','')
mail_template_id = data.replace(']','')
insert_dup_tem = AbstractAdminModel().InsertDuplicateTemp(mail_template_id,conf_id,current_dt)
# print(insert_dup_tem)
data = {"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
@app.route('/<conf_id>/<mail_template_id>/delete_mail_template_data',methods=["POST"])
def DeleteMailTemplateData(conf_id,mail_template_id):
dele_mail_tem_data=AbstractAdminModel().DeleteMailTemplData(mail_template_id)
data = {"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
@app.route('/<conf_id>/insert_abs_guidline',methods=["POST"])
def InsertAbsGuidline(conf_id):
setting_key = request.values.get('setting_key')
setting_value = request.values.get('setting_value')
data={
'setting_key' :setting_key,
'setting_value' :setting_value,
'conf_id' :conf_id
}
abs_guidline = AbstractAdminModel().InsertAbsGuidline(conf_id,data)
flash("Inserted successfully","successMsg")
data = {"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
@app.route('/abs_map_cate_duplicate',methods=["POST"])
def AbsMapCateDuplicate():
conf = request.values.get('conf') or None
get_map_cate = AbstractAdminModel().AbsMapcategData(conf)
html_data = render_template('abstract_templates/abs_map_cate_dup.html',get_map_cate=get_map_cate)
data = {"html_data":html_data,"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
@app.route('/<conf_id>/update_order_no_aph',methods=["POST"])
def UpdateOrderNoAphb(conf_id):
abs_type_id = request.values.get('abs_type_id')
update_order_no = AbstractAdminModel().UpdateOrder_No(conf_id,abs_type_id)
get_m_abs_categoires = AbstractAdminModel().Get_Map_Categories(conf_id,abs_type_id)
html_data = render_template('abstract_templates/map_abs_category_table.html',get_m_abs_categoires=get_m_abs_categoires)
data = {"html_data":html_data,"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
@app.route('/<conf_id>/duplicate_abs_template',methods=["POST"])
def DuplicateAbsTemplate(conf_id):
template_ids = request.values.get('template_id')
template_id = str(template_ids)[1:-1]
tem_names = request.values.get('tem_name')
tem_name = str(tem_names)[1:-1]
get_abs_temp = AbstractAdminModel().DuplicateAbsTemplate(template_id,conf_id)
data = {"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
@app.route('/<conf_id>/delete_abs_template',methods=["POST"])
def DeleteEvalTemplate(conf_id):
template_id = request.values.get('template_id')
delete_eval_template= AbstractAdminModel().DeleteEvalTemplates(template_id)
flash("Deleted Successfully","error_Msg")
data = {"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
@app.route("/update_extended_date", methods=["GET", "POST"])
def update_extended_date():
now = datetime.now()
now = now.strftime('%Y-%m-%d %H:%M')
now_datetime = datetime.now().strftime("%d-%m-%Y %I:%M %p")
extended_data = AbstractAdminModel().get_extended_data_by_conf_id(now)
if extended_data:
for ext_data in extended_data:
if ext_data['abs_type_id'] == ext_data['abstract_type_id']:
if str(ext_data['scheduled_on'].strftime('%Y-%m-%d %H:%M')) == now:
AbstractAdminModel().update_extended_date_by_abs_id(now)
data = AbstractAdminModel().get_updated_extended_data(now)
subject = "Abstract Submission Extended Date on "+ now_datetime
to = ["sai@numerotec.com","manjula@numerotec.com","dp@numerotec.com","sridharan.r@numerotec.com","sakthivel@numerotec.com","mukeshkumar@numerotec.com","harini@numerotec.com","sivabalan@numerotec.com", "priyavarthana@numerotec.com","vimal@numerotec.com"]
html_data = render_template('abstract_templates/email/extend_date_mail.html',data=data,now_datetime=now_datetime)
# EMAIL.SendMailExtendDate(subject,html_data,to)
Bravo.sendMail(subject,html_data,to,None,None)
return "success"
else:
return "waiting to update"
else:
return "failed"
return "no extended data"
@app.route('/<abs_type_id>/get_scheduled_data',methods=["POST"])
def get_scheduled_data(abs_type_id):
schedule_data = AbstractAdminModel().get_schedule_data(abs_type_id)
data = {"schedule_data":schedule_data,"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
@app.route('/<abs_type_id>/update_scheduled_data',methods=["POST"])
def update_scheduled_data(abs_type_id):
schedule_id = request.values.get('schedule_id') or 0
abs_type_id = request.values.get('abs_type_id') or None
schedule_on = request.values.get('schedule_on') or None
extend_on = request.values.get('extend_on') or None
conference_id = request.values.get('conference_id') or None
data ={
'abs_type_id':abs_type_id,
'scheduled_on':schedule_on,
'extent_on':extend_on,
'conf_id':conference_id
}
if int(schedule_id) == 0:
AbstractAdminModel().InsertSchedule(data)
else:
AbstractAdminModel().UpdateSchedule(schedule_id,data)
schedule_data = AbstractAdminModel().get_schedule_data(abs_type_id)
data = {"schedule_data":schedule_data,"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
@app.route('/<abs_type_id>/delete_scheduled_data',methods=["POST"])
def delete_scheduled_data(abs_type_id):
schedule_id = request.values.get('schedule_id')
AbstractAdminModel().delete_schedule(schedule_id)
schedule_data = AbstractAdminModel().get_schedule_data(abs_type_id)
data = {"schedule_data":schedule_data,"msg" : "success" ,"status" : 1 }
json_data = json.dumps(data,default = str)
return json_data
@app.route('/<conf_id>/edit_conference_data',methods=["POST"])
def EditConferenceData(conf_id):
# print(conf_id)
society_id=None
get_conference=AbstractAdminModel().GetConferenceData(society_id,conf_id)
data = {"html_data":get_conference,"msg" : "success" ,"status" : 1 }
json_data= json.dumps(data,default = str)
return json_data
@app.route('/<conf_id>/update_conference_data',methods=["POST"])
def Update_Conference_Data(conf_id):
conf_name = request.values.get('edit_conf_name')
conf_key = request.values.get('edit_conf_key')
conf_title = request.values.get('edit_conf_title')
conf_name = request.values.get('edit_conf_name')
conf_end = request.values.get('edit_conf_end')
conf_start = request.values.get('edit_conf_start')
e_support_email=request.values.get('edit_e_support_email')
e_backup_emails=request.values.get('edit_e_backup_emails')
e_from_email=request.values.get('edit_e_from_email')
# society_id = request.values.get('society_id')
data={
'conf_name' :conf_name,
'conf_title' :conf_title,
'conf_key' :conf_key,
'conf_start_time':conf_start,
'conf_end_time' :conf_end,
'e_from_email':e_from_email,
'e_backup_emails':e_backup_emails,
'e_support_email':e_support_email
}
update_conf=AbstractAdminModel().UpdateConference(data,conf_id)
data = {"msg" : "success" ,"status" : 1 }
json_data= json.dumps(data,default = str)
return json_data
# @app.route('/<int:conf_id>/<int:society_id>/create_application')
# def CreateApp(conf_id,society_id):
# is_page = 6
# path=floder_name
# req_path=request.values.get('req_path') or 'Controller'
# if req_path=='Controller':
# path=floder_name
# elif req_path=='Templates':
# path=template_path
# else:
# path=backoff_template
# folder=[]
# try:
# os.chdir(path)
# all_subdirs = [d for d in os.listdir('.') if os.path.isdir(d)]
# for dirs in all_subdirs:
# folder.append(dirs)
# except Exception as e:
# print(e)
# get_conf=AbstractAdminModel().GetConferenceData(society_id,conf_id)
# conf_name=get_conf[0]['conf_name']
# return render_template('abstract_templates/create_app.html',conf_id=conf_id,society_id=society_id,is_page=is_page,folder=folder,url=path,conf_name=conf_name)
# # @app.route('/<int:conf_id>/<int:society_id>/switch_path',methods=['POST'])
# # def SwitchPath_data(conf_id,society_id):
# # req_path=request.values.get('req_path') or 'Controller'
# # if req_path=='Controller':
# # path=floder_name
# # elif req_path=='Templates':
# # path=template_path
# # else:
# # path=backoff_template
# # folder=[]
# # try:
# # os.chdir(path)
# # all_subdirs = [d for d in os.listdir('.') if os.path.isdir(d)]
# # for dirs in all_subdirs:
# # folder.append(dirs)
# # except Exception as e:
# # print(e)
# # html_data= render_template('abstract_templates/switch_path_tem.html',conf_id=conf_id,society_id=society_id,folder=folder,url=path)
# # data = {"html_data":html_data,"msg" : "success" ,"status" : 1,'url':path }
# # json_data= json.dumps(data,default = str)
# # return json_data
# @app.route('/<conf_id>/<society_id>/switch_path',methods=['POST'])
# def SwitchPath_data(conf_id,society_id):
# req_path=request.values.get('req_path') or 'Controller'
# path_1 = request.values.get('path')
# open_folder=request.values.get('open_folder')
# # print(open_folder)
# if req_path=='Controller':
# if open_folder:
# path=path_1
# else:
# path=floder_name
# elif req_path=='Templates':
# if open_folder:
# path=path_1
# else:
# path=template_path
# else:
# if open_folder:
# path=path_1
# else:
# path=backoff_template
# # print(path)
# os.chdir(path)
# # all_subdirs = [d for d in os.listdir('.') if os.path.isdir(d)]
# all_subdirs = os.listdir(path)
# folder=[]
# for dirs in all_subdirs:
# folder.append(dirs)
# html_data= render_template('abstract_templates/switch_path_tem.html',conf_id=conf_id,society_id=society_id,folder=folder,url=path)
# data = {"html_data":html_data,"msg" : "success" ,"status" : 1,'url':path }
# json_data= json.dumps(data,default = str)
# return json_data
# # @app.route('/<int:conf_id>/make_duplicate_folder_app',methods=["POST"])
# # def Make_DuplicateFolder_App(conf_id):
# # path_name=request.values.get('path_name') or 'Controller'
# # path=request.values.get('path')
# # floder_name=request.values.get('folder_name')
# # society_id=None
# # get_conf=AbstractAdminModel().GetConferenceData(society_id,conf_id)
# # new_folder=get_conf[0]['conf_key']
# # n_folder_name=new_folder.upper()
# # newpath = path+'/'+n_folder_name
# # if not os.path.exists(newpath):
# # os.makedirs(newpath)
# # if path_name=='Controller':
# # for item in os.listdir(newpath):
# # item_path = os.path.join(newpath, item)
# # if os.path.isfile(item_path):
# # try:
# # os.remove(item_path)
# # print(f"Deleted file: {item_path}")
# # except Exception as e:
# # print(f"Failed to delete file: {item_path} - {e}")
# # try:
# # files = glob.glob(floder_name + '/*')
# # for file in files:
# # shutil.copy(file, newpath)
# # except Exception as e:
# # print(e)
# # elif path_name=='Templates':
# # for item in os.listdir(newpath):
# # item_path = newpath+'/'+item
# # try:
# # shutil.rmtree(item_path)
# # # print(f"Deleted folder: {item_path}")
# # except Exception as e:
# # print(f"Failed to delete folder: {item_path} - {e}")
# # try:
# # files = glob.glob(floder_name + '/*')
# # for i in files:
# # f=os.path.basename(i)
# # if not os.path.exists(f):
# # tem_folder=newpath+'/'+f
# # os.makedirs(tem_folder)
# # dup_tem_fol_name=path+'/'+floder_name+'/'+f
# # files_1 = glob.glob(dup_tem_fol_name + '/*')
# # for file in files_1:
# # shutil.copy(file, tem_folder)
# # except Exception as e:
# # print(e)
# # else:
# # print('Folder not exists')
# # flash("Folder move successfully","successMsg")
# # data = {"msg" : "success" ,"status" : 1 }
# # json_data= json.dumps(data,default = str)
# # return json_data
# # @app.route('/<int:conf_id>/make_duplicate_folder_app',methods=["POST"])
# # def Make_DuplicateFolder_App(conf_id):
# # path_name=request.values.get('path_name') or 'Controller'
# # path=request.values.get('path')
# # floder_name=request.values.get('folder_name')
# # society_id=None
# # get_conf=AbstractAdminModel().GetConferenceData(society_id,conf_id)
# # new_folder=get_conf[0]['conf_key']
# # n_folder_name=new_folder.upper()
# # newpath = path+'/'+n_folder_name
# # if os.path.exists(newpath):
# # try:
# # shutil.rmtree(newpath)
# # print(f"Deleted file: {newpath}")
# # except Exception as e:
# # print(f"Failed to delete file: {newpath} - {e}")
# # try:
# # source_folder = path+'/'+floder_name
# # destination_folder = newpath
# # s_path = source_folder
# # d_path = destination_folder
# # shutil.copytree(s_path,d_path)
# # except Exception as e:
# # print(e)
# # else:
# # try:
# # source_folder = path+'/'+floder_name
# # destination_folder = newpath
# # s_path = source_folder
# # d_path = destination_folder
# # shutil.copytree(s_path,d_path)
# # except Exception as e:
# # print(e)
# # if path_name=='Controller':
# # if os.path.exists(newpath):
# # try:
# # shutil.rmtree(newpath)
# # print(f"Deleted file: {newpath}")
# # except Exception as e:
# # print(f"Failed to delete file: {newpath} - {e}")
# # try:
# # source_folder = path+'/'+floder_name
# # destination_folder = newpath
# # s_path = source_folder
# # d_path = destination_folder
# # shutil.copytree(s_path,d_path)
# # except Exception as e:
# # print(e)
# # elif path_name=='Templates':
# # if os.path.exists(newpath):
# # try:
# # shutil.rmtree(newpath)
# # print(f"Deleted file: {newpath}")
# # except Exception as e:
# # print(f"Failed to delete file: {newpath} - {e}")
# # try:
# # source_folder = path+'/'+floder_name
# # destination_folder = newpath
# # try:
# # s_path = source_folder
# # d_path = destination_folder
# # shutil.copytree(s_path,d_path)
# # print("Folder copied successfully!")
# # except Exception as e:
# # print(e)
# # files = glob.glob(floder_name + '/*')
# # for i in files:
# # f=os.path.basename(i)
# # if not os.path.exists(f):
# # tem_folder=newpath+'/'+f
# # os.makedirs(tem_folder)
# # dup_tem_fol_name=path+'/'+floder_name+'/'+f
# # files_1 = glob.glob(dup_tem_fol_name + '/*')
# # for file in files_1:
# # shutil.copy(file, tem_folder)
# # except Exception as e:
# # print(e)
# # else:
# # print('Folder not exists')
# # flash("Folder move successfully","successMsg")
# # data = {"msg" : "success" ,"status" : 1 }
# # json_data= json.dumps(data,default = str)
# # return json_data
# @app.route('/<int:conf_id>/make_duplicate_folder_app',methods=["POST"])
# def Make_DuplicateFolder_App(conf_id):
# path_name=request.values.get('path_name') or 'Controller'
# path=request.values.get('path')
# # print(path)
# floder_name=request.values.get('folder_name')
# # print(floder_name)
# file_replace=request.values.get('file_replace') or 'No'
# society_id=None
# get_conf=AbstractAdminModel().GetConferenceData(society_id,conf_id)
# new_folder=get_conf[0]['conf_key']
# n_folder_name=new_folder.upper()
# newpath = path+'/'+n_folder_name
# # print(newpath)
# if os.path.exists(newpath):
# if file_replace=='No':
# # print("----------")
# flash("Folder move successfully","successMsg")
# data = {"msg" : "already" ,"status" : 2 }
# json_data= json.dumps(data,default = str)
# return json_data
# if file_replace=='Yes':
# try:
# shutil.rmtree(newpath)
# print(f"Deleted file: {newpath}")
# except Exception as e:
# print(f"Failed to delete file: {newpath} - {e}")
# try:
# source_folder = path+'/'+floder_name
# destination_folder = newpath
# s_path = source_folder
# d_path = destination_folder
# shutil.copytree(s_path,d_path)
# except Exception as e:
# print(e)
# flash("Folder move successfully","successMsg")
# data = {"msg" : "success" ,"status" : 1 }
# json_data= json.dumps(data,default = str)
# return json_data
# else:
# try:
# source_folder = path+'/'+floder_name
# destination_folder = newpath
# print()
# s_path = source_folder
# d_path = destination_folder
# shutil.copytree(s_path,d_path)
# except Exception as e:
# print(e)
# flash("Folder move successfully","successMsg")
# data = {"msg" : "success" ,"status" : 1 }
# json_data= json.dumps(data,default = str)
# return json_data
# @app.route('/<int:conf_id>/make_duplicate_file_app',methods=["POST"])
# def Make_DuplicateFile_App(conf_id):
# # print("------------------")
# path_name=request.values.get('path_name') or 'Controller'
# source_path=request.values.get('source_path')
# if path_name=='Controller':
# path=floder_name
# elif path_name=='Templates':
# path=template_path
# else:
# path=backoff_template
# # print(path)
# file_name_2=request.values.get('folder_name')
# file_name_3 = str(file_name_2)[1:-1]
# file_name_1 = file_name_3.replace('"', '')
# file_name=list(file_name_1.split(","))
# file_replace=request.values.get('file_replace') or 'No'
# society_id=None
# get_conf=AbstractAdminModel().GetConferenceData(society_id,conf_id)
# new_folder=get_conf[0]['conf_key']
# n_folder_name=new_folder.upper()
# newpath = path+'/'+n_folder_name
# # print(ne.wpath)
# if os.path.exists(newpath):
# try:
# if file_name:
# for i in file_name:
# # print(i)
# if path_name=='Controller':
# source_folder = source_path+'/'+i
# destination_folder = newpath
# s_path = source_folder
# d_path = destination_folder
# shutil.copy(s_path,d_path)
# elif path_name=='Templates':
# source_folder = source_path+'/'+i
# destination_folder = newpath+'/'+i
# s_path = source_folder
# d_path = destination_folder
# shutil.copytree(s_path,d_path)
# else:
# source_folder = source_path+'/'+i
# destination_folder = newpath
# s_path = source_folder
# d_path = destination_folder
# shutil.copy(s_path,d_path)
# except Exception as e:
# print(e)
# flash("Folder move successfully","successMsg")
# data = {"msg" : "success" ,"status" : 1 }
# json_data= json.dumps(data,default = str)
# return json_data
# else:
# if not os.path.exists(newpath):
# os.makedirs(newpath)
# try:
# if file_name:
# for i in file_name:
# # print(i)
# if path_name=='Controller':
# source_folder = source_path+'/'+i
# destination_folder = newpath
# s_path = source_folder
# d_path = destination_folder
# shutil.copy(s_path,d_path)
# elif path_name=='Templates':
# source_folder = source_path+'/'+i
# destination_folder = newpath+'/'+i
# s_path = source_folder
# d_path = destination_folder
# shutil.copytree(s_path,d_path)
# else:
# source_folder = source_path+'/'+i
# destination_folder = newpath
# s_path = source_folder
# d_path = destination_folder
# shutil.copy(s_path,d_path)
# except Exception as e:
# print(e)
# flash("Folder move successfully","successMsg")
# data = {"msg" : "success" ,"status" : 1 }
# json_data= json.dumps(data,default = str)
# return json_data
# @app.route('/sample')
# def Sample():
# source_folder = "/home/numerotech/admin.numerotech.com/DEMO"
# destination_folder = "/home/numerotech/test.numerotech.com/DEMO"
# try:
# s_path = source_folder
# d_path = destination_folder
# shutil.copytree(s_path,d_path)
# print("Folder copied successfully!")
# except Exception as e:
# print(e)
# if e.winerror == 5:
# print("Permission denied. Attempting to elevate privileges...")
# try:
# # Attempt to run the script with administrative privileges
# if ctypes.windll.shell32.IsUserAnAdmin() == 0:
# ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, __file__, None, 1)
# except Exception as e:
# print(f"Failed to elevate privileges: {e}")
# else:
# print(f"Error: {e}")
# return jsonify(os.listdir(destination_folder))
@app.route('/<int:conf_id>/<int:society_id>/create_application')
def CreateApp(conf_id,society_id):
is_page = 6
path=floder_name
req_path=request.values.get('req_path') or 'Controller'
if req_path=='Controller':
path=floder_name
elif req_path=='Templates':
path=template_path
else:
path=backoff_template
folder=[]
try:
os.chdir(path)
all_subdirs = [d for d in os.listdir('.') if os.path.isdir(d)]
for dirs in all_subdirs:
folder.append(dirs)
except Exception as e:
print(e)
get_conf=AbstractAdminModel().GetConferenceData(society_id,conf_id)
conf_name=get_conf[0]['conf_name']
return render_template('abstract_templates/create_app.html',conf_id=conf_id,society_id=society_id,is_page=is_page,folder=folder,url=path,conf_name=conf_name,get_conf=get_conf)
@app.route('/<conf_id>/<society_id>/switch_path',methods=['POST'])
def SwitchPath_data(conf_id,society_id):
req_path=request.values.get('req_path') or 'Controller'
path_1 = request.values.get('path')
open_folder=request.values.get('open_folder')
# print(open_folder)
folder_name=request.values.get('folder_name') or None
# print(folder_name)
conf_key=request.values.get('conf_key')
# print(path_1)
btn_folder=0
if path_1==floder_name or path_1== template_path or path_1 == backoff_template:
btn_folder=1
if req_path=='Controller':
if path_1==floder_name or path_1==floder_name+'/':
btn_folder=1
if open_folder:
path=path_1
else:
path=floder_name
elif req_path=='Templates':
if path_1==template_path or path_1==template_path+'/':
btn_folder=1
if open_folder:
path=path_1
else:
path=template_path
else:
if path_1==backoff_template or path_1==backoff_template+'/':
btn_folder=1
if open_folder:
path=path_1
else:
path=backoff_template
# print(path)
os.chdir(path)
last_word = os.path.basename(path)
same_folder=''
if conf_key==last_word:
same_folder=1
else:
same_folder=0
# all_subdirs = [d for d in os.listdir('.') if os.path.isdir(d)]
all_subdirs = os.listdir(path)
folder=[]
for dirs in all_subdirs:
folder.append(dirs)
# print(btn_folder)
html_data= render_template('abstract_templates/switch_path_tem.html',conf_id=conf_id,society_id=society_id,folder=folder,url=path,conf_key=conf_key,same_folder=same_folder)
data = {"html_data":html_data,"msg" : "success" ,"status" : 1,'url':path,'btn_folder':btn_folder}
json_data= json.dumps(data,default = str)
return json_data
@app.route('/<int:conf_id>/make_duplicate_folder_app',methods=["POST"])
def Make_DuplicateFolder_App(conf_id):
path_name=request.values.get('path_name') or 'Controller'
path=request.values.get('path')
# print(path)
floder_name=request.values.get('folder_name')
# print(floder_name)
file_replace=request.values.get('file_replace') or 'No'
society_id=None
get_conf=AbstractAdminModel().GetConferenceData(society_id,conf_id)
new_folder=get_conf[0]['conf_key']
n_folder_name=new_folder.upper()
newpath = path+'/'+n_folder_name
# print(newpath)
if os.path.exists(newpath):
if file_replace=='No':
flash("Folder move successfully","successMsg")
data = {"msg" : "already" ,"status" : 2 }
json_data= json.dumps(data,default = str)
return json_data
if file_replace=='Yes':
try:
shutil.rmtree(newpath)
print(f"Deleted file: {newpath}")
except Exception as e:
print(f"Failed to delete file: {newpath} - {e}")
try:
source_folder = path+'/'+floder_name
destination_folder = newpath
s_path = source_folder
d_path = destination_folder
shutil.copytree(s_path,d_path)
if path_name=='Controller':
os.chdir(d_path)
all_subdirs = os.listdir(d_path)
folder=[]
for dirs in all_subdirs:
folder.append(dirs)
# print(folder)
if folder:
for i in folder:
try:
with open(d_path+'/'+i, 'r') as f:
file_content = f.read()
modified_content = file_content.replace('/'+floder_name+'/', '/'+n_folder_name+'/')
with open(d_path+'/'+i, 'w') as f:
f.write(modified_content)
finally:
f.close()
# file_content.close()
except Exception as e:
print(e)
# flash("Folder move successfully","successMsg")
data = {"msg" : "success" ,"status" : 1 }
json_data= json.dumps(data,default = str)
return json_data
else:
try:
source_folder = path+'/'+floder_name
destination_folder = newpath
# print(source_folder)
# print(destination_folder)
s_path = source_folder
d_path = destination_folder
shutil.copytree(s_path,d_path)
if path_name=='Controller':
os.chdir(d_path)
# all_subdirs = [d for d in os.listdir('.') if os.path.isdir(d)]
all_subdirs = os.listdir(d_path)
folder=[]
for dirs in all_subdirs:
folder.append(dirs)
# print(folder)
if folder:
for i in folder:
try:
with open(d_path+'/'+i, 'r') as f:
file_content = f.read()
modified_content = file_content.replace('/'+floder_name+'/', '/'+n_folder_name+'/')
with open(d_path+'/'+i, 'w') as f:
f.write(modified_content)
finally:
f.close()
except Exception as e:
print(e)
# flash("Folder move successfully","successMsg")
data = {"msg" : "success" ,"status" : 1 }
json_data= json.dumps(data,default = str)
return json_data
@app.route('/<int:conf_id>/make_duplicate_file_app',methods=["POST"])
def Make_DuplicateFile_App(conf_id):
path_name=request.values.get('path_name') or 'Controller'
source_path=request.values.get('source_path')
if path_name=='Controller':
path=floder_name
elif path_name=='Templates':
path=template_path
else:
path=backoff_template
file_name_2=request.values.get('folder_name')
file_name_3 = str(file_name_2)[1:-1]
file_name_1 = file_name_3.replace('"', '')
file_name=list(file_name_1.split(","))
file_replace=request.values.get('file_replace') or 'No'
society_id=None
get_conf=AbstractAdminModel().GetConferenceData(society_id,conf_id)
new_folder=get_conf[0]['conf_key']
n_folder_name=new_folder.upper()
newpath = path+'/'+n_folder_name
if os.path.exists(newpath):
try:
if file_name:
for i in file_name:
file_name_exist=newpath+'/'+i
# print("klkfko")
if os.path.exists(file_name_exist):
# print("loooo")
if file_replace=='No':
data = {"msg" : "already" ,"status" : 2 }
json_data= json.dumps(data,default = str)
return json_data
if file_replace=='Yes':
try:
os.remove(file_name_exist)
print(f"Deleted file: {file_name_exist}")
except Exception as e:
print(f"Failed to delete file: {file_name_exist} - {e}")
if path_name=='Controller':
source_folder = source_path+'/'+i
destination_folder = newpath
s_path = source_folder
d_path = destination_folder
shutil.copy(s_path,d_path)
parsed_url = urlparse(source_folder)
path = parsed_url.path # Get the path component of the URL
# Split the path by '/' and filter out any empty strings
path_segments = [segment for segment in path.split('/') if segment.strip()]
# print(path_segments)
# Check if there are at least two segments
if len(path_segments) >= 2:
old_conf_name = path_segments[-2]
# print(old_conf_name)
else:
print('noo')
try:
with open(d_path+'/'+i, 'r') as f:
file_content = f.read()
modified_content = file_content.replace('/'+old_conf_name+'/', '/'+n_folder_name+'/')
with open(d_path+'/'+i, 'w') as f:
f.write(modified_content)
finally:
f.close()
elif path_name=='Templates':
source_folder = source_path+'/'+i
destination_folder = newpath+'/'+i
s_path = source_folder
d_path = destination_folder
shutil.copytree(s_path,d_path)
else:
source_folder = source_path+'/'+i
destination_folder = newpath
s_path = source_folder
d_path = destination_folder
shutil.copy(s_path,d_path)
else:
if path_name=='Controller':
source_folder = source_path+'/'+i
destination_folder = newpath
s_path = source_folder
d_path = destination_folder
shutil.copy(s_path,d_path)
# print(s_path)
# print(d_path)
parsed_url = urlparse(source_folder)
path = parsed_url.path # Get the path component of the URL
# Split the path by '/' and filter out any empty strings
path_segments = [segment for segment in path.split('/') if segment.strip()]
# print(path_segments)
# Check if there are at least two segments
if len(path_segments) >= 2:
old_conf_name = path_segments[-2]
print(old_conf_name)
else:
print('noo')
try:
with open(d_path+'/'+i, 'r') as f:
file_content = f.read()
modified_content = file_content.replace('/'+old_conf_name+'/', '/'+n_folder_name+'/')
with open(d_path+'/'+i, 'w') as f:
f.write(modified_content)
finally:
f.close()
elif path_name=='Templates':
source_folder = source_path+'/'+i
destination_folder = newpath+'/'+i
s_path = source_folder
d_path = destination_folder
shutil.copytree(s_path,d_path)
else:
source_folder = source_path+'/'+i
destination_folder = newpath
s_path = source_folder
d_path = destination_folder
shutil.copy(s_path,d_path)
except Exception as e:
print(e)
# flash("Folder move successfully","successMsg")
data = {"msg" : "success" ,"status" : 1 }
json_data= json.dumps(data,default = str)
return json_data
else:
if not os.path.exists(newpath):
os.makedirs(newpath)
try:
# print(file_name)
if file_name:
for i in file_name:
# print(i)
if path_name=='Controller':
source_folder = source_path+'/'+i
destination_folder = newpath
s_path = source_folder
d_path = destination_folder
shutil.copy(s_path,d_path)
parsed_url = urlparse(source_folder)
path = parsed_url.path # Get the path component of the URL
# Split the path by '/' and filter out any empty strings
path_segments = [segment for segment in path.split('/') if segment.strip()]
# Check if there are at least two segments
if len(path_segments) >= 2:
old_conf_name = path_segments[-2]
print(old_conf_name)
else:
print('noo')
try:
with open(d_path+'/'+i, 'r') as f:
file_content = f.read()
modified_content = file_content.replace('/'+old_conf_name+'/', '/'+n_folder_name+'/')
with open(d_path+'/'+i, 'w') as f:
f.write(modified_content)
finally:
f.close()
elif path_name=='Templates':
source_folder = source_path+'/'+i
destination_folder = newpath+'/'+i
s_path = source_folder
d_path = destination_folder
shutil.copytree(s_path,d_path)
else:
source_folder = source_path+'/'+i
destination_folder = newpath
s_path = source_folder
d_path = destination_folder
shutil.copy(s_path,d_path)
except Exception as e:
print(e)
# flash("Folder move successfully","successMsg")
data = {"msg" : "success" ,"status" : 1 }
json_data= json.dumps(data,default = str)
return json_data
@app.route('/copy_same_conference',methods=['POST','GET'])
def CopySameConference():
same_file_dup=request.values.get('same_file_dup')
url_path=request.values.get('url_path')
folder_name=request.values.get('folder_name')
parsed_url = urlparse(same_file_dup)
path = parsed_url.path # Get the path component of the URL
# print(path)
path_segments = [segment for segment in path.split('/') if segment.strip()]
print(path_segments)
len(path_segments)
if len(path_segments) >= 1:
file_name = path_segments[-1]
# print(file_name)
pattern = os.path.join(same_file_dup)
files = glob.glob(pattern)
count_file=len(files)
# print(count_file)
try:
if count_file>=0:
base, ext = os.path.splitext(file_name)
new_filename = file_name
new_filename = f"{base}_{count_file}{ext}"
file_path = (url_path+'/'+file_name)
new_file_path=(url_path+'/'+new_filename)
# print("-----------------")
# print(new_file_path)
# print("same file")
# print(same_file_dup)
if folder_name=='Controller':
shutil.copy2(same_file_dup, new_file_path)
else:
shutil.copytree(same_file_dup, new_file_path)
all_subdirs = os.listdir(url_path)
folder=[]
for dirs in all_subdirs:
folder.append(dirs)
# print(folder)
same_folder=1
html_data= render_template('abstract_templates/switch_path_tem.html',folder=folder,same_folder=same_folder,url=url_path)
data = {'html_data':html_data,"msg" : "success" ,"status" : 1 }
json_data= json.dumps(data,default = str)
return json_data
else:
print("------------")
data = {"msg" : "error" ,"status" : 2 }
json_data= json.dumps(data,default = str)
return json_data
except Exception as e:
print(e)
data = {"msg" : "error" ,"status" : 3 }
json_data= json.dumps(data,default = str)
return json_data
else:
print("else data")
data = {"msg" : "error" ,"status" : 4 }
json_data= json.dumps(data,default = str)
return json_data
@app.route('/rename_file',methods=['POST','GET'])
def RenameFile():
old_file_name=request.values.get('old_file_name')
file_rename=request.values.get('file_rename')
url_path=request.values.get('url_path')
path_name=request.values.get('path_name')
abs_type_1=request.values.get('abs_type')
old_file = (url_path+'/'+old_file_name)
new_file = (url_path+'/'+file_rename)
print("new_file")
print(new_file)
print("old_file")
print(old_file)
try:
# print(old_file_name)
# print(abs_type_1)
if path_name=='Controller':
os.rename(old_file, new_file)
all_subdirs = os.listdir(url_path)
word_to_remove=old_file_name.replace('Controller.py', '')
abs_type=file_rename.replace('Controller.py', '')
else:
os.rename(old_file, abs_type_1.upper())
all_subdirs = os.listdir(url_path)
word_to_remove=old_file_name.replace('Controller.py', '')
abs_type=file_rename.replace('Controller.py', '')
if path_name=='Controller':
try:
with open(new_file, 'r') as f:
file_content = f.read()
modified_content = file_content.replace(word_to_remove,abs_type)
with open(new_file, 'w') as f:
f.write(modified_content)
finally:
f.close()
keyword = "Controller"
index = old_file_name.find(keyword)
if index != -1:
# Slice the string up to and including the keyword
result = old_file_name[:index]
else:
# If keyword is not found, return the original string or handle accordingly
result = old_file_name
a=[''+str(result)+'Controller',"'"+str(result)+"'",'/'+str(result)+'/','main_'+str(result)+'',''+str(result)+'_PA_COUNT',''+str(result)+'_CA_COUNT',''+str(result)+'_submit_mail']
for i in a:
change_abs_type = i.replace(result,abs_type_1.upper())
# print(modified_content)
with open(new_file, 'r') as r:
file_content = r.read()
modified_content = file_content.replace(i,change_abs_type)
with open(new_file, 'w') as f:
f.write(modified_content)
folder=[]
for dirs in all_subdirs:
folder.append(dirs)
same_folder=1
html_data= render_template('abstract_templates/switch_path_tem.html',folder=folder,same_folder=same_folder,url=url_path)
data = {"html_data":html_data,"msg" : "success" ,"status" : 1 }
json_data= json.dumps(data,default = str)
return json_data
except Exception as e:
print(e)
all_subdirs = os.listdir(url_path)
folder=[]
for dirs in all_subdirs:
folder.append(dirs)
same_folder=1
html_data= render_template('abstract_templates/switch_path_tem.html',folder=folder,same_folder=same_folder,url=url_path)
data = {"msg" : "failed" ,"status" : 2 }
json_data= json.dumps(data,default = str)
return json_data
@app.route('/sample')
def Sample():
source_folder = "/home/numerotech/admin.numerotech.com/DEMO"
destination_folder = "/home/numerotech/test.numerotech.com/DEMO"
try:
s_path = source_folder
d_path = destination_folder
shutil.copytree(s_path,d_path)
print("Folder copied successfully!")
except Exception as e:
print(e)
if e.winerror == 5:
print("Permission denied. Attempting to elevate privileges...")
try:
# Attempt to run the script with administrative privileges
if ctypes.windll.shell32.IsUserAnAdmin() == 0:
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, __file__, None, 1)
except Exception as e:
print(f"Failed to elevate privileges: {e}")
else:
print(f"Error: {e}")
return jsonify(os.listdir(destination_folder))
@app.route('/create_database_page')
def create_database_Page():
return render_template('abstract_templates/create_db_page.html')
@app.route('/create_db', methods=['POST'])
def create_db():
db_name = request.values.get('db_name')
db_user = "numerotech_primary_db"
db_prefix = f"{cpanel_username}_"
# cpanel_password = cpanel_password
API_TOKEN=cpanel_api_token
CPANEL_DOMAIN=cpanel_api_url
db_full_name = f"{db_prefix}{db_name}"
# cpanel_username_1=cpanel_username
# cpanel_api_token_1=cpanel_api_token
# cpanel_api_url_1=cpanel_api_url
# cpanel_password_1=cpanel_password
if not db_name or not db_user:
return jsonify({"error": "Missing database name, user, or password"}), 400
url = "https://numerotech.com:2083/execute/Mysql/create_database"
payload = {
'name':db_full_name,
}
headers = {
'Authorization': f"cpanel {cpanel_username}:{API_TOKEN}"
}
response = requests.request("GET", url, headers=headers, data=payload)
response = json.loads(response.text)
if response['status']==1:
url = "https://numerotech.com:2083/execute/Mysql/set_privileges_on_database"
payload = {
'user':db_user,
'database':db_full_name,
'privileges':"ALL PRIVILEGES"
}
headers = {
'Authorization': f"cpanel {cpanel_username}:{API_TOKEN}"
}
response = requests.request("GET", url, headers=headers, data=payload)
response = json.loads(response.text)
# print(response)
return json.dumps({'status':1,'msg':''})
else:
# print(response)
return json.dumps({'status':0,'msg':response['errors']})
@app.route('/create_domain_page')
def create_domain_Page():
get_main_domain=AbstractAdminModel().get_domain_name()
return render_template('abstract_templates/domain_page.html',get_main_domain=get_main_domain)
@app.route('/create_domain', methods=['POST'])
def create_domain():
domain_name = request.values.get('domain')
API_TOKEN=cpanel_api_token
main_domain=request.values.get('main_domain')
if not domain_name:
return jsonify({"error": "Domain name is required"}), 400
# Prepare API request to add a new domain
# url = "https://hostname.example.com:2083/execute/SubDomain/addsubdomain?domain=subdomain&rootdomain=example.com"
url = "https://numerotech.com:2083/execute/SubDomain/addsubdomain"
payload = {
'domain':domain_name,
'rootdomain':"numerotech.com",
'dir':main_domain
}
headers = {
'Authorization': f"cpanel {cpanel_username}:{API_TOKEN}"
}
# data = {
# 'domain': domain_name,
# 'dir': f'public_html/{domain_name}', # Set the document root
# 'subdomain': domain_name.split('.')[0] # Create a subdomain as well
# }
# response = requests.post(url, headers=headers, data=data)
response = requests.request("GET", url, headers=headers, data=payload)
response = json.loads(response.text)
# print(response)
if response['status']==1:
sub_domain_name=domain_name+".numerotech.com"
# print(sub_domain_name)
# print(sub_domain_name)
API_TOKEN = 'ZHqVNGmlgqlecw6XcRlNefZUlA_gc1wSN8agP3CN'
ZONE_ID = 'd5b63b1511003e1bbb1af86621207bf6' # The zone ID of your domain
SUBDOMAIN = sub_domain_name
RECORD_TYPE = 'A' # Change this to 'CNAME' if needed
CONTENT = '207.148.116.149' # IP address or target for the CNAME
TTL = 1 # Automatic TTL
PROXIED = False # Set to True if you want to use Cloudflare's proxy
# Headers for the request
headers = {
'Authorization': f'Bearer {API_TOKEN}',
'Content-Type': 'application/json'
}
# Data for the new DNS record
data = {
'type': RECORD_TYPE,
'name': SUBDOMAIN,
'content': CONTENT,
'ttl': TTL,
'proxied': PROXIED
}
# API endpoint to create a DNS record
url = f'https://api.cloudflare.com/client/v4/zones/{ZONE_ID}/dns_records'
# Making the request
response = requests.post(url, headers=headers, json=data)
# Checking the response
if response.status_code == 200:
print("Subdomain added successfully!")
print(response.json())
else:
print("Failed to add subdomain:")
print(response.json())
return json.dumps({'status':1,'msg':''})
else:
return json.dumps({'status':0,'msg':response['errors']})
@app.route('/send_bulk_whatsapp', methods=['POST', 'GET'])
def send_bulk_whatsapp():
phone_numbers = ['9150798328', '7094558228'] # List of phone numbers
message = 'Hii' # The message to send
# Ensure that phone numbers and message are provided
if not phone_numbers or not message:
return "Phone number and message are required.", 400
# URL-encode the message to ensure it's safe for a URL
encoded_message = urllib.parse.quote(message)
# Iterate through the phone numbers and send the WhatsApp message
for phone_number in phone_numbers:
# Generate the WhatsApp URL
whatsapp_url = f"https://wa.me/{phone_number}?text={encoded_message}"
print(f"Generated URL: {whatsapp_url}")
# Send the GET request to the WhatsApp link
response = requests.get(whatsapp_url, allow_redirects=True) # Allow redirects
# Check the status of the response
if response.status_code == 200:
print(f"Successfully reached WhatsApp for {phone_number}")
# If there was a redirect, check the 'Location' header
location = response.headers.get('Location')
if location:
print("Redirected to:", location)
else:
print("No 'Location' header found in the response.")
else:
print(f"Failed to send message to {phone_number}. Status code: {response.status_code}")
return 'Success', 200
#Nalasamy - feb 4th
@app.route('/a2host_db_create', methods=['POST','GET'])
def A2Host_create_db():
db_name = request.values.get('db_name')
db_user = "numerote_primary_db"
db_prefix = f"{a2host_username}_"
# cpanel_password = cpanel_password
db_full_name = f"{db_prefix}{db_name}"
if not db_name or not db_user:
return jsonify({"error": "Missing database name or user"}), 400
# cPanel API token for authentication
headers = {
'Authorization': f"cpanel {a2host_username}:{a2host_api_token}"
}
# Create the database
url = f"https://{a2host_domain}:2083/execute/Mysql/create_database"
payload = {
'name': db_full_name,
}
response = requests.get(url, headers=headers, params=payload, verify=False)
response_data = response.json()
if response_data['status'] == 1:
# If the database is created successfully, set privileges for the user
url = f"https://{a2host_domain}:2083/execute/Mysql/set_privileges_on_database"
payload = {
'user': db_user,
'database': db_full_name,
'privileges': "ALL PRIVILEGES" # You can modify the privileges as needed
}
response = requests.get(url, headers=headers, params=payload, verify=False)
response_data = response.json()
if response_data['status'] == 1:
return json.dumps({'status': 1, 'message': 'Database and privileges set successfully'})
else:
return json.dumps({'status': 0, 'message': response_data['errors'][0]})
else:
msg=response_data['errors'][0]
return json.dumps({'status': 0, 'message': msg})
# Nithyan
# View and Add Abstract Types
@app.route("/view_abs/<conf_id>/<society_id>", methods=["GET", "POST"])
def ViewAbs(conf_id,society_id):
is_page=7
data = AbstractAdminModel().get_all_abstract(conf_id)
abs_types=defaultdict(list)
# print(abs_types)
if data:
for i in data:
if i['parent_abs_type'] is None:
abs_types[i['abs_type']].append(i)
else:
abs_types[i['parent_abs_type']].append(i)
else:
data = None
return render_template("abstract_templates/abstract_table.html",data=data,conf_id=conf_id,society_id=society_id,abs_types=abs_types,is_page=is_page)
@app.route("/insert_abstype/<conf_id>/<society_id>", methods=["GET", "POST"])
def InsertAbstype(conf_id,society_id):
data =None
is_page=8
return render_template("abstract_templates/adding_abstracttypes.html",data=data,conf_id=conf_id,society_id=society_id,is_page=is_page)
@app.route("/edit_abs/<abs_type_id>/<conf_id>/<society_id>", methods=["GET", "POST"])
def EditAbs(abs_type_id,conf_id,society_id):
data = AbstractAdminModel().get_abstract_data_by_id(abs_type_id,conf_id)
return render_template("abstract_templates/adding_abstracttypes.html", data=data, conf_id=conf_id, society_id=society_id,abs_type_id=abs_type_id,is_page=8)
@app.route("/post_abs/<conf_id>/<society_id>", methods=["GET", "POST"])
def PostAbs(conf_id, society_id, abs_type_id=None):
abs_type_id = request.values.get("abs_type_id") or 0
abs_type = request.values.get("abs_type") or None
parent_abs_type = request.values.get("parent_abs_type") or None
title = request.values.get("title") or None
start_date = request.values.get("start_date") or None
end_date = request.values.get("end_date") or None
description = request.values.get("description") or None
is_visible = request.values.get("is_visible") or 0
order_by = request.values.get("order_by") or None
abs_type_url = request.values.get("abs_type_url") or None
abs_description = request.values.get("abs_description") or None
is_abs = request.values.get("is_abs") or 0
abs_config_type = request.values.get("abs_config_type") or None
button_name = request.values.get("button_name") or None
abs_icons = request.values.get("abs_icons") or None
is_attachement = request.values.get("is_attachement") or 0
show_result = request.values.get("show_result") or 0
show_session = request.values.get("show_session") or 0
upload_selection_type = request.values.get("upload_selection_type") or None
upload_image_type = request.values.get("upload_image_type") or None
upload_ext_type = request.values.get("upload_ext_type") or None
upload_file_size = request.values.get("upload_file_size") or None
upload_guideline = request.values.get("upload_guideline") or None
abs_guideline = request.values.get("abs_guideline") or None
hide_abs_no_comm = request.values.get("hide_abs_no_comm") or None
data = {
"abs_type": abs_type,
"parent_abs_type":parent_abs_type,
"conf_id": conf_id,
"title": title,
"start_date": start_date,
"end_date": end_date,
"description": description,
"created_at":datetime.now(),
"updated_at":datetime.now(),
"is_visible": is_visible,
"order_by": order_by,
"abs_type_url": abs_type_url,
"abs_description": abs_description,
"is_abs": is_abs,
"abs_config_type": abs_config_type,
"button_name": button_name,
"abs_icons": abs_icons,
"is_attachement": is_attachement,
"show_result": show_result,
"show_session": show_session,
"upload_selection_type": upload_selection_type,
"upload_image_type": upload_image_type,
"upload_ext_type": upload_ext_type,
"upload_file_size": upload_file_size,
"upload_guideline": upload_guideline,
"abs_guideline": abs_guideline,
"in_commitment":1,
"hide_abs_no_comm":hide_abs_no_comm,
}
if int(abs_type_id)!=0:
AbstractAdminModel().update_abstract_data(abs_type_id, data)
flash("Abstract type updated successfully!", category="warningMsg")
else:
if abs_type is None:
flash("Abstract type is required!", category="errorMsg")
return redirect(url_for("abstract_admin.InsertAbstype", conf_id=conf_id, society_id=society_id))
existing_abs_type = AbstractAdminModel().get_abstract_by_name(abs_type, conf_id)
if existing_abs_type is None:
AbstractAdminModel().insert_abstype(data)
flash("Abstract type created successfully!", category="successMsg")
return redirect(url_for("abstract_admin.ViewAbs", conf_id=conf_id, society_id=society_id))
else:
flash("Abstract type already exists!", category="errorMsg")
return redirect(url_for("abstract_admin.ViewAbs", conf_id=conf_id, society_id=society_id))
return redirect(url_for("abstract_admin.ViewAbs", conf_id=conf_id, society_id=society_id))
@app.route("/delete_abs/<abs_type_id>/<conf_id>/<society_id>", methods=["GET", "POST"])
def DeleteAbs(abs_type_id,conf_id, society_id):
data = AbstractAdminModel().delete_abstract_data_by_id(abs_type_id,conf_id)
flash("Successfully deleted!", "errorMsg")
return redirect(url_for("abstract_admin.ViewAbs", conf_id=conf_id, society_id=society_id))
#----Abstract Roles----
@app.route("/view_absrole/<conf_id>/<society_id>", methods=["GET", "POST"])
def ViewAbsrole(conf_id, society_id):
is_page=9
data = AbstractAdminModel().get_all_abstractrole()
role_data = render_template("abstract_templates/role_tbody.html", data=data, conf_id=conf_id, society_id=society_id)
return render_template("abstract_templates/abstract_roles.html", data=data, role_data=role_data,is_page=is_page, conf_id=conf_id, society_id=society_id)
@app.route("/insert_absrole", methods=["POST"])
def InsertAbsrole():
data = request.get_json()
role = data.get('role')
role_type = data.get('role_type')
if not role or not role_type:
return jsonify({"status": "error", "message": "Role and Role Type are required!"})
existing_role = AbstractAdminModel().get_role_by_name(role)
if existing_role:
return jsonify({"status": "error", "message": "Role already exists!"})
max_order_no = AbstractAdminModel().get_max_order_no()
new_order_no = max_order_no + 1 if max_order_no is not None else 1
result = AbstractAdminModel().insert_absrole({
"role": role,
"role_type": role_type,
"order_no": new_order_no
})
if result:
return jsonify({
"status": "success",
"message": "Role added successfully!",
"data": {
"role": role,
"role_type": role_type,
"order_no": new_order_no
}
})
else:
return jsonify({"status": "error", "message": "Failed to add role!"})
@app.route("/post_absrole/<role_id>", methods=["POST"])
def PostAbsrole(role_id):
data = request.get_json()
role = data.get('role')
role_type = data.get('role_type')
order_no = data.get('order_no')
if not role or not role_type:
return jsonify({"status": "error", "message": "Role and Role Type are required!"})
# existing_role = AbstractModel().get_role_by_name(role)
# if existing_role:
# return jsonify({"status": "error", "message": "Role already exists!"})
result = AbstractAdminModel().update_abstractroles_data(role_id, {
"role": role,
"role_type": role_type,
"order_no": order_no,
})
if result:
return jsonify({"status": "success", "message": "Successfully updated!"})
else:
return jsonify({"status": "error", "message": "Update failed!"})
@app.route("/get_absrole_data", methods=["GET"])
def GetAbsroleData():
data = AbstractAdminModel().get_all_abstractrole()
if data:
role_data = render_template("abstract_templates/role_tbody.html", data=data)
return jsonify({"status": "success", "role_data": role_data})
else:
return jsonify({"status": "error", "message": "Failed to fetch selection data"})
@app.route("/edit_absroles/<role_id>", methods=["GET", "POST"])
def EditAbsroles(role_id):
data = AbstractAdminModel().get_abstractroles_data_by_id(role_id)
if data:
return jsonify({"status": "success", "data": data})
else:
return jsonify({"status": "error", "message": "Role not found!"})
@app.route("/check_role_exists", methods=["POST"])
def check_role_exists():
role = request.form.get("role")
existing_role = AbstractAdminModel().get_role_by_name(role)
return jsonify({"exists": bool(existing_role)})
@app.route("/delete_absrole/<role_id>", methods=["DELETE"])
def DeleteAbsrole(role_id):
role_type = AbstractAdminModel().delete_abstractroles_data_by_id(role_id)
if role_type:
AbstractAdminModel().delete_abstractroles_data_by_id(role_id)
return jsonify({"status": "success", "message": "Role deleted successfully!"})
else:
return jsonify({"status": "error", "message": "Failed to delete role!"})
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists