How to call function in django ?

0 votes
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
Oct 12 in Python by Hari
• 160 points

recategorized Oct 12 by Niroj 54 views

1 answer to this question.

0 votes

Hi, @Hari,

Are you facing any error while executing your code?

answered Oct 12 by Gitika
• 50,100 points

Related Questions In Python

0 votes
1 answer

How to call function that takes an argument in a Django template?

Hello @kartik, You cannot call a function that ...READ MORE

answered Jun 23 in Python by Niroj
• 78,080 points
1,191 views
0 votes
1 answer

How to call a function from another file in Python?

Hi@akhtar, You can use the import keyword to ...READ MORE

answered Jun 24 in Python by MD
• 79,350 points
279 views
0 votes
1 answer

How to use a global variable in function?

The global variable can be used in ...READ MORE

answered Sep 27, 2018 in Python by SDeb
• 13,250 points
136 views
0 votes
1 answer

How to switch pages using Ajax in Django?

You should use django-pjax which is built exactly for ...READ MORE

answered Oct 9, 2018 in Python by aryya
• 7,400 points
471 views
0 votes
1 answer

Hadoop MapReduce vs MongoDB MapReduce

Hadoop vs MongoDB MR: 1) Hadoop's MR can ...READ MORE

answered Mar 26, 2018 in Big Data Hadoop by nitinrawat895
• 10,950 points
441 views
0 votes
1 answer

How can we send data from MongoDB to Hadoop?

The MongoDB Connector for Hadoop reads data ...READ MORE

answered Mar 26, 2018 in Big Data Hadoop by nitinrawat895
• 10,950 points
695 views
0 votes
0 answers

How can I add a connection between Mongodb and Tableau

What I want? Parse the XML to JSON ...READ MORE

May 17, 2018 in Tableau by ghost
• 1,790 points
297 views
0 votes
2 answers

How do I integrate Kdb+ and hadoop?

 kdb+ could be installed on every Hadoop ...READ MORE

answered Aug 6, 2018 in Big Data Hadoop by Abhi
• 3,720 points
667 views
0 votes
2 answers

How to call perl script in Python script?

If you just want to open a ...READ MORE

answered Oct 6 in Python by Reshma
245 views
0 votes
1 answer

How to insert value by one post method in 2 table with Django?

try  import-export   library of Django or if you are ...READ MORE

answered Nov 12 in Python by Gitika
• 50,100 points
17 views