mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-25 16:04:46 +00:00
[hub] add user selection in register
This commit is contained in:
0
erpnext/hub_node/doctype/hub_user/__init__.py
Normal file
0
erpnext/hub_node/doctype/hub_user/__init__.py
Normal file
140
erpnext/hub_node/doctype/hub_user/hub_user.json
Normal file
140
erpnext/hub_node/doctype/hub_user/hub_user.json
Normal file
@@ -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
|
||||||
|
}
|
||||||
10
erpnext/hub_node/doctype/hub_user/hub_user.py
Normal file
10
erpnext/hub_node/doctype/hub_user/hub_user.py
Normal file
@@ -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
|
||||||
@@ -240,6 +240,38 @@
|
|||||||
"translatable": 0,
|
"translatable": 0,
|
||||||
"unique": 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_bulk_edit": 0,
|
||||||
"allow_in_quick_entry": 0,
|
"allow_in_quick_entry": 0,
|
||||||
@@ -344,8 +376,8 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
"fieldname": "logo",
|
"fieldname": "company_description",
|
||||||
"fieldtype": "Attach Image",
|
"fieldtype": "Long Text",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
"ignore_xss_filter": 0,
|
"ignore_xss_filter": 0,
|
||||||
@@ -353,7 +385,7 @@
|
|||||||
"in_global_search": 0,
|
"in_global_search": 0,
|
||||||
"in_list_view": 0,
|
"in_list_view": 0,
|
||||||
"in_standard_filter": 0,
|
"in_standard_filter": 0,
|
||||||
"label": "Company Logo",
|
"label": "Company Description",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
@@ -376,8 +408,8 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
"fieldname": "company_description",
|
"fieldname": "users",
|
||||||
"fieldtype": "Text Editor",
|
"fieldtype": "Table",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
"ignore_xss_filter": 0,
|
"ignore_xss_filter": 0,
|
||||||
@@ -385,9 +417,10 @@
|
|||||||
"in_global_search": 0,
|
"in_global_search": 0,
|
||||||
"in_list_view": 0,
|
"in_list_view": 0,
|
||||||
"in_standard_filter": 0,
|
"in_standard_filter": 0,
|
||||||
"label": "Description",
|
"label": "Users",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
|
"options": "Hub User",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"precision": "",
|
"precision": "",
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
@@ -479,8 +512,8 @@
|
|||||||
"issingle": 1,
|
"issingle": 1,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2018-08-31 17:30:37.305704",
|
"modified": "2018-08-31 17:56:23.354092",
|
||||||
"modified_by": "netchamp@rawcoderz.com",
|
"modified_by": "cave@aperture.com",
|
||||||
"module": "Hub Node",
|
"module": "Hub Node",
|
||||||
"name": "Marketplace Settings",
|
"name": "Marketplace Settings",
|
||||||
"name_case": "",
|
"name_case": "",
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class MarketplaceSettings(Document):
|
|||||||
frappe.throw(json.loads(response.text))
|
frappe.throw(json.loads(response.text))
|
||||||
|
|
||||||
if message.get('email'):
|
if message.get('email'):
|
||||||
self.create_hub_connector(message)
|
self.update_session_user_password(message)
|
||||||
self.registered = 1
|
self.registered = 1
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
@@ -63,6 +63,10 @@ class MarketplaceSettings(Document):
|
|||||||
# self.enabled = 0
|
# self.enabled = 0
|
||||||
# self.save()
|
# self.save()
|
||||||
|
|
||||||
|
def update_session_user_password(self, message):
|
||||||
|
# TODO: Update child table session user password
|
||||||
|
pass
|
||||||
|
|
||||||
def create_hub_connector(self, message):
|
def create_hub_connector(self, message):
|
||||||
if frappe.db.exists('Data Migration Connector', 'Hub Connector'):
|
if frappe.db.exists('Data Migration Connector', 'Hub Connector'):
|
||||||
hub_connector = frappe.get_doc('Data Migration Connector', 'Hub Connector')
|
hub_connector = frappe.get_doc('Data Migration Connector', 'Hub Connector')
|
||||||
@@ -98,7 +102,24 @@ def reset_hub_settings(last_sync_datetime = ""):
|
|||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def register_seller(**kwargs):
|
def register_seller(**kwargs):
|
||||||
settings = frappe.get_doc('Marketplace Settings')
|
settings = frappe.get_doc('Marketplace Settings')
|
||||||
settings.update(kwargs)
|
user_emails = kwargs.get('users').strip()[:-1].split(', ')
|
||||||
message = settings.register()
|
|
||||||
|
|
||||||
|
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')
|
return message.get('email')
|
||||||
|
|||||||
@@ -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()
|
||||||
|
]);
|
||||||
|
|
||||||
|
});
|
||||||
@@ -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
|
||||||
@@ -1,5 +1,11 @@
|
|||||||
const ProfileDialog = (title = __('Edit Profile'), action={}) => {
|
const ProfileDialog = (title = __('Edit Profile'), action={}) => {
|
||||||
const fields = [
|
const fields = [
|
||||||
|
{
|
||||||
|
// TODO: add hub check for taken
|
||||||
|
fieldname: 'username',
|
||||||
|
label: __('Username'),
|
||||||
|
fieldtype: 'Data'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
fieldtype: 'Link',
|
fieldtype: 'Link',
|
||||||
fieldname: 'company',
|
fieldname: 'company',
|
||||||
@@ -13,7 +19,8 @@ const ProfileDialog = (title = __('Edit Profile'), action={}) => {
|
|||||||
.then(company => {
|
.then(company => {
|
||||||
dialog.set_values({
|
dialog.set_values({
|
||||||
country: company.country,
|
country: company.country,
|
||||||
currency: company.default_currency
|
currency: company.default_currency,
|
||||||
|
company_email: company.email
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -21,8 +28,13 @@ const ProfileDialog = (title = __('Edit Profile'), action={}) => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: 'company_email',
|
fieldname: 'company_email',
|
||||||
label: __('Email'),
|
label: __('Company Email'),
|
||||||
fieldtype: 'Read Only'
|
fieldtype: 'Data'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldname: 'users',
|
||||||
|
label: __('Users'),
|
||||||
|
fieldtype: 'MultiSelect'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: 'country',
|
fieldname: 'country',
|
||||||
@@ -62,6 +74,15 @@ const ProfileDialog = (title = __('Edit Profile'), action={}) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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
|
// Post create
|
||||||
const default_company = frappe.defaults.get_default('company');
|
const default_company = frappe.defaults.get_default('company');
|
||||||
dialog.set_value('company', default_company);
|
dialog.set_value('company', default_company);
|
||||||
|
|||||||
Reference in New Issue
Block a user