Reply
Highlighted
New Contributor
Posts: 1
Registered: ‎07-08-2018

Adding a parameter while saving the postgres query

I am working on the HUE for my project, i have to save a parameter along with the metadatas while creating a postgres query,i have added my parameter in the client post request by altering the "notebook.ko.js" file present in the "/hue/desktop/libs/notebook/src/notebook/static/notebook/js/" location, now i have to save that parameter in the "desktop_document2"  database table ,for that i have altered the code in "api.py" file present in the /hue/desktop/libs/notebook/src/notebook/ location,i altered the code in api.py as follows.

 

def _save_notebook(notebook, user):
notebook_type = notebook.get('type', 'notebook')
save_as = False

if notebook.get('parentSavedQueryUuid'): # We save into the original saved query, not into the query history
notebook_doc = Document2.objects.get_by_uuid(user=user, uuid=notebook['parentSavedQueryUuid'])
elif notebook.get('id'):
notebook_doc = Document2.objects.get(id=notebook['id'])
else:
notebook_doc = Document2.objects.create(name=notebook['name'], uuid=notebook['uuid'], type=notebook_type, owner=user)
Document.objects.link(notebook_doc, owner=notebook_doc.owner, name=notebook_doc.name, description=notebook_doc.description, extra=notebook_type)
save_as = True

if notebook.get('directoryUuid'):
notebook_doc.parent_directory = Document2.objects.get_by_uuid(user=user, uuid=notebook.get('directoryUuid'), perm_type='write')
else:
notebook_doc.parent_directory = Document2.objects.get_home_directory(user)

notebook['isSaved'] = True
notebook['isHistory'] = False
notebook['id'] = notebook_doc.id
_clear_sessions(notebook)
notebook_doc1 = notebook_doc._get_doc1(doc2_type=notebook_type)
notebook_doc.update_data(notebook)
notebook_doc.search = _get_statement(notebook)
notebook_doc.name = notebook_doc1.name = notebook['name']

--------------------------I added my param below to save---------------------------------------------------

notebook_doc.projectid= notebook_doc1.name = notebook['projectid']

-------------------------------------------------------------------------------------------------------------------------
notebook_doc.description = notebook_doc1.description = notebook['description']
notebook_doc.save()
notebook_doc1.save()

return notebook_doc, save_as

 

I have also created a column in the "Desktop_document2 " table to store my column,but at the server side i can't able to save,could somebody help me?

Announcements