Merge branch 'hub-redesign' of https://github.com/frappe/erpnext into hub-redesign
This commit is contained in:
commit
89ed2d9b34
@ -119,39 +119,52 @@ def item_sync_postprocess():
|
|||||||
|
|
||||||
|
|
||||||
def load_base64_image_from_items(items):
|
def load_base64_image_from_items(items):
|
||||||
import io, base64, urllib, os
|
import io, base64, urllib, os, requests, tempfile
|
||||||
from frappe.utils.file_manager import get_file_path
|
from frappe.utils.file_manager import get_file_path
|
||||||
|
|
||||||
for item in items:
|
for item in items:
|
||||||
file_path = item['image']
|
file_path = item['image']
|
||||||
file_name = os.path.basename(file_path)
|
file_name = os.path.basename(file_path)
|
||||||
|
base64content = None
|
||||||
|
|
||||||
if file_path.startswith('http'):
|
if file_path.startswith('http'):
|
||||||
|
# fetch content and then base64 it
|
||||||
url = file_path
|
url = file_path
|
||||||
file_path = os.path.join('/tmp', file_name)
|
response = requests.get(url)
|
||||||
urllib.urlretrieve(url, file_path)
|
base64content = base64.b64encode(response.content)
|
||||||
else:
|
else:
|
||||||
|
# read file then base64 it
|
||||||
file_path = os.path.abspath(get_file_path(file_path))
|
file_path = os.path.abspath(get_file_path(file_path))
|
||||||
|
with io.open(file_path, 'rb') as f:
|
||||||
|
base64content = base64.b64encode(f.read())
|
||||||
|
|
||||||
with io.open(file_path, 'rb') as f:
|
image_data = json.dumps({
|
||||||
image_data = json.dumps({
|
'file_name': file_name,
|
||||||
'file_name': file_name,
|
'base64': base64content
|
||||||
'base64': base64.b64encode(f.read())
|
})
|
||||||
})
|
|
||||||
|
|
||||||
item['image'] = image_data
|
item['image'] = image_data
|
||||||
|
|
||||||
|
|
||||||
def get_hub_connection():
|
def get_hub_connection():
|
||||||
|
read_only = True
|
||||||
|
|
||||||
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_connection = hub_connector.get_connection()
|
|
||||||
return hub_connection.connection
|
# full rights to user who registered as hub_seller
|
||||||
|
if hub_connector.username == frappe.session.user:
|
||||||
|
read_only = False
|
||||||
|
|
||||||
|
if not read_only:
|
||||||
|
hub_connection = hub_connector.get_connection()
|
||||||
|
return hub_connection.connection
|
||||||
|
|
||||||
# read-only connection
|
# read-only connection
|
||||||
hub_connection = FrappeClient(frappe.conf.hub_url)
|
if read_only:
|
||||||
return hub_connection
|
hub_url = frappe.db.get_single_value('Hub Settings', 'hub_url')
|
||||||
|
hub_connection = FrappeClient(hub_url)
|
||||||
|
return hub_connection
|
||||||
|
|
||||||
def get_field_mappings():
|
def get_field_mappings():
|
||||||
return []
|
return []
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
frappe.ui.form.on("Hub Settings", {
|
frappe.ui.form.on("Hub Settings", {
|
||||||
refresh: function(frm) {
|
|
||||||
frm.disable_save();
|
|
||||||
},
|
|
||||||
|
|
||||||
onload_post_render: function(frm) {
|
onload_post_render: function(frm) {
|
||||||
if(frm.get_field("unregister_from_hub").$input)
|
if(frm.get_field("unregister_from_hub").$input)
|
||||||
frm.get_field("unregister_from_hub").$input.addClass("btn-danger");
|
frm.get_field("unregister_from_hub").$input.addClass("btn-danger");
|
||||||
|
@ -12,6 +12,39 @@
|
|||||||
"document_type": "",
|
"document_type": "",
|
||||||
"editable_grid": 0,
|
"editable_grid": 0,
|
||||||
"fields": [
|
"fields": [
|
||||||
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
|
"default": "https://hubmarket.org",
|
||||||
|
"fieldname": "hub_url",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_global_search": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"in_standard_filter": 0,
|
||||||
|
"label": "Hub URL",
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"remember_last_selected_value": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"translatable": 0,
|
||||||
|
"unique": 0
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
"allow_in_quick_entry": 0,
|
"allow_in_quick_entry": 0,
|
||||||
@ -76,38 +109,6 @@
|
|||||||
"translatable": 0,
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_in_quick_entry": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"fieldname": "company_registered",
|
|
||||||
"fieldtype": "Check",
|
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 0,
|
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "Company Registered",
|
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"precision": "",
|
|
||||||
"print_hide": 0,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"read_only": 1,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 0,
|
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"translatable": 0,
|
|
||||||
"unique": 0
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
"allow_in_quick_entry": 0,
|
"allow_in_quick_entry": 0,
|
||||||
@ -334,203 +335,6 @@
|
|||||||
"translatable": 0,
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_in_quick_entry": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"fieldname": "users_sb",
|
|
||||||
"fieldtype": "Section Break",
|
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 0,
|
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "Enabled Users",
|
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"precision": "",
|
|
||||||
"print_hide": 0,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 0,
|
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"translatable": 0,
|
|
||||||
"unique": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_in_quick_entry": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"depends_on": "",
|
|
||||||
"fieldname": "publish_section",
|
|
||||||
"fieldtype": "Section Break",
|
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 0,
|
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "Publish",
|
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"precision": "",
|
|
||||||
"print_hide": 0,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 0,
|
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"translatable": 0,
|
|
||||||
"unique": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_in_quick_entry": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"fieldname": "publish",
|
|
||||||
"fieldtype": "Check",
|
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 0,
|
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "Publish Items to Hub",
|
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"precision": "",
|
|
||||||
"print_hide": 0,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 0,
|
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"translatable": 0,
|
|
||||||
"unique": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_in_quick_entry": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"depends_on": "publish",
|
|
||||||
"fieldname": "publish_pricing",
|
|
||||||
"fieldtype": "Check",
|
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 0,
|
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "Publish Pricing",
|
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"precision": "",
|
|
||||||
"print_hide": 0,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 0,
|
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"translatable": 0,
|
|
||||||
"unique": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_in_quick_entry": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"depends_on": "eval:(doc.publish && doc.publish_pricing)",
|
|
||||||
"fieldname": "selling_price_list",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 0,
|
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "Selling Price List",
|
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"options": "Price List",
|
|
||||||
"permlevel": 0,
|
|
||||||
"precision": "",
|
|
||||||
"print_hide": 0,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 0,
|
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"translatable": 0,
|
|
||||||
"unique": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_in_quick_entry": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"depends_on": "publish",
|
|
||||||
"fieldname": "publish_availability",
|
|
||||||
"fieldtype": "Check",
|
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 0,
|
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "Publish Availability",
|
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"precision": "",
|
|
||||||
"print_hide": 0,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 0,
|
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"translatable": 0,
|
|
||||||
"unique": 0
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
"allow_in_quick_entry": 0,
|
"allow_in_quick_entry": 0,
|
||||||
@ -675,7 +479,7 @@
|
|||||||
"issingle": 1,
|
"issingle": 1,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2018-07-30 10:43:28.818498",
|
"modified": "2018-08-29 17:46:30.413159",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Hub Node",
|
"module": "Hub Node",
|
||||||
"name": "Hub Settings",
|
"name": "Hub Settings",
|
||||||
@ -709,5 +513,6 @@
|
|||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
"track_changes": 1,
|
"track_changes": 1,
|
||||||
"track_seen": 0
|
"track_seen": 0,
|
||||||
|
"track_views": 0
|
||||||
}
|
}
|
@ -15,22 +15,19 @@ class HubSetupError(frappe.ValidationError): pass
|
|||||||
class HubSettings(Document):
|
class HubSettings(Document):
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
protocol = 'http://'
|
self.site_name = frappe.utils.get_url()
|
||||||
self.site_name = protocol + frappe.local.site + ':' + str(frappe.conf.webserver_port)
|
|
||||||
if self.publish_pricing and not self.selling_price_list:
|
|
||||||
frappe.throw(_("Please select a Price List to publish pricing"))
|
|
||||||
|
|
||||||
def get_hub_url(self):
|
def get_hub_url(self):
|
||||||
if not frappe.conf.hub_url:
|
return self.hub_url
|
||||||
frappe.throw('hub_url is not set in site_config')
|
|
||||||
return frappe.conf.hub_url
|
|
||||||
|
|
||||||
def register(self):
|
def register(self):
|
||||||
""" Create a User on hub.erpnext.org and return username/password """
|
""" Create a User on hub.erpnext.org and return username/password """
|
||||||
|
|
||||||
|
if 'System Manager' not in frappe.get_roles():
|
||||||
|
frappe.throw(_('Only users with System Manager role can register on Marketplace'), frappe.PermissionError)
|
||||||
|
|
||||||
# TODO: site_name for cloud sites
|
# TODO: site_name for cloud sites
|
||||||
protocol = 'http://'
|
self.site_name = frappe.utils.get_url()
|
||||||
self.site_name = protocol + frappe.local.site + ':' + str(frappe.conf.webserver_port)
|
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'profile': self.as_json()
|
'profile': self.as_json()
|
||||||
|
@ -559,3 +559,4 @@ erpnext.patches.v11_0.add_item_group_defaults
|
|||||||
erpnext.patches.v10_0.update_address_template_for_india
|
erpnext.patches.v10_0.update_address_template_for_india
|
||||||
execute:frappe.delete_doc("Page", "hub")
|
execute:frappe.delete_doc("Page", "hub")
|
||||||
erpnext.patches.v11_0.reset_publish_in_hub_for_all_items
|
erpnext.patches.v11_0.reset_publish_in_hub_for_all_items
|
||||||
|
erpnext.patches.v11_0.update_hub_url
|
5
erpnext/patches/v11_0/update_hub_url.py
Normal file
5
erpnext/patches/v11_0/update_hub_url.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import frappe
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
frappe.reload_doc('hub_node', 'doctype', 'Hub Settings')
|
||||||
|
frappe.db.set_value('Hub Settings', 'Hub Settings', 'hub_url', 'https://hubmarket.org')
|
@ -29,8 +29,8 @@ erpnext.hub.Marketplace = class Marketplace {
|
|||||||
this.make_body();
|
this.make_body();
|
||||||
this.setup_events();
|
this.setup_events();
|
||||||
this.refresh();
|
this.refresh();
|
||||||
if (!is_registered) {
|
if (!is_registered && frappe.user_roles.includes('System Manager')) {
|
||||||
this.page.set_primary_action('Become A Seller', this.show_register_dialog.bind(this))
|
this.page.set_primary_action('Become a Seller', this.show_register_dialog.bind(this))
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user