mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-04 14:08:29 +00:00
Hub Market (#13325)
* [hub] enable hub with OAuth token from user's client ID * [hub] settings schema for adding users * [hub] image view style listing * [hub] broken image link fallback * [wip] * [hub] bootstrap timeline * [hub] setup quick view * [hub] reformat ratings, add companies autocomplete filter * [hub] common listing frames * [hub] setup sort selector * [hub] timeline * [hub] customize list header * [hub] genuine form fieldtypes * [hub] review products * [hub] suggest missing categories remotely * [hub] Wishlist; header and title templates * [hub] link wishlist, remove company migration * [hub] calculate ratings
This commit is contained in:
committed by
Rushabh Mehta
parent
c5effbf009
commit
b60a52b194
@@ -22,13 +22,64 @@ def get_list(doctype, start=0, limit=20, fields=["*"], filters="{}", order_by=No
|
||||
response = connection.get_list(doctype,
|
||||
limit_start=start, limit_page_length=limit,
|
||||
filters=filters, fields=fields)
|
||||
return response
|
||||
|
||||
# Bad, need child tables in response
|
||||
listing = []
|
||||
for obj in response:
|
||||
doc = connection.get_doc(doctype, obj['name'])
|
||||
listing.append(doc)
|
||||
|
||||
return listing
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_item_favourites(start=0, limit=20, fields=["*"], order_by=None):
|
||||
doctype = 'Hub Item'
|
||||
hub_settings = frappe.get_doc('Hub Settings')
|
||||
item_names_str = hub_settings.get('custom_data') or '[]'
|
||||
item_names = json.loads(item_names_str)
|
||||
filters = json.dumps({
|
||||
'hub_item_code': ['in', item_names]
|
||||
})
|
||||
return get_list(doctype, start, limit, fields, filters, order_by)
|
||||
|
||||
@frappe.whitelist()
|
||||
def update_wishlist_item(item_name, remove=0):
|
||||
remove = int(remove)
|
||||
hub_settings = frappe.get_doc('Hub Settings')
|
||||
data = hub_settings.get('custom_data')
|
||||
if not data or not json.loads(data):
|
||||
data = '[]'
|
||||
hub_settings.custom_data = data
|
||||
hub_settings.save()
|
||||
|
||||
item_names_str = data
|
||||
item_names = json.loads(item_names_str)
|
||||
if not remove and item_name not in item_names:
|
||||
item_names.append(item_name)
|
||||
if remove and item_name in item_names:
|
||||
item_names.remove(item_name)
|
||||
|
||||
item_names_str = json.dumps(item_names)
|
||||
|
||||
hub_settings.custom_data = item_names_str
|
||||
hub_settings.save()
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_meta(doctype):
|
||||
connection = get_client_connection()
|
||||
meta = connection.get_doc('DocType', doctype)
|
||||
return meta
|
||||
categories = connection.get_list('Hub Category',
|
||||
limit_start=0, limit_page_length=300,
|
||||
filters={}, fields=['name'])
|
||||
|
||||
categories = [d.get('name') for d in categories]
|
||||
return {
|
||||
'meta': meta,
|
||||
'companies': connection.get_list('Hub Company',
|
||||
limit_start=0, limit_page_length=300,
|
||||
filters={}, fields=['name']),
|
||||
'categories': categories
|
||||
}
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_categories(parent='All Categories'):
|
||||
@@ -40,12 +91,42 @@ def get_categories(parent='All Categories'):
|
||||
return response
|
||||
|
||||
@frappe.whitelist()
|
||||
def update_category(item_name, category):
|
||||
def update_category(hub_item_code, category):
|
||||
connection = get_hub_connection()
|
||||
response = connection.update('Hub Item', dict(
|
||||
|
||||
# args = frappe._dict(dict(
|
||||
# doctype='Hub Category',
|
||||
# hub_category_name=category
|
||||
# ))
|
||||
# response = connection.insert('Hub Category', args)
|
||||
|
||||
response = connection.update('Hub Item', frappe._dict(dict(
|
||||
doctype='Hub Item',
|
||||
hub_category = category
|
||||
), item_name)
|
||||
return response.ok
|
||||
)), hub_item_code)
|
||||
|
||||
return response
|
||||
|
||||
@frappe.whitelist()
|
||||
def send_review(hub_item_code, review):
|
||||
review = json.loads(review)
|
||||
hub_connection = get_hub_connection()
|
||||
|
||||
item_doc = hub_connection.connection.get_doc('Hub Item', hub_item_code)
|
||||
existing_reviews = item_doc.get('reviews')
|
||||
|
||||
reviews = [review]
|
||||
review.setdefault('idx', 0)
|
||||
for r in existing_reviews:
|
||||
if r.get('user') != review.get('user'):
|
||||
reviews.append(r)
|
||||
|
||||
response = hub_connection.update('Hub Item', dict(
|
||||
doctype='Hub Item',
|
||||
reviews = reviews
|
||||
), hub_item_code)
|
||||
|
||||
return response
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_details(hub_sync_id=None, doctype='Hub Item'):
|
||||
@@ -53,6 +134,11 @@ def get_details(hub_sync_id=None, doctype='Hub Item'):
|
||||
return
|
||||
connection = get_client_connection()
|
||||
details = connection.get_doc(doctype, hub_sync_id)
|
||||
reviews = details.get('reviews')
|
||||
if len(reviews):
|
||||
for r in reviews:
|
||||
r.setdefault('pretty_date', frappe.utils.pretty_date(r.get('modified')))
|
||||
details.setdefault('reviews', reviews)
|
||||
return details
|
||||
|
||||
def get_client_connection():
|
||||
|
||||
@@ -4,10 +4,6 @@
|
||||
"doctype": "Data Migration Plan",
|
||||
"idx": 1,
|
||||
"mappings": [
|
||||
{
|
||||
"enabled": 1,
|
||||
"mapping": "Company to Hub Company"
|
||||
},
|
||||
{
|
||||
"enabled": 1,
|
||||
"mapping": "Item to Hub Item"
|
||||
|
||||
@@ -8,18 +8,31 @@ frappe.ui.form.on("Hub Settings", {
|
||||
frm.trigger("enabled");
|
||||
if (frm.doc.enabled) {
|
||||
frm.add_custom_button(__('View Hub'),
|
||||
() => frappe.set_route('hub'));
|
||||
() => frappe.set_route('Hub', 'Item'));
|
||||
frm.add_custom_button(__('Sync'),
|
||||
() => frm.call('sync'));
|
||||
}
|
||||
},
|
||||
onload: function(frm) {
|
||||
let token = frappe.urllib.get_arg("access_token");
|
||||
if(token) {
|
||||
let email = frm.get_field("user");
|
||||
console.log('token', frappe.urllib.get_arg("access_token"));
|
||||
|
||||
get_user_details(frm, token, email);
|
||||
let row = frappe.model.add_child(frm.doc, "Hub Users", "users");
|
||||
row.user = frappe.session.user;
|
||||
}
|
||||
|
||||
if(!frm.doc.country) {
|
||||
frm.set_value("country", frappe.defaults.get_default("Country"));
|
||||
}
|
||||
if(!frm.doc.company) {
|
||||
frm.set_value("company", frappe.defaults.get_default("Company"));
|
||||
}
|
||||
if(!frm.doc.user) {
|
||||
frm.set_value("user", frappe.session.user);
|
||||
}
|
||||
},
|
||||
onload_post_render: function(frm) {
|
||||
if(frm.get_field("unregister_from_hub").$input)
|
||||
@@ -48,33 +61,47 @@ frappe.ui.form.on("Hub Settings", {
|
||||
if(frappe.session.user === "Administrator") {
|
||||
frappe.msgprint(__("Please login as another user."))
|
||||
} else {
|
||||
frappe.verify_password(() => {
|
||||
this.frm.call({
|
||||
doc: this.frm.doc,
|
||||
method: "register",
|
||||
args: {},
|
||||
freeze: true,
|
||||
callback: function(r) {},
|
||||
onerror: function() {
|
||||
frappe.msgprint(__("Wrong Password"));
|
||||
frm.set_value("enabled", 0);
|
||||
}
|
||||
});
|
||||
} );
|
||||
// frappe.verify_password(() => {
|
||||
|
||||
// } );
|
||||
|
||||
frm.trigger("call_pre_reg");
|
||||
// frm.trigger("call_register");
|
||||
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// update_hub: (frm) => {
|
||||
// this.frm.call({
|
||||
// doc: this.frm.doc,
|
||||
// method: "update_hub",
|
||||
// args: {},
|
||||
// freeze: true,
|
||||
// callback: function(r) { },
|
||||
// onerror: function() { }
|
||||
// });
|
||||
// },
|
||||
call_pre_reg: (frm) => {
|
||||
this.frm.call({
|
||||
doc: this.frm.doc,
|
||||
method: "pre_reg",
|
||||
args: {},
|
||||
freeze: true,
|
||||
callback: function(r) {
|
||||
console.log(r.message);
|
||||
authorize(frm, r.message.client_id, r.message.redirect_uri);
|
||||
},
|
||||
onerror: function() {
|
||||
frappe.msgprint(__("Wrong Password"));
|
||||
frm.set_value("enabled", 0);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
call_register: (frm) => {
|
||||
this.frm.call({
|
||||
doc: this.frm.doc,
|
||||
method: "register",
|
||||
args: {},
|
||||
freeze: true,
|
||||
callback: function(r) {},
|
||||
onerror: function() {
|
||||
frappe.msgprint(__("Wrong Password"));
|
||||
frm.set_value("enabled", 0);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
unregister_from_hub: (frm) => {
|
||||
frappe.verify_password(() => {
|
||||
@@ -85,3 +112,67 @@ frappe.ui.form.on("Hub Settings", {
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
// let hub_url = 'https://hubmarket.org'
|
||||
let hub_url = 'http://159.89.175.122'
|
||||
// let hub_url = 'http://erpnext.hub:8000'
|
||||
|
||||
function authorize(frm, client_id, redirect_uri) {
|
||||
|
||||
// queryStringData is details of OAuth Client (Implicit Grant) on Custom App
|
||||
var queryStringData = {
|
||||
response_type : "token",
|
||||
client_id : client_id,
|
||||
redirect_uri : redirect_uri
|
||||
}
|
||||
|
||||
// Get current raw route and build url
|
||||
const route = "/desk#" + frappe.get_raw_route_str();
|
||||
localStorage.removeItem("route"); // Clear previously set route if any
|
||||
localStorage.setItem("route", route);
|
||||
|
||||
// Go authorize!
|
||||
let api_route = "/api/method/frappe.integrations.oauth2.authorize?";
|
||||
let url = hub_url + api_route + $.param(queryStringData);
|
||||
window.location.replace(url, 'test');
|
||||
}
|
||||
|
||||
function get_user_details(frm, token, email) {
|
||||
console.log('user_details');
|
||||
var route = localStorage.getItem("route");
|
||||
if (token && route) {
|
||||
// Clean up access token from route
|
||||
frappe.set_route(frappe.get_route().join("/"))
|
||||
|
||||
// query protected resource e.g. Hub Items with token
|
||||
var call = {
|
||||
"async": true,
|
||||
"crossDomain": true,
|
||||
"url": hub_url + "/api/resource/User",
|
||||
"method": "GET",
|
||||
"data": {
|
||||
// "email": email,
|
||||
"fields": '["name", "first_name", "language"]',
|
||||
"limit_page_length": 1
|
||||
},
|
||||
"headers": {
|
||||
"authorization": "Bearer " + token,
|
||||
"content-type": "application/x-www-form-urlencoded"
|
||||
}
|
||||
}
|
||||
$.ajax(call).done(function (response) {
|
||||
// display openid profile
|
||||
console.log('response', response);
|
||||
|
||||
let data = response.data[0];
|
||||
frm.set_value("enabled", 1);
|
||||
frm.set_value("hub_username", data.first_name);
|
||||
frm.set_value("hub_user_status", "Starter");
|
||||
frm.set_value("language", data.language);
|
||||
frm.save();
|
||||
|
||||
// clear route from localStorage
|
||||
localStorage.removeItem("route");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
@@ -70,6 +71,39 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "enabled",
|
||||
"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": 0,
|
||||
"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": 1,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
@@ -101,6 +135,102 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "column_break_0",
|
||||
"fieldtype": "Column 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": "",
|
||||
"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_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "enabled",
|
||||
"fieldname": "hub_user_status",
|
||||
"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": "Status",
|
||||
"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_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "enabled",
|
||||
"fieldname": "language",
|
||||
"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": "Language",
|
||||
"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
|
||||
},
|
||||
{
|
||||
@@ -133,6 +263,38 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "company_registered",
|
||||
"fieldtype": "Check",
|
||||
"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 Registered",
|
||||
"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
|
||||
},
|
||||
{
|
||||
@@ -164,6 +326,38 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "company_email",
|
||||
"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": "Company Email",
|
||||
"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
|
||||
},
|
||||
{
|
||||
@@ -195,6 +389,38 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 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
|
||||
},
|
||||
{
|
||||
@@ -225,6 +451,70 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "users_sb",
|
||||
"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": "Enabled Users",
|
||||
"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_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "users",
|
||||
"fieldtype": "Table",
|
||||
"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": "Users",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Hub Users",
|
||||
"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
|
||||
},
|
||||
{
|
||||
@@ -256,6 +546,7 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
@@ -286,6 +577,7 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
@@ -317,6 +609,7 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
@@ -349,6 +642,7 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
@@ -380,6 +674,7 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
@@ -411,6 +706,7 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
@@ -418,6 +714,39 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"default": "",
|
||||
"depends_on": "eval:1",
|
||||
"fieldname": "custom_data",
|
||||
"fieldtype": "Code",
|
||||
"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": "Custom Data",
|
||||
"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_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 1,
|
||||
"collapsible_depends_on": "",
|
||||
"columns": 0,
|
||||
"depends_on": "enabled",
|
||||
@@ -443,6 +772,7 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
@@ -473,6 +803,7 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
}
|
||||
],
|
||||
@@ -486,8 +817,8 @@
|
||||
"issingle": 1,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2017-09-21 12:13:50.841646",
|
||||
"modified_by": "manas@erpnext.com",
|
||||
"modified": "2018-03-26 00:55:17.929140",
|
||||
"modified_by": "test1@example.com",
|
||||
"module": "Hub Node",
|
||||
"name": "Hub Settings",
|
||||
"name_case": "",
|
||||
|
||||
@@ -10,7 +10,24 @@ from frappe import _
|
||||
from erpnext.utilities.product import get_price, get_qty_in_stock
|
||||
from six import string_types
|
||||
|
||||
hub_url = "https://hubmarket.org"
|
||||
# hub_url = "https://hubmarket.org"
|
||||
hub_url = "http://159.89.175.122"
|
||||
# hub_url = "http://erpnext.hub:8000"
|
||||
|
||||
# test_hub_url = "https://hubmarket.org"
|
||||
|
||||
class OAuth2Session():
|
||||
def __init__(self, headers):
|
||||
self.headers = headers
|
||||
def get(self, url, params, headers, verify):
|
||||
res = requests.get(url, params=params, headers=self.headers, verify=verify)
|
||||
return res
|
||||
def post(self, url, data, verify):
|
||||
res = requests.post(url, data=data, headers=self.headers, verify=verify)
|
||||
return res
|
||||
def put(self, url, data, verify):
|
||||
res = requests.put(url, data=data, headers=self.headers, verify=verify)
|
||||
return res
|
||||
|
||||
class HubSetupError(frappe.ValidationError): pass
|
||||
|
||||
@@ -35,6 +52,33 @@ class HubSettings(Document):
|
||||
|
||||
doc.run()
|
||||
|
||||
def pre_reg(self):
|
||||
site_name = frappe.local.site + ':' + str(frappe.conf.webserver_port)
|
||||
protocol = 'http://'
|
||||
route = '/token'
|
||||
data = {
|
||||
'site_name': site_name,
|
||||
'protocol': protocol,
|
||||
'route': route
|
||||
}
|
||||
|
||||
redirect_url = protocol + site_name + route
|
||||
post_url = hub_url + '/api/method/hub.hub.api.pre_reg'
|
||||
|
||||
response = requests.post(post_url, data=data)
|
||||
response.raise_for_status()
|
||||
message = response.json().get('message')
|
||||
|
||||
if message and message.get('client_id'):
|
||||
print("======CLIENT_ID======")
|
||||
print(message.get('client_id'))
|
||||
|
||||
return {
|
||||
'client_id': message.get('client_id'),
|
||||
'redirect_uri': redirect_url
|
||||
}
|
||||
|
||||
|
||||
def register(self):
|
||||
""" Create a User on hub.erpnext.org and return username/password """
|
||||
data = {
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('Hub Tracked Item', {
|
||||
refresh: function(frm) {
|
||||
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,93 @@
|
||||
{
|
||||
"allow_copy": 0,
|
||||
"allow_guest_to_view": 0,
|
||||
"allow_import": 0,
|
||||
"allow_rename": 0,
|
||||
"beta": 0,
|
||||
"creation": "2018-03-18 09:33:50.267762",
|
||||
"custom": 0,
|
||||
"docstatus": 0,
|
||||
"doctype": "DocType",
|
||||
"document_type": "",
|
||||
"editable_grid": 1,
|
||||
"engine": "InnoDB",
|
||||
"fields": [
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "item_code",
|
||||
"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": "Item Code",
|
||||
"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": 1,
|
||||
"is_submittable": 0,
|
||||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2018-03-18 09:34:01.757713",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Hub Node",
|
||||
"name": "Hub Tracked Item",
|
||||
"name_case": "",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
{
|
||||
"amend": 0,
|
||||
"apply_user_permissions": 0,
|
||||
"cancel": 0,
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"if_owner": 0,
|
||||
"import": 0,
|
||||
"permlevel": 0,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "System Manager",
|
||||
"set_user_permissions": 0,
|
||||
"share": 1,
|
||||
"submit": 0,
|
||||
"write": 1
|
||||
}
|
||||
],
|
||||
"quick_entry": 1,
|
||||
"read_only": 1,
|
||||
"read_only_onload": 0,
|
||||
"show_name_in_global_search": 0,
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"track_changes": 1,
|
||||
"track_seen": 0
|
||||
}
|
||||
@@ -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 HubTrackedItem(Document):
|
||||
pass
|
||||
@@ -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: Hub Tracked Item", function (assert) {
|
||||
let done = assert.async();
|
||||
|
||||
// number of asserts
|
||||
assert.expect(1);
|
||||
|
||||
frappe.run_serially([
|
||||
// insert a new Hub Tracked Item
|
||||
() => frappe.tests.make('Hub Tracked Item', [
|
||||
// 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 TestHubTrackedItem(unittest.TestCase):
|
||||
pass
|
||||
0
erpnext/hub_node/doctype/hub_users/__init__.py
Normal file
0
erpnext/hub_node/doctype/hub_users/__init__.py
Normal file
72
erpnext/hub_node/doctype/hub_users/hub_users.json
Normal file
72
erpnext/hub_node/doctype/hub_users/hub_users.json
Normal file
@@ -0,0 +1,72 @@
|
||||
{
|
||||
"allow_copy": 0,
|
||||
"allow_guest_to_view": 0,
|
||||
"allow_import": 0,
|
||||
"allow_rename": 0,
|
||||
"beta": 0,
|
||||
"creation": "2018-03-06 04:38:49.891787",
|
||||
"custom": 0,
|
||||
"docstatus": 0,
|
||||
"doctype": "DocType",
|
||||
"document_type": "",
|
||||
"editable_grid": 1,
|
||||
"engine": "InnoDB",
|
||||
"fields": [
|
||||
{
|
||||
"allow_bulk_edit": 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,
|
||||
"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-03-06 04:41:17.916243",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Hub Node",
|
||||
"name": "Hub Users",
|
||||
"name_case": "",
|
||||
"owner": "test1@example.com",
|
||||
"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
|
||||
}
|
||||
10
erpnext/hub_node/doctype/hub_users/hub_users.py
Normal file
10
erpnext/hub_node/doctype/hub_users/hub_users.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 HubUsers(Document):
|
||||
pass
|
||||
Reference in New Issue
Block a user