Merge pull request #11943 from pratu16x7/hub-connector-fixes

[fix] hub connection, fixes #11357
This commit is contained in:
Prateeksha Singh 2017-12-11 23:23:37 +05:30 committed by GitHub
commit 903e9f4b6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,7 +16,7 @@ def enable_hub():
@frappe.whitelist()
def get_items(start=0, limit=20, category=None, order_by=None, company=None, text=None):
connection = get_connection()
connection = get_client_connection()
filters = {
'hub_category': category,
}
@ -32,7 +32,7 @@ def get_items(start=0, limit=20, category=None, order_by=None, company=None, tex
@frappe.whitelist()
def get_categories():
connection = get_connection()
connection = get_client_connection()
response = connection.get_list('Hub Category')
return response
@ -40,20 +40,24 @@ def get_categories():
def get_item_details(hub_sync_id=None):
if not hub_sync_id:
return
connection = get_connection()
connection = get_client_connection()
return connection.get_doc('Hub Item', hub_sync_id)
@frappe.whitelist()
def get_company_details(hub_sync_id):
connection = get_connection()
connection = get_client_connection()
return connection.get_doc('Hub Company', hub_sync_id)
def get_connection():
def get_client_connection():
# frappeclient connection
hub_connection = get_hub_connection()
return hub_connection.connection
def get_hub_connection():
hub_connector = frappe.get_doc(
'Data Migration Connector', 'Hub Connector')
hub_connection = hub_connector.get_connection()
# frappeclient connection
return hub_connection.connection
return hub_connection
def make_opportunity(buyer_name, email_id):
buyer_name = "HUB-" + buyer_name
@ -174,7 +178,7 @@ def send_opportunity(contact):
user=contact.email_id
))
connection = get_connection()
connection = get_hub_connection()
response = connection.insert('Hub Message', args)
return response.ok