mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-27 17:04:47 +00:00
[hub] fix merge conflicts
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import frappe, io, base64, urllib, os
|
import frappe, io, base64, urllib, os, json
|
||||||
|
from frappe.utils.file_manager import get_file_path
|
||||||
|
|
||||||
def pre_process(doc):
|
def pre_process(doc):
|
||||||
|
|
||||||
@@ -9,11 +10,17 @@ def pre_process(doc):
|
|||||||
url = file_path
|
url = file_path
|
||||||
file_path = os.path.join('/tmp', file_name)
|
file_path = os.path.join('/tmp', file_name)
|
||||||
urllib.urlretrieve(url, file_path)
|
urllib.urlretrieve(url, file_path)
|
||||||
|
else:
|
||||||
|
file_path = os.path.abspath(get_file_path(file_path))
|
||||||
|
|
||||||
with io.open(file_path, 'rb') as f:
|
try:
|
||||||
doc.image = base64.b64encode(f.read())
|
with io.open(file_path, 'rb') as f:
|
||||||
|
doc.image = json.dumps({
|
||||||
doc.image_file_name = file_name
|
'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)
|
cached_details = frappe.get_doc('Hub Tracked Item', doc.item_code)
|
||||||
|
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ class HubSettings(Document):
|
|||||||
def create_hub_connector(self, message):
|
def create_hub_connector(self, message):
|
||||||
if frappe.db.exists('Data Migration Connector', 'Hub Connector'):
|
if frappe.db.exists('Data Migration Connector', 'Hub Connector'):
|
||||||
hub_connector = frappe.get_doc('Data Migration Connector', 'Hub Connector')
|
hub_connector = frappe.get_doc('Data Migration Connector', 'Hub Connector')
|
||||||
|
hub_connector.hostname = self.get_hub_url()
|
||||||
hub_connector.username = message['email']
|
hub_connector.username = message['email']
|
||||||
hub_connector.password = message['password']
|
hub_connector.password = message['password']
|
||||||
hub_connector.save()
|
hub_connector.save()
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
// rename this file from _test_[name] to test_[name] to activate
|
|
||||||
// and remove above this line
|
|
||||||
|
|
||||||
QUnit.test("test: Hub Tracked Item", function (assert) {
|
|
||||||
let done = assert.async();
|
|
||||||
|
|
||||||
// number of asserts
|
|
||||||
assert.expect(1);
|
|
||||||
|
|
||||||
frappe.run_serially([
|
|
||||||
// insert a new Hub Tracked Item
|
|
||||||
() => frappe.tests.make('Hub Tracked Item', [
|
|
||||||
// values to be set
|
|
||||||
{key: 'value'}
|
|
||||||
]),
|
|
||||||
() => {
|
|
||||||
assert.equal(cur_frm.doc.key, 'value');
|
|
||||||
},
|
|
||||||
() => done()
|
|
||||||
]);
|
|
||||||
|
|
||||||
});
|
|
||||||
@@ -21,7 +21,7 @@ function get_item_card_html(item) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const item_html = `
|
const item_html = `
|
||||||
<div class="col-md-3 col-sm-4 col-xs-6">
|
<div class="col-md-3 col-sm-4 col-xs-6 hub-card-container">
|
||||||
<div class="hub-card"
|
<div class="hub-card"
|
||||||
data-hub-item-code="${item.hub_item_code}"
|
data-hub-item-code="${item.hub_item_code}"
|
||||||
data-route="${item.route}">
|
data-route="${item.route}">
|
||||||
@@ -74,7 +74,7 @@ function get_local_item_card_html(item) {
|
|||||||
</div>`;
|
</div>`;
|
||||||
|
|
||||||
const item_html = `
|
const item_html = `
|
||||||
<div class="col-md-3 col-sm-4 col-xs-6">
|
<div class="col-md-3 col-sm-4 col-xs-6 hub-card-container">
|
||||||
<div class="hub-card is-local ${is_active ? 'active' : ''}" data-id="${id}">
|
<div class="hub-card is-local ${is_active ? 'active' : ''}" data-id="${id}">
|
||||||
<div class="hub-card-header flex">
|
<div class="hub-card-header flex">
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -149,8 +149,10 @@ erpnext.hub.Marketplace = class Marketplace {
|
|||||||
|
|
||||||
update_sidebar() {
|
update_sidebar() {
|
||||||
const route = frappe.get_route();
|
const route = frappe.get_route();
|
||||||
const route_str = route.slice(0, 2).join('/');
|
const route_str = route.join('/');
|
||||||
const $sidebar_item = this.$sidebar.find(`[data-route="${route_str}"]`);
|
const part_route_str = route.slice(0, 2).join('/');
|
||||||
|
const $sidebar_item = this.$sidebar.find(`[data-route="${route_str}"], [data-route="${part_route_str}"]`);
|
||||||
|
|
||||||
|
|
||||||
const $siblings = this.$sidebar.find('[data-route]');
|
const $siblings = this.$sidebar.find('[data-route]');
|
||||||
$siblings.removeClass('active').addClass('text-muted');
|
$siblings.removeClass('active').addClass('text-muted');
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ erpnext.hub.Item = class Item extends SubPage {
|
|||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
d.hide();
|
d.hide();
|
||||||
frappe.set_route('marketplace', 'messages');
|
frappe.set_route('marketplace', 'buy', this.item.hub_item_code);
|
||||||
erpnext.hub.trigger('action:send_message')
|
erpnext.hub.trigger('action:send_message')
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ erpnext.hub.Publish = class Publish extends SubPage {
|
|||||||
show_publish_progress() {
|
show_publish_progress() {
|
||||||
const items_to_publish = this.items_data_to_publish.length
|
const items_to_publish = this.items_data_to_publish.length
|
||||||
? this.items_data_to_publish
|
? this.items_data_to_publish
|
||||||
: JSON.parse(hub.settings.custom_data);
|
: JSON.parse(hub.settings.custom_data || '[]');
|
||||||
|
|
||||||
const $publish_progress = $(`<div class="sync-progress">
|
const $publish_progress = $(`<div class="sync-progress">
|
||||||
<p><b>${__(`Syncing ${items_to_publish.length} Products`)}</b></p>
|
<p><b>${__(`Syncing ${items_to_publish.length} Products`)}</b></p>
|
||||||
@@ -226,7 +226,14 @@ erpnext.hub.Publish = class Publish extends SubPage {
|
|||||||
|
|
||||||
items.map(item => {
|
items.map(item => {
|
||||||
this.fetched_items_dict[item.item_code] = item;
|
this.fetched_items_dict[item.item_code] = item;
|
||||||
})
|
});
|
||||||
|
|
||||||
|
// remove the items which doesn't have a valid image
|
||||||
|
setTimeout(() => {
|
||||||
|
items_container.find('.no-image').each(function() {
|
||||||
|
$(this).closest('.hub-card-container').remove();
|
||||||
|
});
|
||||||
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
get_valid_items() {
|
get_valid_items() {
|
||||||
|
|||||||
Reference in New Issue
Block a user