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, 2020 in Python by Hari
• 160 points

recategorized Oct 12, 2020 by Niroj 892 views

1 answer to this question.

0 votes

Hi, @Hari,

Are you facing any error while executing your code?

answered Oct 12, 2020 by Gitika
• 65,770 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, 2020 in Python by Niroj
• 82,840 points
12,993 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, 2020 in Python by MD
• 95,460 points
5,247 views
0 votes
0 answers
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,300 points
920 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
• 11,380 points
1,408 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 27, 2018 in Big Data Hadoop by nitinrawat895
• 11,380 points
2,098 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 18, 2018 in Tableau by ghost
• 1,790 points
776 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
1,724 views
0 votes
4 answers

How to print objects of class using print function in Python?

>>> class Test: ... ...READ MORE

answered Dec 16, 2020 in Python by Roshni
• 10,480 points
78,509 views
+1 vote
4 answers

how to sort a list of numbers without using built-in functions like min, max or any other function?

Yes it is possible. You can refer ...READ MORE

answered Jun 27, 2019 in Python by Arvind
• 3,050 points
188,459 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP