Merge branch 'hub-redesign' of https://github.com/frappe/erpnext into hub-redesign
This commit is contained in:
		
						commit
						ff8f1c6120
					
				| @ -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") | ||||
|  | ||||
| @ -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 | ||||
| 
 | ||||
| @ -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){ | ||||
|  | ||||
| @ -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 | ||||
| 
 | ||||
|  | ||||
| @ -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; | ||||
| 	} | ||||
| 
 | ||||
| </style> | ||||
|  | ||||
| @ -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
 | ||||
|  | ||||
| @ -21,12 +21,12 @@ frappe.views.marketplaceFactory = class marketplaceFactory extends frappe.views. | ||||
| 			}); | ||||
| 		}); | ||||
| 	} | ||||
| } | ||||
| }; | ||||
| 
 | ||||
| $(document).on('toolbar_setup', () => { | ||||
| 	$('#toolbar-user .navbar-reload').after(` | ||||
| 		<li> | ||||
| 			<a href="#marketplace/home">${__('Marketplace')} | ||||
| 		</li> | ||||
| 	`)
 | ||||
| }) | ||||
| 	`);
 | ||||
| }); | ||||
|  | ||||
| @ -3,6 +3,7 @@ | ||||
| body[data-route^="marketplace/"] { | ||||
| 	.layout-side-section { | ||||
| 		padding-top: 25px; | ||||
| 		padding-left: 5px; | ||||
| 		padding-right: 25px; | ||||
| 	} | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user