diff --git a/erpnext/hub_node/api.py b/erpnext/hub_node/api.py index 8b186afa3e..c46e6dce51 100644 --- a/erpnext/hub_node/api.py +++ b/erpnext/hub_node/api.py @@ -1,6 +1,5 @@ from __future__ import unicode_literals -import frappe, requests, json -from frappe.utils import now +import frappe, json from frappe.frappeclient import FrappeClient from frappe.desk.form.load import get_attachments from six import string_types @@ -62,7 +61,7 @@ def get_valid_items(search_value=''): item.attachments = get_attachments('Item', item.item_code) return item - valid_items = map(lambda x: prepare_item(x), valid_items) + valid_items = map(prepare_item, valid_items) return valid_items @@ -99,7 +98,7 @@ def publish_selected_items(items_to_publish): 'stats': len(items) }) except Exception as e: - frappe.log_error(title='Hub Sync Error') + frappe.log_error(message=e, title='Hub Sync Error') def item_sync_preprocess(): hub_seller = frappe.db.get_value("Hub Settings", "Hub Settings", "company_email") diff --git a/erpnext/hub_node/data_migration_mapping/item_to_hub_item/__init__.py b/erpnext/hub_node/data_migration_mapping/item_to_hub_item/__init__.py index eb57f3a98a..e69de29bb2 100644 --- a/erpnext/hub_node/data_migration_mapping/item_to_hub_item/__init__.py +++ b/erpnext/hub_node/data_migration_mapping/item_to_hub_item/__init__.py @@ -1,32 +0,0 @@ -import frappe, io, base64, urllib, os, json -from frappe.utils.file_manager import get_file_path - -def pre_process(doc): - - file_path = doc.image - file_name = os.path.basename(file_path) - - if file_path.startswith('http'): - url = file_path - file_path = os.path.join('/tmp', file_name) - urllib.urlretrieve(url, file_path) - else: - file_path = os.path.abspath(get_file_path(file_path)) - - try: - with io.open(file_path, 'rb') as f: - doc.image = json.dumps({ - 'file_name': file_name, - 'base64': base64.b64encode(f.read()) - }) - except Exception as e: - frappe.log_error(title='Hub Sync Error') - - cached_details = frappe.get_doc('Hub Tracked Item', doc.item_code) - - if cached_details: - doc.hub_category = cached_details.hub_category - doc.image_list = cached_details.image_list - - return doc - diff --git a/erpnext/hub_node/doctype/hub_settings/hub_settings.js b/erpnext/hub_node/doctype/hub_settings/hub_settings.js index 4bd3333276..ddd86b8711 100644 --- a/erpnext/hub_node/doctype/hub_settings/hub_settings.js +++ b/erpnext/hub_node/doctype/hub_settings/hub_settings.js @@ -1,23 +1,12 @@ frappe.ui.form.on("Hub Settings", { refresh: function(frm) { frm.disable_save(); - frm.add_custom_button(__('Logs'), - () => frappe.set_route('List', 'Data Migration Run', { - data_migration_plan: 'Hub Sync' - })); - - if (frm.doc.enabled) { - frm.add_custom_button(__('Sync'), - () => frm.call('sync')); - } }, - onload: function(frm) { }, + onload_post_render: function(frm) { if(frm.get_field("unregister_from_hub").$input) frm.get_field("unregister_from_hub").$input.addClass("btn-danger"); }, - on_update: function(frm) { - }, hub_user_email: function(frm) { if(frm.doc.hub_user_email){ diff --git a/erpnext/hub_node/legacy.py b/erpnext/hub_node/legacy.py index 06d20f344c..7218d3fce2 100644 --- a/erpnext/hub_node/legacy.py +++ b/erpnext/hub_node/legacy.py @@ -1,6 +1,6 @@ from __future__ import unicode_literals -import frappe, requests, json -from frappe.utils import now, nowdate +import frappe, json +from frappe.utils import nowdate from frappe.frappeclient import FrappeClient from frappe.utils.nestedset import get_root_of from frappe.contacts.doctype.contact.contact import get_default_contact @@ -18,56 +18,6 @@ def get_hub_connection(): hub_connection = FrappeClient(frappe.conf.hub_url) return hub_connection -@frappe.whitelist() -def get_item_favourites(start=0, limit=20, fields=["*"], order_by=None): - doctype = 'Hub Item' - hub_settings = frappe.get_doc('Hub Settings') - item_names_str = hub_settings.get('custom_data') or '[]' - item_names = json.loads(item_names_str) - filters = json.dumps({ - 'hub_item_code': ['in', item_names] - }) - return get_list(doctype, start, limit, fields, filters, order_by) - -@frappe.whitelist() -def update_wishlist_item(item_name, remove=0): - remove = int(remove) - hub_settings = frappe.get_doc('Hub Settings') - data = hub_settings.get('custom_data') - if not data or not json.loads(data): - data = '[]' - hub_settings.custom_data = data - hub_settings.save() - - item_names_str = data - item_names = json.loads(item_names_str) - if not remove and item_name not in item_names: - item_names.append(item_name) - if remove and item_name in item_names: - item_names.remove(item_name) - - item_names_str = json.dumps(item_names) - - hub_settings.custom_data = item_names_str - hub_settings.save() - -@frappe.whitelist() -def update_category(hub_item_code, category): - connection = get_hub_connection() - - # args = frappe._dict(dict( - # doctype='Hub Category', - # hub_category_name=category - # )) - # response = connection.insert('Hub Category', args) - - response = connection.update('Hub Item', frappe._dict(dict( - doctype='Hub Item', - hub_category = category - )), hub_item_code) - - return response - def make_opportunity(buyer_name, email_id): buyer_name = "HUB-" + buyer_name diff --git a/erpnext/public/js/hub/components/EmptyState.vue b/erpnext/public/js/hub/components/EmptyState.vue index 527194b99c..d6216c9ac7 100644 --- a/erpnext/public/js/hub/components/EmptyState.vue +++ b/erpnext/public/js/hub/components/EmptyState.vue @@ -42,6 +42,9 @@ export default { border-radius: 4px; border: 1px solid @border-color; border-style: dashed; + + // bad, due to item card column layout, that is inner 15px margin + margin: 0 15px; } diff --git a/erpnext/public/js/hub/hub_call.js b/erpnext/public/js/hub/hub_call.js index e461564f34..a8bfa2e854 100644 --- a/erpnext/public/js/hub/hub_call.js +++ b/erpnext/public/js/hub/hub_call.js @@ -2,7 +2,7 @@ frappe.provide('hub'); frappe.provide('erpnext.hub'); erpnext.hub.cache = {}; -hub.call = function call_hub_method(method, args={}, clear_cache_on_event) { +hub.call = function call_hub_method(method, args={}, clear_cache_on_event) { // eslint-disable-line return new Promise((resolve, reject) => { // cache @@ -18,7 +18,7 @@ hub.call = function call_hub_method(method, args={}, clear_cache_on_event) { invalidate_after_5_mins(clear_cache); } else { erpnext.hub.on(clear_cache_on_event, () => { - clear_cache(key) + clear_cache(key); }); } @@ -28,8 +28,7 @@ hub.call = function call_hub_method(method, args={}, clear_cache_on_event) { method, params: args } - }) - .then(r => { + }).then(r => { if (r.message) { const response = r.message; if (response.error) { @@ -44,10 +43,10 @@ hub.call = function call_hub_method(method, args={}, clear_cache_on_event) { resolve(response); } reject(r); - }) - .fail(reject) + + }).fail(reject); }); -} +}; function invalidate_after_5_mins(clear_cache) { // cache invalidation after 5 minutes diff --git a/erpnext/public/js/hub/hub_factory.js b/erpnext/public/js/hub/hub_factory.js index f933600375..57f27f982e 100644 --- a/erpnext/public/js/hub/hub_factory.js +++ b/erpnext/public/js/hub/hub_factory.js @@ -21,12 +21,12 @@ frappe.views.marketplaceFactory = class marketplaceFactory extends frappe.views. }); }); } -} +}; $(document).on('toolbar_setup', () => { $('#toolbar-user .navbar-reload').after(`