diff --git a/erpnext/hub_node/doctype/hub_settings/hub_settings.json b/erpnext/hub_node/doctype/hub_settings/hub_settings.json index 61ef48ca54..a5338e9b3e 100644 --- a/erpnext/hub_node/doctype/hub_settings/hub_settings.json +++ b/erpnext/hub_node/doctype/hub_settings/hub_settings.json @@ -173,6 +173,38 @@ "translatable": 0, "unique": 0 }, + { + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "site_name", + "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": "Site Name", + "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_in_quick_entry": 0, @@ -643,7 +675,7 @@ "issingle": 1, "istable": 0, "max_attachments": 0, - "modified": "2018-07-26 15:56:36.104768", + "modified": "2018-07-28 00:48:21.210413", "modified_by": "cave@aperture.com", "module": "Hub Node", "name": "Hub Settings", diff --git a/erpnext/hub_node/doctype/hub_settings/hub_settings.py b/erpnext/hub_node/doctype/hub_settings/hub_settings.py index 621229cb33..0b7dc48b15 100644 --- a/erpnext/hub_node/doctype/hub_settings/hub_settings.py +++ b/erpnext/hub_node/doctype/hub_settings/hub_settings.py @@ -15,24 +15,13 @@ from six import string_types # hub_url = "http://erpnext.hub:8001" hub_url = "http://hub.market:8000" -class OAuth2Session(): - def __init__(self, headers): - self.headers = headers - def get(self, url, params, headers, verify): - res = requests.get(url, params=params, headers=self.headers, verify=verify) - return res - def post(self, url, data, verify): - res = requests.post(url, data=data, headers=self.headers, verify=verify) - return res - def put(self, url, data, verify): - res = requests.put(url, data=data, headers=self.headers, verify=verify) - return res - class HubSetupError(frappe.ValidationError): pass class HubSettings(Document): def validate(self): + protocol = 'http://' + 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")) @@ -53,35 +42,13 @@ class HubSettings(Document): doc.run() # self.sync_in_progress = 0 - def pre_reg(self): - site_name = frappe.local.site + ':' + str(frappe.conf.webserver_port) - protocol = 'http://' - route = '/token' - data = { - 'site_name': site_name, - 'protocol': protocol, - 'route': route - } - - redirect_url = protocol + site_name + route - post_url = hub_url + '/api/method/hub.hub.api.pre_reg' - - response = requests.post(post_url, data=data) - response.raise_for_status() - message = response.json().get('message') - - if message and message.get('client_id'): - print("======CLIENT_ID======") - print(message.get('client_id')) - - return { - 'client_id': message.get('client_id'), - 'redirect_uri': redirect_url - } - - def register(self): """ Create a User on hub.erpnext.org and return username/password """ + + # TODO: site_name for cloud sites + protocol = 'http://' + self.site_name = protocol + frappe.local.site + ':' + str(frappe.conf.webserver_port) + data = { 'profile': self.as_json() } @@ -103,18 +70,18 @@ class HubSettings(Document): return message or None - def unregister(self): - """ Disable the User on hub.erpnext.org""" + # def unregister(self): + # """ Disable the User on hub.erpnext.org""" - hub_connector = frappe.get_doc( - 'Data Migration Connector', 'Hub Connector') + # hub_connector = frappe.get_doc( + # 'Data Migration Connector', 'Hub Connector') - connection = hub_connector.get_connection() - response_doc = connection.update('User', frappe._dict({'enabled': 0}), hub_connector.username) + # connection = hub_connector.get_connection() + # response_doc = connection.update('User', frappe._dict({'enabled': 0}), hub_connector.username) - if response_doc['enabled'] == 0: - self.enabled = 0 - self.save() + # if response_doc['enabled'] == 0: + # self.enabled = 0 + # self.save() def create_hub_connector(self, message): if frappe.db.exists('Data Migration Connector', 'Hub Connector'): diff --git a/erpnext/public/js/hub/marketplace.js b/erpnext/public/js/hub/marketplace.js index cb879eb720..7363afb912 100644 --- a/erpnext/public/js/hub/marketplace.js +++ b/erpnext/public/js/hub/marketplace.js @@ -8,7 +8,7 @@ erpnext.hub.Marketplace = class Marketplace { frappe.db.get_doc('Hub Settings') .then(doc => { - this.hub_settings = doc; + hub.settings = doc; this.registered = doc.registered; this.setup_header(); @@ -158,14 +158,15 @@ erpnext.hub.Marketplace = class Marketplace { } if (route[1] === 'profile' && !this.subpages.profile) { - this.subpages.profile = new erpnext.hub.Profile(this.$body, {data: this.hub_settings}); + this.subpages.profile = new erpnext.hub.Profile(this.$body); } if (route[1] === 'publish' && !this.subpages.publish) { - this.subpages.publish = new erpnext.hub.Publish( - this.$body, - {sync_in_progress: this.hub_settings.sync_in_progress} - ); + this.subpages.publish = new erpnext.hub.Publish(this.$body); + } + + if (route[1] === 'my-products' && !this.subpages['my-products']) { + this.subpages['my-products'] = new erpnext.hub.PublishedProducts(this.$body); } if (!Object.keys(this.subpages).includes(route[1])) { @@ -650,13 +651,12 @@ erpnext.hub.Register = class Register extends SubPage { } erpnext.hub.Profile = class Profile extends SubPage { - constructor(parent, profile_data) { - super(parent); - this.profile_data = profile_data; - } - make_wrapper() { super.make_wrapper(); + + // Shorthand for profile data; + const p = hub.settings; + const profile_html = `
@@ -696,21 +696,16 @@ erpnext.hub.Profile = class Profile extends SubPage { } erpnext.hub.Publish = class Publish extends SubPage { - make_wrapper(options) { - super.make_wrapper(); - this.sync_in_progress = options.sync_in_progress; - - this.load_publish_page(); - } - load_publish_page() { const title_html = `${__('Select Products to Publish')}`; + const info = `

${__("Status decided by the 'Publish in Hub' field in Item.")}

`; - const subtitle_html = ` -

+ + const subtitle_html = `

${__(`Only products with an image, description and category can be published. Please update them if an item in your inventory does not appear.`)}

`; + const publish_button_html = `