Marketplace

- Cache hub calls
- call_hub_method using FrappeClient connection
- Become a seller UX fixes
This commit is contained in:
Faris Ansari
2018-07-26 18:37:01 +05:30
parent 2ca5afa214
commit f4884f8108
3 changed files with 867 additions and 10 deletions

View File

@@ -14,6 +14,19 @@ def enable_hub():
frappe.db.commit()
return hub_settings
@frappe.whitelist()
def call_hub_method(method, params=None):
connection = get_client_connection()
params = json.loads(params)
params.update({
'cmd': 'hub.hub.api.' + method
})
response = connection.post_api('hub.hub.api.' + method, params)
response = connection.post_request(params)
return response
@frappe.whitelist()
def get_list(doctype, start=0, limit=20, fields=["*"], filters="{}", order_by=None):
connection = get_client_connection()

View File

@@ -86,15 +86,20 @@ class HubSettings(Document):
post_url = hub_url + '/api/method/hub.hub.api.register'
response = requests.post(post_url, data=data, headers = {'accept': 'application/json'})
response.raise_for_status()
if response.ok:
message = response.json().get('message')
else:
frappe.throw(json.loads(response.text))
return message.get('password') if message else None
if message.get('email'):
self.create_hub_connector(message)
self.registered = 1
self.save()
return message or None
def unregister(self):
""" Disable the User on hub.erpnext.org"""
@@ -149,11 +154,6 @@ def sync():
def register_seller(**kwargs):
settings = frappe.get_doc('Hub Settings')
settings.update(kwargs)
password = settings.register()
message = settings.register()
print(password)
# if password:
# self.create_hub_connector(message)
# self.registered = 1
# self.save()
return message.get('email')