[hub] Publishing Dialog, Sync category

- Hub Category selection
- Recycled
This commit is contained in:
Prateeksha Singh
2018-08-19 19:39:00 +05:30
parent c1fe1c45c7
commit 0a60d1cd96
4 changed files with 198 additions and 39 deletions

View File

@@ -42,11 +42,19 @@ def get_valid_items(search_value=''):
def publish_selected_items(items_to_publish):
items_to_publish = json.loads(items_to_publish)
if not len(items_to_publish):
return
frappe.throw('No items to publish')
for item_code in items_to_publish:
for item in items_to_publish:
item_code = item.get('item_code')
frappe.db.set_value('Item', item_code, 'publish_in_hub', 1)
frappe.get_doc({
'doctype': 'Hub Tracked Item',
'item_code': item_code,
'hub_category': item.get('hub_category'),
# 'images': item.get('images')
}).insert()
try:
hub_settings = frappe.get_doc('Hub Settings')
item_sync_preprocess()

View File

@@ -1,19 +1,24 @@
import io, base64, urllib, os
import frappe, io, base64, urllib, os
def pre_process(doc):
file_path = doc.image
file_name = os.path.basename(file_path)
# file_path = doc.image
# file_name = os.path.basename(file_path)
if file_path.startswith('http'):
url = file_path
file_path = os.path.join('/tmp', file_name)
urllib.urlretrieve(url, file_path)
# if file_path.startswith('http'):
# url = file_path
# file_path = os.path.join('/tmp', file_name)
# urllib.urlretrieve(url, file_path)
with io.open(file_path, 'rb') as f:
doc.image = base64.b64encode(f.read())
# with io.open(file_path, 'rb') as f:
# doc.image = base64.b64encode(f.read())
doc.image_file_name = file_name
# doc.image_file_name = file_name
cached_details = frappe.get_doc('Hub Tracked Item', doc.item_code)
if cached_details:
doc.hub_category = cached_details.hub_category
return doc

View File

@@ -3,6 +3,7 @@
"allow_guest_to_view": 0,
"allow_import": 0,
"allow_rename": 0,
"autoname": "field:item_code",
"beta": 0,
"creation": "2018-03-18 09:33:50.267762",
"custom": 0,
@@ -14,6 +15,7 @@
"fields": [
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -41,6 +43,70 @@
"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_category",
"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 Category",
"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": "images",
"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": "Images",
"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
}
],
@@ -49,12 +115,12 @@
"hide_toolbar": 0,
"idx": 0,
"image_view": 0,
"in_create": 1,
"in_create": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2018-03-18 09:34:01.757713",
"modified": "2018-08-19 19:30:01.449904",
"modified_by": "Administrator",
"module": "Hub Node",
"name": "Hub Tracked Item",
@@ -63,7 +129,6 @@
"permissions": [
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1,
"delete": 1,
@@ -89,5 +154,6 @@
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 1,
"track_seen": 0
"track_seen": 0,
"track_views": 0
}