Sindbad~EG File Manager
from core import app
from flask import render_template_string
from flask import url_for,render_template,request,redirect,session
from datetime import datetime, date, time, timedelta
import math,random
import time
# from core.model.SocietyAssets import SocietyAssets
# from core.model.MSSetting import MSSetting
from requests.utils import requote_uri
class Helper:
AppType = "AbstractAdmin"
# AiosMembershipNumber = ['vrsi','mos','tnoa']
# AadhaarNumber = ['tnoa']
# AadhaarAddress = ['tnoa']
# ColumnDescription = ['vrsi','mos','tnoa','ipgs','csos','apots']
# HospitalAddress = {'iages':{'show':1,'req':1}}
# AttachTypeId = {'vrsi':7,'mos':1,'tnoa':12, 'ipgs':16, 'apots':17, 'csos':23,'ksos':45 ,'kos':52 ,'aios' : 58}
# AttachType = 'Photograph'
# AssociateMemberId = 6
# FellowshipAttachId = {'vrsi' :11, 'demo' :51}
# def date_diff(d1, d2):
# # fmt = '%H:%M'
# d1 = date(d1,'%Y, %m, %d')
# d2 = date(d2,'%Y, %m, %d')
# diff = str(d1) - str(d2)
# return diff
# def random_otp():
# digits = "123456789"
# otp_random = ""
# for i in range(4) :
# random.seed(time.process_time())
# otp_random += digits[math.floor(random.random() * 9)]
# return otp_random
# def getcurrenttimestamp():
# ct = datetime.datetime.now()
# ts = ct.timestamp()
# return ts
# def email_mask(email):
# if email:
# lo = email.find('@')
# if lo>0:
# mask_email = email[0]+"*****"+email[lo-1:]
# return mask_email
# return email
# def mobile_mask(mobile):
# if mobile:
# lo = len(mobile)
# if lo>0:
# mask = mobile[:2]+"******"+mobile[lo-2:]
# return mask
# return mobile
# def convert_html_for_payment_screen(payment_content,member):
# temp = app.jinja_env.from_string("{{payment_content.payment_content|safe}}").render(payment_content=payment_content,member=member)
# return render_template_string(temp,payment_content=payment_content,member=member)
# # def convert_html_for_mail_screen(mail_content,userData,qul_data,exp_data,image,prosec_data,society):
# # temp = app.jinja_env.from_string("{{mail_content|safe}}").render(mail_content=mail_content,userData=userData,qul_data=qul_data,exp_data=exp_data,image=image,prosec_data=prosec_data,society=society)
# # return render_template_string(temp,mail_content=mail_content,userData=userData,qul_data=qul_data,exp_data=exp_data,image=image,prosec_data=prosec_data,society=society)
# def convert_html_for_mail_screen(data):
# temp = app.jinja_env.from_string("{{mail_content|safe}}").render(**data)
# return render_template_string(temp,**data)
# def merge_tags(text,values):
# for k, v in values.items():
# text = text.replace('*|'+k+'|*', v)
# return text
# def pagination_tool(total,page,limit):
# numpages = math.ceil(total/limit)
# return render_template('back_office/pagination.html',total=total,limit=limit,page=page,numpages=numpages)
# def base_url():
# base_url = request.host_url
# if "https" in base_url :
# pass
# else :
# base_url = base_url.replace("http" ,"https")
# return base_url
# def sendWhatsApp(mobile,wp_content):
# wp_content = requote_uri(wp_content)
# h_link = "http://wa.me/91"+mobile+"?text="+wp_content
# return h_link
# def getSoceityAssets(society_id,asset_name):
# assets_dict = session.get('asset_'+str(society_id),None) # check asset data from session
# if assets_dict is None: # if session data not the get from database and set in session
# assetsData = SocietyAssets().getsociety_assets(society_id)
# assets_dict = {}
# for ad in assetsData:
# assets_dict[ad['asset_name']] = ad['asset_url']
# session['asset_'+str(society_id)] = assets_dict # set asset_dict to session
# return assets_dict[asset_name]
# def getSettings(society_id,setting_key):
# setting_dict = session.get('setting_'+str(society_id),None)
# if setting_dict is None:
# settingData = MSSetting().get_settings(society_id)
# if settingData :
# setting_dict = {}
# for setting in settingData:
# setting_dict[setting['setting_key']] = setting['setting_value']
# session['setting_'+str(society_id)] = setting_dict
# else:
# return None
# return setting_dict.get(setting_key,None)
def check_dates_is_open(start,end):
today = date.today()
# start_date = start.strftime("%Y-%m-%d %H:%M")
# end_date = end.strftime("%Y-%m-%d %H:%M")
if start and end:
start_date = start.strftime("%Y-%m-%d %H:%M")
end_date = end.strftime("%Y-%m-%d %H:%M")
else:
start_date="0000-00-00 00:00"
end_date="0000-00-00 00:00"
today_date = today.strftime("%Y-%m-%d %H:%M")
if start_date <= today_date <= end_date:
return 1
elif today_date > end_date:
return 2
else:
return 0
def get_role_data(absData):
chiefins = None
coins = []
chiefauthor = None
presauthor = None
coauthor = []
others = []
for item in absData['topics']:
if item['role_id'] == 32:
chiefins = item
if item['role_id'] == 33:
coins.append(item)
if item['role_id'] == 34:
chiefauthor = item
if item['role_id'] == 35:
presauthor = item
if item['role_id'] == 36:
coauthor.append(item)
if item['role_id'] not in (32,33,34,35,36):
others.append(item)
return chiefins,coins,chiefauthor,presauthor,coauthor,others
def get_days(conf_start_time):
now = datetime.now()
current_dt = now.strftime("%Y-%m-%d %H:%M:%S")
conf_start_dt = conf_start_time
current_dt_obj = datetime.strptime(current_dt, "%Y-%m-%d %H:%M:%S")
if conf_start_dt:
if isinstance(conf_start_dt, str):
conf_start_dt = datetime.strptime(conf_start_dt, "%Y-%m-%d %H:%M:%S")
days_remaining = (int(conf_start_dt.timestamp()) - int(current_dt_obj.timestamp())) // 86400
else:
days_remaining = None
return days_remaining
app.jinja_env.globals.update(Helper=Helper)
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists