[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

@@ -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