[hub] add user selection in register
diff --git a/erpnext/hub_node/doctype/hub_user/__init__.py b/erpnext/hub_node/doctype/hub_user/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/hub_node/doctype/hub_user/__init__.py
diff --git a/erpnext/hub_node/doctype/hub_user/hub_user.json b/erpnext/hub_node/doctype/hub_user/hub_user.json
new file mode 100644
index 0000000..f72f01d
--- /dev/null
+++ b/erpnext/hub_node/doctype/hub_user/hub_user.json
@@ -0,0 +1,140 @@
+{
+ "allow_copy": 0,
+ "allow_guest_to_view": 0,
+ "allow_import": 0,
+ "allow_rename": 0,
+ "autoname": "field:user",
+ "beta": 0,
+ "creation": "2018-08-31 12:36:45.627531",
+ "custom": 0,
+ "docstatus": 0,
+ "doctype": "DocType",
+ "document_type": "",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "fields": [
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "user",
+ "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": "User",
+ "length": 0,
+ "no_copy": 0,
+ "options": "User",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 1,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 1
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "hub_username",
+ "fieldtype": "Data",
+ "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": "Hub Username",
+ "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": "hub_password",
+ "fieldtype": "Password",
+ "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": "Hub Password",
+ "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,
+ "hide_heading": 0,
+ "hide_toolbar": 0,
+ "idx": 0,
+ "image_view": 0,
+ "in_create": 0,
+ "is_submittable": 0,
+ "issingle": 0,
+ "istable": 1,
+ "max_attachments": 0,
+ "modified": "2018-08-31 13:58:46.098710",
+ "modified_by": "Administrator",
+ "module": "Hub Node",
+ "name": "Hub User",
+ "name_case": "",
+ "owner": "Administrator",
+ "permissions": [],
+ "quick_entry": 1,
+ "read_only": 0,
+ "read_only_onload": 0,
+ "show_name_in_global_search": 0,
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "track_changes": 1,
+ "track_seen": 0,
+ "track_views": 0
+}
\ No newline at end of file
diff --git a/erpnext/hub_node/doctype/hub_user/hub_user.py b/erpnext/hub_node/doctype/hub_user/hub_user.py
new file mode 100644
index 0000000..de43f4e
--- /dev/null
+++ b/erpnext/hub_node/doctype/hub_user/hub_user.py
@@ -0,0 +1,10 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import frappe
+from frappe.model.document import Document
+
+class HubUser(Document):
+ pass
diff --git a/erpnext/hub_node/doctype/marketplace_settings/marketplace_settings.json b/erpnext/hub_node/doctype/marketplace_settings/marketplace_settings.json
index 5243f38..2663dc5 100644
--- a/erpnext/hub_node/doctype/marketplace_settings/marketplace_settings.json
+++ b/erpnext/hub_node/doctype/marketplace_settings/marketplace_settings.json
@@ -247,6 +247,38 @@
"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,
@@ -344,8 +376,8 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
- "fieldname": "logo",
- "fieldtype": "Attach Image",
+ "fieldname": "company_description",
+ "fieldtype": "Long Text",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
@@ -353,7 +385,7 @@
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
- "label": "Company Logo",
+ "label": "Company Description",
"length": 0,
"no_copy": 0,
"permlevel": 0,
@@ -376,8 +408,8 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
- "fieldname": "company_description",
- "fieldtype": "Text Editor",
+ "fieldname": "users",
+ "fieldtype": "Table",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
@@ -385,9 +417,10 @@
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
- "label": "Description",
+ "label": "Users",
"length": 0,
"no_copy": 0,
+ "options": "Hub User",
"permlevel": 0,
"precision": "",
"print_hide": 0,
@@ -479,8 +512,8 @@
"issingle": 1,
"istable": 0,
"max_attachments": 0,
- "modified": "2018-08-31 17:30:37.305704",
- "modified_by": "netchamp@rawcoderz.com",
+ "modified": "2018-08-31 17:56:23.354092",
+ "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 9b83898..909ed99 100644
--- a/erpnext/hub_node/doctype/marketplace_settings/marketplace_settings.py
+++ b/erpnext/hub_node/doctype/marketplace_settings/marketplace_settings.py
@@ -44,7 +44,7 @@
frappe.throw(json.loads(response.text))
if message.get('email'):
- self.create_hub_connector(message)
+ self.update_session_user_password(message)
self.registered = 1
self.save()
@@ -63,6 +63,10 @@
# self.enabled = 0
# self.save()
+ def update_session_user_password(self, message):
+ # TODO: Update child table session user password
+ pass
+
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')
@@ -98,7 +102,24 @@
@frappe.whitelist()
def register_seller(**kwargs):
settings = frappe.get_doc('Marketplace Settings')
- settings.update(kwargs)
- message = settings.register()
+ user_emails = kwargs.get('users').strip()[:-1].split(', ')
+ users = []
+
+ for user_email in user_emails:
+ users.append({
+ "user": user_email
+ })
+
+ users.insert(0, {
+ "user": frappe.session.user,
+ "hub_username": kwargs.get('username')
+ })
+
+ kwargs['users'] = users
+ settings.update(kwargs)
+
+ settings.save()
+
+ message = settings.register()
return message.get('email')
diff --git a/erpnext/hub_node/doctype/marketplace_settings/test_marketplace_settings.js b/erpnext/hub_node/doctype/marketplace_settings/test_marketplace_settings.js
new file mode 100644
index 0000000..fba3e09
--- /dev/null
+++ b/erpnext/hub_node/doctype/marketplace_settings/test_marketplace_settings.js
@@ -0,0 +1,23 @@
+/* eslint-disable */
+// rename this file from _test_[name] to test_[name] to activate
+// and remove above this line
+
+QUnit.test("test: Marketplace Settings", function (assert) {
+ let done = assert.async();
+
+ // number of asserts
+ assert.expect(1);
+
+ frappe.run_serially([
+ // insert a new Marketplace Settings
+ () => frappe.tests.make('Marketplace Settings', [
+ // values to be set
+ {key: 'value'}
+ ]),
+ () => {
+ assert.equal(cur_frm.doc.key, 'value');
+ },
+ () => done()
+ ]);
+
+});
diff --git a/erpnext/hub_node/doctype/marketplace_settings/test_marketplace_settings.py b/erpnext/hub_node/doctype/marketplace_settings/test_marketplace_settings.py
new file mode 100644
index 0000000..549b991
--- /dev/null
+++ b/erpnext/hub_node/doctype/marketplace_settings/test_marketplace_settings.py
@@ -0,0 +1,10 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
+# See license.txt
+from __future__ import unicode_literals
+
+import frappe
+import unittest
+
+class TestMarketplaceSettings(unittest.TestCase):
+ pass
diff --git a/erpnext/public/js/hub/components/profile_dialog.js b/erpnext/public/js/hub/components/profile_dialog.js
index ae44659..36672b9 100644
--- a/erpnext/public/js/hub/components/profile_dialog.js
+++ b/erpnext/public/js/hub/components/profile_dialog.js
@@ -1,6 +1,12 @@
const ProfileDialog = (title = __('Edit Profile'), action={}) => {
const fields = [
{
+ // TODO: add hub check for taken
+ fieldname: 'username',
+ label: __('Username'),
+ fieldtype: 'Data'
+ },
+ {
fieldtype: 'Link',
fieldname: 'company',
label: __('Company'),
@@ -13,7 +19,8 @@
.then(company => {
dialog.set_values({
country: company.country,
- currency: company.default_currency
+ currency: company.default_currency,
+ company_email: company.email
});
});
}
@@ -21,8 +28,13 @@
},
{
fieldname: 'company_email',
- label: __('Email'),
- fieldtype: 'Read Only'
+ label: __('Company Email'),
+ fieldtype: 'Data'
+ },
+ {
+ fieldname: 'users',
+ label: __('Users'),
+ fieldtype: 'MultiSelect'
},
{
fieldname: 'country',
@@ -62,6 +74,15 @@
}
});
+ frappe.db.get_list('User')
+ .then(result => {
+ const users = result.map(result => result.name)
+ .filter(user => !['Guest', 'Administrator', frappe.session.user].includes(user));
+ dialog.fields_dict.users.set_data(users);
+ });
+
+ dialog.set_values(initial_values);
+
// Post create
const default_company = frappe.defaults.get_default('company');
dialog.set_value('company', default_company);