Sindbad~EG File Manager

Current Path : /home/numerotech/imagepoll.numerotech.com/common_imagepoll_v1/core/library/
Upload File :
Current File : //home/numerotech/imagepoll.numerotech.com/common_imagepoll_v1/core/library/helper_old.py

from core import app
from flask import url_for,render_template_string
from datetime import datetime, date, time, timedelta
import random,time,math
from num2words import num2words
from core.library.auth import Auth
#settime working as global variable but commented for easy identification of this variable using class name 
# global settime
# settime = 5

class Helper:

	# PaymentGatewayAppMasterID = 7 # IAGES23 razorpay
	# PaymentGatewayISTest      = 1 # testmode = 1

	DefaultCountryID          = 101 # for india country code
	AppType                   = "IMAGEPOLL"
	cdn_url 				  = "https://cdn.numerotech.com" 	
	# master_email_ids = ["vimaljoseph@numerotec.com","sridharan.r@numerotec.com"]

	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)       
		# print(diff)
		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 random4digt():
		number = random.randint(1000,9999)
		return number

	def amountTowords(amount):
		words_in_amount = num2words(amount, lang='en_IN')
		return words_in_amount  

	def amountTodecimal(amount):
		num = int(amount)
		rs = f"{num:,}"
		return rs   


	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 formatINR(number):
		s, *d = str(number).partition(".")
		r = ",".join([s[x-2:x] for x in range(-3, -len(s), -2)][::-1] + [s[-3:]])
		return "".join([r] + d)
	
	def convert_html(data):
		temp = app.jinja_env.from_string("{{login_content|safe}}").render(**data)
		return render_template_string(temp,**data)

	def convert_jinja_cert(self,tempt,data):
		temp = app.jinja_env.from_string(tempt).render(data=data)
		return render_template_string(temp,**data)

	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


app.jinja_env.globals.update(Helper=Helper) 

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists