mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-18 12:39:18 +00:00
Marketplace
- Cache hub calls - call_hub_method using FrappeClient connection - Become a seller UX fixes
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user