[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
This commit is contained in:
parent
255dd0e03d
commit
b2b745fc7a
@ -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 }
|
||||
|
||||
|
@ -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": "",
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user