From 25f509ebd31da584144c5b1b7a325e609bd51ba3 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Fri, 31 Aug 2018 15:35:32 +0530 Subject: [PATCH 1/2] feat: Add disable marketplace option in Hub Settings --- .../doctype/hub_settings/hub_settings.js | 4 +- .../doctype/hub_settings/hub_settings.json | 74 +++++++++++++++++-- erpnext/public/js/hub/hub_factory.js | 34 +++++++-- 3 files changed, 99 insertions(+), 13 deletions(-) diff --git a/erpnext/hub_node/doctype/hub_settings/hub_settings.js b/erpnext/hub_node/doctype/hub_settings/hub_settings.js index 089f499919..445f5a831d 100644 --- a/erpnext/hub_node/doctype/hub_settings/hub_settings.js +++ b/erpnext/hub_node/doctype/hub_settings/hub_settings.js @@ -1,3 +1,5 @@ frappe.ui.form.on("Hub Settings", { - onload_post_render: function() {}, + refresh: function(frm) { + $('#toolbar-user .marketplace-link').toggle(!frm.doc.disable_marketplace); + }, }); diff --git a/erpnext/hub_node/doctype/hub_settings/hub_settings.json b/erpnext/hub_node/doctype/hub_settings/hub_settings.json index e230515aae..cd2c5e8acb 100644 --- a/erpnext/hub_node/doctype/hub_settings/hub_settings.json +++ b/erpnext/hub_node/doctype/hub_settings/hub_settings.json @@ -12,6 +12,71 @@ "document_type": "", "editable_grid": 0, "fields": [ + { + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "disable_marketplace", + "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": "Disable Marketplace", + "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.disable_marketplace", + "fieldname": "marketplace_settings_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": "Marketplace Settings", + "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, @@ -86,7 +151,7 @@ "columns": 0, "fieldname": "sync_in_progress", "fieldtype": "Check", - "hidden": 0, + "hidden": 1, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, @@ -479,8 +544,8 @@ "issingle": 1, "istable": 0, "max_attachments": 0, - "modified": "2018-08-29 17:46:30.413159", - "modified_by": "Administrator", + "modified": "2018-08-31 02:40:41.244423", + "modified_by": "ameya@coffee.com", "module": "Hub Node", "name": "Hub Settings", "name_case": "", @@ -513,6 +578,5 @@ "sort_field": "modified", "sort_order": "DESC", "track_changes": 1, - "track_seen": 0, - "track_views": 0 + "track_seen": 0 } \ No newline at end of file diff --git a/erpnext/public/js/hub/hub_factory.js b/erpnext/public/js/hub/hub_factory.js index 57f27f982e..5c9178fa54 100644 --- a/erpnext/public/js/hub/hub_factory.js +++ b/erpnext/public/js/hub/hub_factory.js @@ -2,12 +2,20 @@ frappe.provide('erpnext.hub'); frappe.views.marketplaceFactory = class marketplaceFactory extends frappe.views.Factory { show() { - if (frappe.pages.marketplace) { - frappe.container.change_to('marketplace'); - erpnext.hub.marketplace.refresh(); - } else { - this.make('marketplace'); - } + is_marketplace_disabled() + .then(disabled => { + if (disabled) { + frappe.show_not_found('Marketplace'); + return; + } + + if (frappe.pages.marketplace) { + frappe.container.change_to('marketplace'); + erpnext.hub.marketplace.refresh(); + } else { + this.make('marketplace'); + } + }); } make(page_name) { @@ -23,10 +31,22 @@ frappe.views.marketplaceFactory = class marketplaceFactory extends frappe.views. } }; +function is_marketplace_disabled() { + return frappe.model.with_doc('Hub Settings') + .then(doc => doc.disable_marketplace); +} + $(document).on('toolbar_setup', () => { $('#toolbar-user .navbar-reload').after(`
  • - ${__('Marketplace')} + ${__('Marketplace')}
  • `); + + is_marketplace_disabled() + .then(disabled => { + if (disabled) { + $('#toolbar-user .marketplace-link').hide(); + } + }); }); From f9a66c1c362b96f0105f790299848ff1de302160 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Fri, 31 Aug 2018 16:15:06 +0530 Subject: [PATCH 2/2] fix: Rename Hub Settings -> Marketplace Settings --- erpnext/config/hub_node.py | 6 +- erpnext/hub_node/__init__.py | 4 +- erpnext/hub_node/api.py | 10 +-- .../doctype/hub_settings/hub_settings.js | 5 -- .../doctype/hub_settings/test_hub_settings.js | 23 ----- .../doctype/hub_settings/test_hub_settings.py | 10 --- .../__init__.py | 0 .../marketplace_settings.js | 8 ++ .../marketplace_settings.json} | 84 +++---------------- .../marketplace_settings.py} | 22 +++-- erpnext/hub_node/legacy.py | 6 +- erpnext/patches.txt | 2 +- erpnext/patches/v11_0/update_hub_url.py | 4 +- erpnext/public/js/hub/hub_factory.js | 2 +- erpnext/public/js/hub/marketplace.js | 29 ++++--- erpnext/public/js/hub/pages/Publish.vue | 2 +- 16 files changed, 60 insertions(+), 157 deletions(-) delete mode 100644 erpnext/hub_node/doctype/hub_settings/hub_settings.js delete mode 100644 erpnext/hub_node/doctype/hub_settings/test_hub_settings.js delete mode 100644 erpnext/hub_node/doctype/hub_settings/test_hub_settings.py rename erpnext/hub_node/doctype/{hub_settings => marketplace_settings}/__init__.py (100%) create mode 100644 erpnext/hub_node/doctype/marketplace_settings/marketplace_settings.js rename erpnext/hub_node/doctype/{hub_settings/hub_settings.json => marketplace_settings/marketplace_settings.json} (86%) rename erpnext/hub_node/doctype/{hub_settings/hub_settings.py => marketplace_settings/marketplace_settings.py} (83%) diff --git a/erpnext/config/hub_node.py b/erpnext/config/hub_node.py index c9d5b97bf0..9b9fcc456c 100644 --- a/erpnext/config/hub_node.py +++ b/erpnext/config/hub_node.py @@ -8,16 +8,16 @@ def get_data(): "items": [ { "type": "doctype", - "name": "Hub Settings" + "name": "Marketplace Settings" }, ] }, { - "label": _("Hub"), + "label": _("Marketplace"), "items": [ { "type": "page", - "name": "hub" + "name": "marketplace/home" }, ] }, diff --git a/erpnext/hub_node/__init__.py b/erpnext/hub_node/__init__.py index 0ebbec7a0e..85ffe29d11 100644 --- a/erpnext/hub_node/__init__.py +++ b/erpnext/hub_node/__init__.py @@ -6,12 +6,12 @@ import frappe @frappe.whitelist() def enable_hub(): - hub_settings = frappe.get_doc('Hub Settings') + hub_settings = frappe.get_doc('Marketplace Settings') hub_settings.register() frappe.db.commit() return hub_settings @frappe.whitelist() def sync(): - hub_settings = frappe.get_doc('Hub Settings') + hub_settings = frappe.get_doc('Marketplace Settings') hub_settings.sync() diff --git a/erpnext/hub_node/api.py b/erpnext/hub_node/api.py index be81effe69..924d6d6cb8 100644 --- a/erpnext/hub_node/api.py +++ b/erpnext/hub_node/api.py @@ -24,7 +24,7 @@ def map_fields(items): field_mappings = get_field_mappings() table_fields = [d.fieldname for d in frappe.get_meta('Item').get_table_fields()] - hub_seller = frappe.db.get_value('Hub Settings' , 'Hub Settings', 'company_email') + hub_seller = frappe.db.get_value('Marketplace Settings' , 'Marketplace Settings', 'company_email') for item in items: for fieldname in table_fields: @@ -105,7 +105,7 @@ def item_sync_preprocess(intended_item_publish_count): }) if response: - frappe.db.set_value("Hub Settings", "Hub Settings", "sync_in_progress", 1) + frappe.db.set_value("Marketplace Settings", "Marketplace Settings", "sync_in_progress", 1) return response else: frappe.throw('Unable to update remote activity') @@ -113,11 +113,11 @@ def item_sync_preprocess(intended_item_publish_count): def item_sync_postprocess(): response = call_hub_method('post_items_publish', {}) if response: - frappe.db.set_value('Hub Settings', 'Hub Settings', 'last_sync_datetime', frappe.utils.now()) + frappe.db.set_value('Marketplace Settings', 'Marketplace Settings', 'last_sync_datetime', frappe.utils.now()) else: frappe.throw('Unable to update remote activity') - frappe.db.set_value('Hub Settings', 'Hub Settings', 'sync_in_progress', 0) + frappe.db.set_value('Marketplace Settings', 'Marketplace Settings', 'sync_in_progress', 0) def load_base64_image_from_items(items): @@ -161,7 +161,7 @@ def get_hub_connection(): # read-only connection if read_only: - hub_url = frappe.db.get_single_value('Hub Settings', 'hub_url') + hub_url = frappe.db.get_single_value('Marketplace Settings', 'hub_url') hub_connection = FrappeClient(hub_url) return hub_connection diff --git a/erpnext/hub_node/doctype/hub_settings/hub_settings.js b/erpnext/hub_node/doctype/hub_settings/hub_settings.js deleted file mode 100644 index 445f5a831d..0000000000 --- a/erpnext/hub_node/doctype/hub_settings/hub_settings.js +++ /dev/null @@ -1,5 +0,0 @@ -frappe.ui.form.on("Hub Settings", { - refresh: function(frm) { - $('#toolbar-user .marketplace-link').toggle(!frm.doc.disable_marketplace); - }, -}); diff --git a/erpnext/hub_node/doctype/hub_settings/test_hub_settings.js b/erpnext/hub_node/doctype/hub_settings/test_hub_settings.js deleted file mode 100644 index 546ce1504c..0000000000 --- a/erpnext/hub_node/doctype/hub_settings/test_hub_settings.js +++ /dev/null @@ -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 Settings", function (assert) { - let done = assert.async(); - - // number of asserts - assert.expect(1); - - frappe.run_serially('Hub Settings', [ - // insert a new Hub Settings - () => frappe.tests.make([ - // values to be set - {key: 'value'} - ]), - () => { - assert.equal(cur_frm.doc.key, 'value'); - }, - () => done() - ]); - -}); diff --git a/erpnext/hub_node/doctype/hub_settings/test_hub_settings.py b/erpnext/hub_node/doctype/hub_settings/test_hub_settings.py deleted file mode 100644 index 1299adc17e..0000000000 --- a/erpnext/hub_node/doctype/hub_settings/test_hub_settings.py +++ /dev/null @@ -1,10 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors -# See license.txt -from __future__ import unicode_literals - -import frappe -import unittest - -class TestHubSettings(unittest.TestCase): - pass diff --git a/erpnext/hub_node/doctype/hub_settings/__init__.py b/erpnext/hub_node/doctype/marketplace_settings/__init__.py similarity index 100% rename from erpnext/hub_node/doctype/hub_settings/__init__.py rename to erpnext/hub_node/doctype/marketplace_settings/__init__.py diff --git a/erpnext/hub_node/doctype/marketplace_settings/marketplace_settings.js b/erpnext/hub_node/doctype/marketplace_settings/marketplace_settings.js new file mode 100644 index 0000000000..36da832c7c --- /dev/null +++ b/erpnext/hub_node/doctype/marketplace_settings/marketplace_settings.js @@ -0,0 +1,8 @@ +// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors +// For license information, please see license.txt + +frappe.ui.form.on('Marketplace Settings', { + refresh: function(frm) { + $('#toolbar-user .marketplace-link').toggle(!frm.doc.disable_marketplace); + }, +}); diff --git a/erpnext/hub_node/doctype/hub_settings/hub_settings.json b/erpnext/hub_node/doctype/marketplace_settings/marketplace_settings.json similarity index 86% rename from erpnext/hub_node/doctype/hub_settings/hub_settings.json rename to erpnext/hub_node/doctype/marketplace_settings/marketplace_settings.json index cd2c5e8acb..febb5490ed 100644 --- a/erpnext/hub_node/doctype/hub_settings/hub_settings.json +++ b/erpnext/hub_node/doctype/marketplace_settings/marketplace_settings.json @@ -4,13 +4,14 @@ "allow_import": 0, "allow_rename": 0, "beta": 1, - "creation": "2015-02-18 00:59:34.560476", + "creation": "2018-08-31 15:54:38.795263", "custom": 0, "description": "", "docstatus": 0, "doctype": "DocType", "document_type": "", "editable_grid": 0, + "engine": "InnoDB", "fields": [ { "allow_bulk_edit": 0, @@ -85,7 +86,7 @@ "collapsible": 0, "columns": 0, "default": "https://hubmarket.org", - "fieldname": "hub_url", + "fieldname": "marketplace_url", "fieldtype": "Data", "hidden": 0, "ignore_user_permissions": 0, @@ -94,7 +95,7 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, - "label": "Hub URL", + "label": "Marketplace URL", "length": 0, "no_copy": 0, "permlevel": 0, @@ -466,72 +467,6 @@ "set_only_once": 0, "translatable": 0, "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 1, - "collapsible_depends_on": "", - "columns": 0, - "depends_on": "enabled", - "fieldname": "unregister_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": "Unregister", - "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": "unregister_from_hub", - "fieldtype": "Button", - "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": "Unregister from 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 } ], "has_web_view": 0, @@ -544,12 +479,12 @@ "issingle": 1, "istable": 0, "max_attachments": 0, - "modified": "2018-08-31 02:40:41.244423", - "modified_by": "ameya@coffee.com", + "modified": "2018-08-31 15:54:38.795263", + "modified_by": "netchamp@rawcoderz.com", "module": "Hub Node", - "name": "Hub Settings", + "name": "Marketplace Settings", "name_case": "", - "owner": "Administrator", + "owner": "netchamp@rawcoderz.com", "permissions": [ { "amend": 0, @@ -578,5 +513,6 @@ "sort_field": "modified", "sort_order": "DESC", "track_changes": 1, - "track_seen": 0 + "track_seen": 0, + "track_views": 0 } \ No newline at end of file diff --git a/erpnext/hub_node/doctype/hub_settings/hub_settings.py b/erpnext/hub_node/doctype/marketplace_settings/marketplace_settings.py similarity index 83% rename from erpnext/hub_node/doctype/hub_settings/hub_settings.py rename to erpnext/hub_node/doctype/marketplace_settings/marketplace_settings.py index ab0a7d24ff..9b83898536 100644 --- a/erpnext/hub_node/doctype/hub_settings/hub_settings.py +++ b/erpnext/hub_node/doctype/marketplace_settings/marketplace_settings.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors and contributors +# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors and contributors # For license information, please see license.txt from __future__ import unicode_literals @@ -10,15 +10,13 @@ from frappe import _ from erpnext.utilities.product import get_price, get_qty_in_stock from six import string_types -class HubSetupError(frappe.ValidationError): pass - -class HubSettings(Document): +class MarketplaceSettings(Document): def validate(self): self.site_name = frappe.utils.get_url() - def get_hub_url(self): - return self.hub_url + def get_marketplace_url(self): + return self.marketplace_url def register(self): """ Create a User on hub.erpnext.org and return username/password """ @@ -34,7 +32,7 @@ class HubSettings(Document): data = { 'profile': self.as_json() } - post_url = self.get_hub_url() + '/api/method/hub.hub.api.register' + post_url = self.get_marketplace_url() + '/api/method/hub.hub.api.register' response = requests.post(post_url, data=data, headers = {'accept': 'application/json'}) @@ -68,7 +66,7 @@ class HubSettings(Document): def create_hub_connector(self, message): if frappe.db.exists('Data Migration Connector', 'Hub Connector'): hub_connector = frappe.get_doc('Data Migration Connector', 'Hub Connector') - hub_connector.hostname = self.get_hub_url() + hub_connector.hostname = self.get_marketplace_url() hub_connector.username = message['email'] hub_connector.password = message['password'] hub_connector.save() @@ -78,19 +76,19 @@ class HubSettings(Document): 'doctype': 'Data Migration Connector', 'connector_type': 'Frappe', 'connector_name': 'Hub Connector', - 'hostname': self.get_hub_url(), + 'hostname': self.get_marketplace_url(), 'username': message['email'], 'password': message['password'] }).insert() def reset_hub_publishing_settings(last_sync_datetime = ""): - doc = frappe.get_doc("Hub Settings", "Hub Settings") + doc = frappe.get_doc("Marketplace Settings", "Marketplace Settings") doc.reset_publishing_settings(last_sync_datetime) doc.in_callback = 1 doc.save() def reset_hub_settings(last_sync_datetime = ""): - doc = frappe.get_doc("Hub Settings", "Hub Settings") + doc = frappe.get_doc("Marketplace Settings", "Marketplace Settings") doc.reset_publishing_settings(last_sync_datetime) doc.reset_enable() doc.in_callback = 1 @@ -99,7 +97,7 @@ def reset_hub_settings(last_sync_datetime = ""): @frappe.whitelist() def register_seller(**kwargs): - settings = frappe.get_doc('Hub Settings') + settings = frappe.get_doc('Marketplace Settings') settings.update(kwargs) message = settings.register() diff --git a/erpnext/hub_node/legacy.py b/erpnext/hub_node/legacy.py index 7218d3fce2..9daee2752f 100644 --- a/erpnext/hub_node/legacy.py +++ b/erpnext/hub_node/legacy.py @@ -101,7 +101,7 @@ def make_rfq(item, supplier, contact): 'doctype': 'Request for Quotation', 'transaction_date': nowdate(), 'status': 'Draft', - 'company': frappe.db.get_single_value('Hub Settings', 'company'), + 'company': frappe.db.get_single_value('Marketplace Settings', 'company'), 'message_for_supplier': 'Please supply the specified items at the best possible rates', 'suppliers': [ { 'supplier': supplier.name, 'contact': contact.name } @@ -126,8 +126,8 @@ def send_opportunity(contact): # Make Hub Message on Hub with lead data doc = { 'doctype': 'Lead', - 'lead_name': frappe.db.get_single_value('Hub Settings', 'company'), - 'email_id': frappe.db.get_single_value('Hub Settings', 'user') + 'lead_name': frappe.db.get_single_value('Marketplace Settings', 'company'), + 'email_id': frappe.db.get_single_value('Marketplace Settings', 'user') } args = frappe._dict(dict( diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 8e02e42295..9dd6bb5e43 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -559,6 +559,6 @@ erpnext.patches.v11_0.add_item_group_defaults erpnext.patches.v10_0.update_address_template_for_india execute:frappe.delete_doc("Page", "hub") erpnext.patches.v11_0.reset_publish_in_hub_for_all_items -erpnext.patches.v11_0.update_hub_url +erpnext.patches.v11_0.update_hub_url # 2018-08-31 erpnext.patches.v10_0.set_discount_amount erpnext.patches.v10_0.recalculate_gross_margin_for_project diff --git a/erpnext/patches/v11_0/update_hub_url.py b/erpnext/patches/v11_0/update_hub_url.py index ced2aaf7e0..abddfd6391 100644 --- a/erpnext/patches/v11_0/update_hub_url.py +++ b/erpnext/patches/v11_0/update_hub_url.py @@ -1,5 +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') + frappe.reload_doc('hub_node', 'doctype', 'Marketplace Settings') + frappe.db.set_value('Marketplace Settings', 'Marketplace Settings', 'hub_url', 'https://hubmarket.org') diff --git a/erpnext/public/js/hub/hub_factory.js b/erpnext/public/js/hub/hub_factory.js index 5c9178fa54..506d374f5e 100644 --- a/erpnext/public/js/hub/hub_factory.js +++ b/erpnext/public/js/hub/hub_factory.js @@ -32,7 +32,7 @@ frappe.views.marketplaceFactory = class marketplaceFactory extends frappe.views. }; function is_marketplace_disabled() { - return frappe.model.with_doc('Hub Settings') + return frappe.model.with_doc('Marketplace Settings') .then(doc => doc.disable_marketplace); } diff --git a/erpnext/public/js/hub/marketplace.js b/erpnext/public/js/hub/marketplace.js index cdf3d2332d..e062c6a31d 100644 --- a/erpnext/public/js/hub/marketplace.js +++ b/erpnext/public/js/hub/marketplace.js @@ -20,20 +20,19 @@ erpnext.hub.Marketplace = class Marketplace { this.$parent = $(parent); this.page = parent.page; - frappe.db.get_doc('Hub Settings') - .then(doc => { - hub.settings = doc; - const is_registered = hub.settings.registered; - const is_registered_seller = hub.settings.company_email === frappe.session.user; - this.setup_header(); - this.make_sidebar(); - this.make_body(); - this.setup_events(); - this.refresh(); - if (!is_registered && !is_registered_seller && frappe.user_roles.includes('System Manager')) { - this.page.set_primary_action('Become a Seller', this.show_register_dialog.bind(this)) - } - }); + frappe.model.with_doc('Marketplace Settings').then(doc => { + hub.settings = doc; + const is_registered = hub.settings.registered; + const is_registered_seller = hub.settings.company_email === frappe.session.user; + this.setup_header(); + this.make_sidebar(); + this.make_body(); + this.setup_events(); + this.refresh(); + if (!is_registered && !is_registered_seller && frappe.user_roles.includes('System Manager')) { + this.page.set_primary_action('Become a Seller', this.show_register_dialog.bind(this)) + } + }); } setup_header() { @@ -78,7 +77,7 @@ erpnext.hub.Marketplace = class Marketplace { erpnext.hub.on('seller-registered', () => { this.page.clear_primary_action() - frappe.db.get_doc('Hub Settings').then((doc)=> { + frappe.model.with_doc('Marketplace Settings').then((doc)=> { hub.settings = doc; }); }); diff --git a/erpnext/public/js/hub/pages/Publish.vue b/erpnext/public/js/hub/pages/Publish.vue index b05f12adb6..735f2b92ec 100644 --- a/erpnext/public/js/hub/pages/Publish.vue +++ b/erpnext/public/js/hub/pages/Publish.vue @@ -138,7 +138,7 @@ export default { ) .then((r) => { this.selected_items = []; - return frappe.db.get_doc('Hub Settings'); + return frappe.db.get_doc('Marketplace Settings'); }) .then(doc => { hub.settings = doc;