[hub] register_seller -> register_marketplace
- resgister_seller will be for subsequent users - make username and password readonly - check if password present before trying to create connection
This commit is contained in:
parent
810ae01832
commit
4e1fd0b417
@ -15,8 +15,9 @@ from six import string_types
|
|||||||
|
|
||||||
current_user = frappe.session.user
|
current_user = frappe.session.user
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def register_seller(**kwargs):
|
def register_marketplace(**kwargs):
|
||||||
settings = frappe.get_single('Marketplace Settings')
|
settings = frappe.get_single('Marketplace Settings')
|
||||||
settings.update(kwargs)
|
settings.update(kwargs)
|
||||||
settings.users = []
|
settings.users = []
|
||||||
@ -42,6 +43,12 @@ def register_seller(**kwargs):
|
|||||||
|
|
||||||
return message
|
return message
|
||||||
|
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def register_user(username, first_name, company):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def validate_registerer():
|
def validate_registerer():
|
||||||
if current_user == 'Administrator':
|
if current_user == 'Administrator':
|
||||||
frappe.throw(_('Please login as another user to register on Marketplace'))
|
frappe.throw(_('Please login as another user to register on Marketplace'))
|
||||||
@ -49,6 +56,7 @@ def validate_registerer():
|
|||||||
if 'System Manager' not in frappe.get_roles():
|
if 'System Manager' not in frappe.get_roles():
|
||||||
frappe.throw(_('Only users with System Manager role can register on Marketplace'), frappe.PermissionError)
|
frappe.throw(_('Only users with System Manager role can register on Marketplace'), frappe.PermissionError)
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def call_hub_method(method, params=None):
|
def call_hub_method(method, params=None):
|
||||||
connection = get_hub_connection()
|
connection = get_hub_connection()
|
||||||
@ -63,6 +71,7 @@ def call_hub_method(method, params=None):
|
|||||||
response = connection.post_request(params)
|
response = connection.post_request(params)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
def map_fields(items):
|
def map_fields(items):
|
||||||
field_mappings = get_field_mappings()
|
field_mappings = get_field_mappings()
|
||||||
table_fields = [d.fieldname for d in frappe.get_meta('Item').get_table_fields()]
|
table_fields = [d.fieldname for d in frappe.get_meta('Item').get_table_fields()]
|
||||||
@ -87,6 +96,7 @@ def map_fields(items):
|
|||||||
|
|
||||||
return items
|
return items
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_valid_items(search_value=''):
|
def get_valid_items(search_value=''):
|
||||||
items = frappe.get_list(
|
items = frappe.get_list(
|
||||||
@ -111,6 +121,7 @@ def get_valid_items(search_value=''):
|
|||||||
|
|
||||||
return valid_items
|
return valid_items
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def publish_selected_items(items_to_publish):
|
def publish_selected_items(items_to_publish):
|
||||||
items_to_publish = json.loads(items_to_publish)
|
items_to_publish = json.loads(items_to_publish)
|
||||||
@ -128,7 +139,6 @@ def publish_selected_items(items_to_publish):
|
|||||||
'image_list': item.get('image_list')
|
'image_list': item.get('image_list')
|
||||||
}).insert(ignore_if_duplicate=True)
|
}).insert(ignore_if_duplicate=True)
|
||||||
|
|
||||||
|
|
||||||
items = map_fields(items_to_publish)
|
items = map_fields(items_to_publish)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -143,6 +153,7 @@ def publish_selected_items(items_to_publish):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
frappe.log_error(message=e, title='Hub Sync Error')
|
frappe.log_error(message=e, title='Hub Sync Error')
|
||||||
|
|
||||||
|
|
||||||
def item_sync_preprocess(intended_item_publish_count):
|
def item_sync_preprocess(intended_item_publish_count):
|
||||||
response = call_hub_method('pre_items_publish', {
|
response = call_hub_method('pre_items_publish', {
|
||||||
'intended_item_publish_count': intended_item_publish_count
|
'intended_item_publish_count': intended_item_publish_count
|
||||||
@ -154,6 +165,7 @@ def item_sync_preprocess(intended_item_publish_count):
|
|||||||
else:
|
else:
|
||||||
frappe.throw('Unable to update remote activity')
|
frappe.throw('Unable to update remote activity')
|
||||||
|
|
||||||
|
|
||||||
def item_sync_postprocess():
|
def item_sync_postprocess():
|
||||||
response = call_hub_method('post_items_publish', {})
|
response = call_hub_method('post_items_publish', {})
|
||||||
if response:
|
if response:
|
||||||
@ -192,7 +204,10 @@ def load_base64_image_from_items(items):
|
|||||||
def get_hub_connection():
|
def get_hub_connection():
|
||||||
settings = frappe.get_single('Marketplace Settings')
|
settings = frappe.get_single('Marketplace Settings')
|
||||||
marketplace_url = settings.marketplace_url
|
marketplace_url = settings.marketplace_url
|
||||||
current_user_records = filter(lambda x: x.user == current_user, settings.users)
|
current_user_records = filter(
|
||||||
|
lambda x: x.user == current_user and x.password,
|
||||||
|
settings.users
|
||||||
|
)
|
||||||
|
|
||||||
if current_user_records:
|
if current_user_records:
|
||||||
record = current_user_records[0]
|
record = current_user_records[0]
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
"precision": "",
|
"precision": "",
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
"print_hide_if_no_value": 0,
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 1,
|
||||||
"remember_last_selected_value": 0,
|
"remember_last_selected_value": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -101,7 +101,7 @@
|
|||||||
"precision": "",
|
"precision": "",
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
"print_hide_if_no_value": 0,
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 1,
|
||||||
"remember_last_selected_value": 0,
|
"remember_last_selected_value": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -121,7 +121,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2018-08-31 20:39:55.944828",
|
"modified": "2018-09-01 09:46:54.327880",
|
||||||
"modified_by": "cave@aperture.com",
|
"modified_by": "cave@aperture.com",
|
||||||
"module": "Hub Node",
|
"module": "Hub Node",
|
||||||
"name": "Hub User",
|
"name": "Hub User",
|
||||||
|
@ -92,16 +92,16 @@ erpnext.hub.Marketplace = class Marketplace {
|
|||||||
__('Become a Seller'),
|
__('Become a Seller'),
|
||||||
{
|
{
|
||||||
label: __('Register'),
|
label: __('Register'),
|
||||||
on_submit: this.register_seller.bind(this)
|
on_submit: this.register_marketplace.bind(this)
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
this.register_dialog.show();
|
this.register_dialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
register_seller(form_values) {
|
register_marketplace(form_values) {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: 'erpnext.hub_node.api.register_seller',
|
method: 'erpnext.hub_node.api.register_marketplace',
|
||||||
args: form_values
|
args: form_values
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.register_dialog.hide();
|
this.register_dialog.hide();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user