Merge pull request #15279 from netchampfaris/marketplace-fixes-3
- feat: Add disable marketplace option in Hub Settings - fix: Rename Hub Settings -> Marketplace Settings
This commit is contained in:
commit
c05bf262f1
@ -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"
|
||||
},
|
||||
]
|
||||
},
|
||||
|
@ -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()
|
||||
|
@ -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:
|
||||
@ -106,7 +106,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')
|
||||
@ -114,11 +114,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):
|
||||
@ -162,7 +162,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
|
||||
|
||||
|
@ -1,3 +0,0 @@
|
||||
frappe.ui.form.on("Hub Settings", {
|
||||
onload_post_render: function() {},
|
||||
});
|
@ -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()
|
||||
]);
|
||||
|
||||
});
|
@ -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
|
@ -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);
|
||||
},
|
||||
});
|
@ -4,14 +4,80 @@
|
||||
"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,
|
||||
"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,
|
||||
@ -20,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,
|
||||
@ -29,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,
|
||||
@ -86,7 +152,7 @@
|
||||
"columns": 0,
|
||||
"fieldname": "sync_in_progress",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 0,
|
||||
"hidden": 1,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
@ -401,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,
|
||||
@ -479,12 +479,12 @@
|
||||
"issingle": 1,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2018-08-29 17:46:30.413159",
|
||||
"modified_by": "Administrator",
|
||||
"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,
|
@ -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()
|
||||
|
@ -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(
|
||||
|
@ -560,6 +560,6 @@ erpnext.patches.v10_0.update_address_template_for_india
|
||||
erpnext.patches.v11_0.add_expense_claim_default_account
|
||||
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
|
||||
|
@ -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')
|
||||
|
@ -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('Marketplace Settings')
|
||||
.then(doc => doc.disable_marketplace);
|
||||
}
|
||||
|
||||
$(document).on('toolbar_setup', () => {
|
||||
$('#toolbar-user .navbar-reload').after(`
|
||||
<li>
|
||||
<a href="#marketplace/home">${__('Marketplace')}
|
||||
<a class="marketplace-link" href="#marketplace/home">${__('Marketplace')}
|
||||
</li>
|
||||
`);
|
||||
|
||||
is_marketplace_disabled()
|
||||
.then(disabled => {
|
||||
if (disabled) {
|
||||
$('#toolbar-user .marketplace-link').hide();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -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;
|
||||
});
|
||||
});
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user