diff --git a/erpnext/hub_node/api.py b/erpnext/hub_node/api.py index dc42de76bdc..af34844d46b 100644 --- a/erpnext/hub_node/api.py +++ b/erpnext/hub_node/api.py @@ -15,8 +15,9 @@ from six import string_types current_user = frappe.session.user + @frappe.whitelist() -def register_seller(**kwargs): +def register_marketplace(**kwargs): settings = frappe.get_single('Marketplace Settings') settings.update(kwargs) settings.users = [] @@ -42,6 +43,12 @@ def register_seller(**kwargs): return message + +@frappe.whitelist() +def register_user(username, first_name, company): + pass + + def validate_registerer(): if current_user == 'Administrator': frappe.throw(_('Please login as another user to register on Marketplace')) @@ -49,6 +56,7 @@ def validate_registerer(): if 'System Manager' not in frappe.get_roles(): frappe.throw(_('Only users with System Manager role can register on Marketplace'), frappe.PermissionError) + @frappe.whitelist() def call_hub_method(method, params=None): connection = get_hub_connection() @@ -63,6 +71,7 @@ def call_hub_method(method, params=None): response = connection.post_request(params) return response + def map_fields(items): field_mappings = get_field_mappings() table_fields = [d.fieldname for d in frappe.get_meta('Item').get_table_fields()] @@ -87,6 +96,7 @@ def map_fields(items): return items + @frappe.whitelist() def get_valid_items(search_value=''): items = frappe.get_list( @@ -111,6 +121,7 @@ def get_valid_items(search_value=''): return valid_items + @frappe.whitelist() def publish_selected_items(items_to_publish): items_to_publish = json.loads(items_to_publish) @@ -128,7 +139,6 @@ def publish_selected_items(items_to_publish): 'image_list': item.get('image_list') }).insert(ignore_if_duplicate=True) - items = map_fields(items_to_publish) try: @@ -143,6 +153,7 @@ def publish_selected_items(items_to_publish): except Exception as e: frappe.log_error(message=e, title='Hub Sync Error') + def item_sync_preprocess(intended_item_publish_count): response = call_hub_method('pre_items_publish', { 'intended_item_publish_count': intended_item_publish_count @@ -154,6 +165,7 @@ def item_sync_preprocess(intended_item_publish_count): else: frappe.throw('Unable to update remote activity') + def item_sync_postprocess(): response = call_hub_method('post_items_publish', {}) if response: @@ -192,7 +204,10 @@ def load_base64_image_from_items(items): def get_hub_connection(): settings = frappe.get_single('Marketplace Settings') marketplace_url = settings.marketplace_url - current_user_records = filter(lambda x: x.user == current_user, settings.users) + current_user_records = filter( + lambda x: x.user == current_user and x.password, + settings.users + ) if current_user_records: record = current_user_records[0] diff --git a/erpnext/hub_node/doctype/hub_user/hub_user.json b/erpnext/hub_node/doctype/hub_user/hub_user.json index 4e4deffe8b8..08a59c6958c 100644 --- a/erpnext/hub_node/doctype/hub_user/hub_user.json +++ b/erpnext/hub_node/doctype/hub_user/hub_user.json @@ -69,7 +69,7 @@ "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, - "read_only": 0, + "read_only": 1, "remember_last_selected_value": 0, "report_hide": 0, "reqd": 0, @@ -101,7 +101,7 @@ "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, - "read_only": 0, + "read_only": 1, "remember_last_selected_value": 0, "report_hide": 0, "reqd": 0, @@ -121,7 +121,7 @@ "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2018-08-31 20:39:55.944828", + "modified": "2018-09-01 09:46:54.327880", "modified_by": "cave@aperture.com", "module": "Hub Node", "name": "Hub User", diff --git a/erpnext/public/js/hub/marketplace.js b/erpnext/public/js/hub/marketplace.js index a4f38c721e6..bea30bd9422 100644 --- a/erpnext/public/js/hub/marketplace.js +++ b/erpnext/public/js/hub/marketplace.js @@ -92,16 +92,16 @@ erpnext.hub.Marketplace = class Marketplace { __('Become a Seller'), { label: __('Register'), - on_submit: this.register_seller.bind(this) + on_submit: this.register_marketplace.bind(this) } ); this.register_dialog.show(); } - register_seller(form_values) { + register_marketplace(form_values) { frappe.call({ - method: 'erpnext.hub_node.api.register_seller', + method: 'erpnext.hub_node.api.register_marketplace', args: form_values }).then(() => { this.register_dialog.hide();