From b2b745fc7a98d21f41159c02b42e6de125fef187 Mon Sep 17 00:00:00 2001 From: Prateeksha Singh Date: Sat, 1 Sep 2018 17:20:08 +0530 Subject: [PATCH] [hub] simplify marketplace settings, remove company fields - Company attributes will be fetched/calculated to send to server - removed them as fields in settings - Added description in company, with existing logo field - TODO: for things like logo and description, ask user to set in master --- erpnext/hub_node/api.py | 14 +- .../marketplace_settings.json | 167 +----------------- .../marketplace_settings.py | 29 ++- .../js/hub/components/profile_dialog.js | 27 +-- erpnext/public/js/hub/marketplace.js | 3 +- erpnext/setup/doctype/company/company.json | 139 +++++++++++---- 6 files changed, 136 insertions(+), 243 deletions(-) diff --git a/erpnext/hub_node/api.py b/erpnext/hub_node/api.py index 12a564a3425..c82890c100b 100644 --- a/erpnext/hub_node/api.py +++ b/erpnext/hub_node/api.py @@ -17,25 +17,17 @@ current_user = frappe.session.user @frappe.whitelist() -def register_marketplace(company, company_description): +def register_marketplace(company): validate_registerer() - settings = frappe.get_single('Marketplace Settings') - country, currency = frappe.db.get_value('Company', company, ['country', 'default_currency']) - - settings.company = company - settings.country = country - settings.currency = currency - settings.company_description = company_description - - message = settings.register() + message = settings.register_seller(company) if message.get('hub_seller_name'): settings.registered = 1 settings.hub_seller_name = message.get('hub_seller_name') settings.save() - settings.add_user(frappe.session.user) + settings.add_hub_user(frappe.session.user) return { 'ok': 1 } diff --git a/erpnext/hub_node/doctype/marketplace_settings/marketplace_settings.json b/erpnext/hub_node/doctype/marketplace_settings/marketplace_settings.json index f2d8b05e050..12837111a78 100644 --- a/erpnext/hub_node/doctype/marketplace_settings/marketplace_settings.json +++ b/erpnext/hub_node/doctype/marketplace_settings/marketplace_settings.json @@ -95,7 +95,7 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, - "label": "Marketplace URL", + "label": "Marketplace URL (to hide and update label)", "length": 0, "no_copy": 0, "permlevel": 0, @@ -240,167 +240,6 @@ "translatable": 0, "unique": 0 }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "company_logo", - "fieldtype": "Attach Image", - "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 Logo", - "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": "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, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "country", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 1, - "in_standard_filter": 0, - "label": "Country", - "length": 0, - "no_copy": 0, - "options": "Country", - "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": "currency", - "fieldtype": "Currency", - "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": "Currency", - "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": "company_description", - "fieldtype": "Long Text", - "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 Description", - "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, @@ -512,8 +351,8 @@ "issingle": 1, "istable": 0, "max_attachments": 0, - "modified": "2018-09-01 14:15:40.676256", - "modified_by": "suraj@rawcoderz.com", + "modified": "2018-09-01 17:05:59.600583", + "modified_by": "cave@aperture.com", "module": "Hub Node", "name": "Marketplace Settings", "name_case": "", diff --git a/erpnext/hub_node/doctype/marketplace_settings/marketplace_settings.py b/erpnext/hub_node/doctype/marketplace_settings/marketplace_settings.py index cfb9acee2fb..43543a8a2b2 100644 --- a/erpnext/hub_node/doctype/marketplace_settings/marketplace_settings.py +++ b/erpnext/hub_node/doctype/marketplace_settings/marketplace_settings.py @@ -13,23 +13,33 @@ from six import string_types class MarketplaceSettings(Document): - def validate(self): - self.site_name = frappe.utils.get_url() + def register_seller(self, company): - def register(self): - """ Create a User on hubmarket.org and return username/password """ - self.site_name = frappe.utils.get_url() + country, currency, company_description = frappe.db.get_value('Company', company, + ['country', 'default_currency', 'company_description']) + + company_details = { + 'company': company, + 'country': country, + # 'city': '', + 'currency': currency, + 'company_description': company_description, + # 'company_logo': company_logo, + + 'site_name': frappe.utils.get_url(), + } hub_connection = self.get_connection() response = hub_connection.post_request({ - 'cmd': 'hub.hub.api.register', - 'company_details': self.as_json() + 'cmd': 'hub.hub.api.add_hub_seller', + 'company_details': json.dumps(company_details) }) return response - def add_user(self, user_email): + + def add_hub_user(self, user_email): if not self.registered: return @@ -53,10 +63,11 @@ class MarketplaceSettings(Document): self.insert() + def get_connection(self): return FrappeClient(self.marketplace_url) def unregister(self): - """ Disable the User on hub.erpnext.org""" + """Disable the User on hubmarket.org""" pass diff --git a/erpnext/public/js/hub/components/profile_dialog.js b/erpnext/public/js/hub/components/profile_dialog.js index 240df82ec1d..0f22eaa361d 100644 --- a/erpnext/public/js/hub/components/profile_dialog.js +++ b/erpnext/public/js/hub/components/profile_dialog.js @@ -4,30 +4,12 @@ const ProfileDialog = (title = __('Edit Profile'), action={}) => { fieldtype: 'Link', fieldname: 'company', label: __('Company'), - options: 'Company', - onchange: () => { - const value = dialog.get_value('company'); - - if (value) { - frappe.db.get_doc('Company', value) - .then(company => { - dialog.set_values({ - country: company.country, - currency: company.default_currency - }); - }); - } - } + options: 'Company' }, { fieldname: 'company_email', label: __('Email'), fieldtype: 'Read Only' - }, - { - fieldtype: 'Text', - label: __('About your Company'), - fieldname: 'company_description' } ]; @@ -38,7 +20,11 @@ const ProfileDialog = (title = __('Edit Profile'), action={}) => { primary_action: () => { const form_values = dialog.get_values(); let values_filled = true; - const mandatory_fields = ['company', 'company_email', 'company_description']; + + // TODO: Say "we notice that the company description and logo isn't set. Please set them in master." + // Only then allow to register + + const mandatory_fields = ['company']; mandatory_fields.forEach(field => { const value = form_values[field]; if (!value) { @@ -51,6 +37,7 @@ const ProfileDialog = (title = __('Edit Profile'), action={}) => { action.on_submit(form_values); } }); + // Post create const default_company = frappe.defaults.get_default('company'); dialog.set_value('company', default_company); diff --git a/erpnext/public/js/hub/marketplace.js b/erpnext/public/js/hub/marketplace.js index 2bd55521b27..ce72042c00c 100644 --- a/erpnext/public/js/hub/marketplace.js +++ b/erpnext/public/js/hub/marketplace.js @@ -99,13 +99,12 @@ erpnext.hub.Marketplace = class Marketplace { this.register_dialog.show(); } - register_marketplace({company, company_email, company_description}) { + register_marketplace({company, company_email}) { frappe.call({ method: 'erpnext.hub_node.api.register_marketplace', args: { company, company_email, - company_description } }).then((r) => { if (r.message && r.message.ok) { diff --git a/erpnext/setup/doctype/company/company.json b/erpnext/setup/doctype/company/company.json index a4c81c5cea0..96d11163f51 100644 --- a/erpnext/setup/doctype/company/company.json +++ b/erpnext/setup/doctype/company/company.json @@ -305,6 +305,102 @@ "translatable": 0, "unique": 0 }, + { + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "sb_about", + "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": "About the Company", + "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": "company_logo", + "fieldtype": "Attach Image", + "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 Logo", + "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": "company_description", + "fieldtype": "Text Editor", + "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 Description", + "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, @@ -741,7 +837,7 @@ "label": "Create Chart Of Accounts Based On", "length": 0, "no_copy": 0, - "options": "\nStandard Template\nExisting Company", + "options": "\nStandard Template\nExisting Company\n\n\n", "permlevel": 0, "precision": "", "print_hide": 0, @@ -775,7 +871,7 @@ "label": "Chart Of Accounts Template", "length": 0, "no_copy": 1, - "options": "", + "options": "\n\n\n", "permlevel": 0, "precision": "", "print_hide": 0, @@ -2630,38 +2726,6 @@ "translatable": 0, "unique": 0 }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "company_logo", - "fieldtype": "Attach Image", - "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 Logo", - "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, @@ -2772,8 +2836,8 @@ "istable": 0, "max_attachments": 0, "menu_index": 0, - "modified": "2018-08-28 15:47:50.757131", - "modified_by": "Administrator", + "modified": "2018-09-01 16:03:30.716918", + "modified_by": "cave@aperture.com", "module": "Setup", "name": "Company", "owner": "Administrator", @@ -2918,5 +2982,6 @@ "show_name_in_global_search": 1, "sort_order": "ASC", "track_changes": 1, - "track_seen": 0 + "track_seen": 0, + "track_views": 0 } \ No newline at end of file