usernotifications = mydb["User_Notifications"]
master_notifications = mydb["Table_master_notifications"]
def insert_creatstrategy(paramdata,newstrategy,strategyname,parameterkey,Benchmark,comments):
message = BusinessLogicClass.check_Strategy_ByParamID(paramdata)
# print('This checking message',message)
# if message == True:
# Stra_list = DatalayersClass.getStrategies()
# return Stra_list
# else:
paramId = paramdata
data_dict = newstrategy.to_dict("records") ## converting into Dictionary from DF
mystrategies.insert({"id":"User1","ParamID":paramId,"StrategyName":strategyname,"ParameterKey":parameterkey,"Benchmark":Benchmark,"StrategyDF":data_dict,"Comments": comments,"is_deleted": 1})
##########
print('Started Notifications')
modeul_name = "Strategy Manager"
print(modeul_name)
task_name = "Create Strategy"
print(task_name)
message = "You have created a New Strategy with Name:"
notified_label = strategyname
DatalayersClass.master_notifications(modeul_name,task_name)
print('Ended Notifications')
return True
def edit_editstrategy(stratergy_id,parameterkey,Benchmark,comments):
myquery = { "_id": ObjectId(stratergy_id) }
newvalues = { "$set": {"ParameterKey":parameterkey,"Benchmark":Benchmark,"Comments": comments} }
mystrategies.update_many(myquery,newvalues)
query = {"stratey Manager":updateStrategy}
my_dict = mystrategies.find_one({"module_name":"Strategy Manager"})
message = my_dict['Note_desc']
print('Started Notifications') ## added
modeul_name = "Strategy Manager"
task_name = "updateStrategy"
print(task_name)
#message = "You have Successfully edit the Strategy"
DatalayersClass.master_notifications(modeul_name,task_name,message,notified_label) ## till here
return True
def delete_deletestrategy(stratergy_id):
myquery = { "_id": ObjectId(stratergy_id) }
newvalues = { "$set": {"is_deleted":0} }
mystrategies.update_many(myquery,newvalues)
## from
query = {"Strategy Manager" : deletestrategy}
my_dict = mystrategies.find_one({"module_name": "Stratergy Manager" })
message = my_dict['Note_desc']
## here
print('Started Notification') ## added
module_name = "Strategy Manager"
task_name = "deletestrategy"
print(task_name)
# message = "You have Successfully deleted the strategy"
DatalayersClass.master_notifications(modeul_name,task_name,message,notified_label) ## till here
return True
def UniversalParameters():
Universal_parameters = []
for i in Universal_params.find():
#print(i['ParamID'])
Universal_parameters.append(i['Savart Universal Parameters'])
return Universal_parameters
def master_notifications(modeul_name,task_name):
msg1 = DatalayersClass.get_master_notifications(task_name)
User_Notifications = msg1 + notified_label
print("Hello User_Notifications",User_Notifications)
DatalayersClass.insert_usernotifications(User_Notifications)
return "Successfull completed Notifications"
def get_master_notifications(task_name):
print('Task name',task_name)
my_dict = master_notifications.find_one({'Task_name': task_name })
message = my_dict['Note_desc']
print("Message",message)
return message
def insert_usernotifications(User_Notifications):
usernotifications.insert({'UserID':"102" ,'Account_ID':"2" ,"User_Notifications":User_Notifications})
# usernotifications.insert({'UserID':"102" ,'Account_ID':"2" ,"User_Notifications":User_Notifications, "Date_and Time Stamp":currenttime })
return "Succesfully inserted"
# def update_usernotifications(User_Notifications): ## added