Merge branch 'develop'
This commit is contained in:
commit
9e4cb5f1d1
11 changed files with 62 additions and 36 deletions
|
|
@ -1,2 +1,2 @@
|
|||
from __future__ import unicode_literals
|
||||
__version__ = "5.0.6"
|
||||
__version__ = "5.0.7"
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ app_title = "Frappe Framework"
|
|||
app_publisher = "Frappe Technologies Pvt. Ltd."
|
||||
app_description = "Full Stack Web Application Framework in Python"
|
||||
app_icon = "octicon octicon-circuit-board"
|
||||
app_version = "5.0.6"
|
||||
app_version = "5.0.7"
|
||||
app_color = "orange"
|
||||
|
||||
app_email = "support@frappe.io"
|
||||
|
|
|
|||
|
|
@ -545,10 +545,10 @@ class BaseDocument(object):
|
|||
return val
|
||||
|
||||
def _extract_images_from_text_editor(self):
|
||||
from frappe.utils.file_manager import extract_images_from_html
|
||||
from frappe.utils.file_manager import extract_images_from_doc
|
||||
if self.doctype != "DocType":
|
||||
for df in self.meta.get("fields", {"fieldtype":"Text Editor"}):
|
||||
extract_images_from_html(self, df.fieldname)
|
||||
extract_images_from_doc(self, df.fieldname)
|
||||
|
||||
def _filter(data, filters, limit=None):
|
||||
"""pass filters as:
|
||||
|
|
|
|||
|
|
@ -203,4 +203,4 @@ def insert_feed(doc):
|
|||
|
||||
def delete_shared(doc):
|
||||
delete_doc("DocShare", frappe.db.sql_list("""select name from `tabDocShare`
|
||||
where share_doctype=%s and share_name=%s""", (doc.doctype, doc.name)))
|
||||
where share_doctype=%s and share_name=%s""", (doc.doctype, doc.name)), ignore_on_trash=True)
|
||||
|
|
|
|||
|
|
@ -78,9 +78,8 @@ def rename_versions(doctype, old, new):
|
|||
|
||||
def rename_parent_and_child(doctype, old, new, meta):
|
||||
# rename the doc
|
||||
frappe.db.sql("update `tab%s` set name=%s where name=%s" \
|
||||
% (doctype, '%s', '%s'), (new, old))
|
||||
|
||||
frappe.db.sql("update `tab%s` set name=%s where name=%s" % (doctype, '%s', '%s'),
|
||||
(new, old))
|
||||
update_child_docs(old, new, meta)
|
||||
|
||||
def validate_rename(doctype, new, meta, merge, force, ignore_permissions):
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
import frappe.utils
|
||||
import json
|
||||
from jinja2 import TemplateSyntaxError
|
||||
|
||||
from frappe.model.document import Document
|
||||
|
|
@ -20,6 +21,8 @@ class PrintFormat(Document):
|
|||
self.old_doc_type = frappe.db.get_value('Print Format',
|
||||
self.name, 'doc_type')
|
||||
|
||||
self.extract_images()
|
||||
|
||||
if self.html:
|
||||
jenv = frappe.get_jenv()
|
||||
try:
|
||||
|
|
@ -28,6 +31,15 @@ class PrintFormat(Document):
|
|||
frappe.msgprint('Line {}: {}'.format(e.lineno, e.message))
|
||||
frappe.throw(frappe._("Syntax error in Jinja template"))
|
||||
|
||||
def extract_images(self):
|
||||
from frappe.utils.file_manager import extract_images_from_html
|
||||
if self.format_data:
|
||||
data = json.loads(self.format_data)
|
||||
for df in data:
|
||||
if df.get('fieldtype') and df['fieldtype'] in ('HTML', 'Custom HTML') and df.get('options'):
|
||||
df['options'] = extract_images_from_html(self, df['options'])
|
||||
self.format_data = json.dumps(data)
|
||||
|
||||
def on_update(self):
|
||||
if hasattr(self, 'old_doc_type') and self.old_doc_type:
|
||||
frappe.clear_cache(doctype=self.old_doc_type)
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ frappe.ui.form.States = Class.extend({
|
|||
},
|
||||
|
||||
set_default_state: function() {
|
||||
var default_state = frappe.workflow.get_default_state(this.frm.doctype);
|
||||
var default_state = frappe.workflow.get_default_state(this.frm.doctype, this.frm.doc.docstatus);
|
||||
if(default_state) {
|
||||
this.frm.set_value(this.state_fieldname, default_state);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,20 @@ frappe.get_indicator = function(doc, doctype) {
|
|||
is_submittable = frappe.model.is_submittable(doctype),
|
||||
workflow_fieldname = frappe.workflow.get_state_fieldname(doctype);
|
||||
|
||||
// workflow
|
||||
if(workflow_fieldname) {
|
||||
var value = doc[workflow_fieldname];
|
||||
if(value) {
|
||||
var colour = {
|
||||
"Success": "green",
|
||||
"Warning": "orange",
|
||||
"Danger": "red",
|
||||
"Primary": "blue",
|
||||
}[locals["Workflow State"][value].style] || "darkgrey";
|
||||
return [__(value), colour, workflow_fieldname + ',=,' + value];
|
||||
}
|
||||
}
|
||||
|
||||
if(is_submittable && doc.docstatus==0) {
|
||||
return [__("Draft"), "red", "docstatus,=,0"];
|
||||
}
|
||||
|
|
@ -20,18 +34,6 @@ frappe.get_indicator = function(doc, doctype) {
|
|||
return [__("Cancelled"), "red", "docstatus,=,2"];
|
||||
}
|
||||
|
||||
// workflow
|
||||
if(workflow_fieldname) {
|
||||
var value = doc[workflow_fieldname];
|
||||
var colour = {
|
||||
"Success": "green",
|
||||
"Warning": "orange",
|
||||
"Danger": "red",
|
||||
"Primary": "blue",
|
||||
}[locals["Workflow State"][value].style] || "darkgrey";
|
||||
return [__(value), colour, workflow_fieldname + ',=,' + value];
|
||||
}
|
||||
|
||||
if(_get_indicator) {
|
||||
var indicator = _get_indicator(doc);
|
||||
if(indicator) return indicator;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
// MIT License. See license.txt
|
||||
// MIT License. See license.txt
|
||||
|
||||
frappe.provide("frappe.workflow");
|
||||
|
||||
|
|
@ -13,7 +13,7 @@ frappe.workflow = {
|
|||
frappe.workflow.state_fields[doctype] = wf[0].workflow_state_field;
|
||||
} else {
|
||||
frappe.workflow.state_fields[doctype] = null;
|
||||
}
|
||||
}
|
||||
},
|
||||
get_state_fieldname: function(doctype) {
|
||||
if(frappe.workflow.state_fields[doctype]===undefined) {
|
||||
|
|
@ -21,9 +21,16 @@ frappe.workflow = {
|
|||
}
|
||||
return frappe.workflow.state_fields[doctype];
|
||||
},
|
||||
get_default_state: function(doctype) {
|
||||
get_default_state: function(doctype, docstatus) {
|
||||
frappe.workflow.setup(doctype);
|
||||
return frappe.workflow.workflows[doctype].states[0].state;
|
||||
var value = null;
|
||||
$.each(frappe.workflow.workflows[doctype].states, function(i, workflow_state) {
|
||||
if(cint(workflow_state.doc_status)===cint(docstatus)) {
|
||||
value = workflow_state.state;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return value;
|
||||
},
|
||||
get_transitions: function(doctype, state) {
|
||||
frappe.workflow.setup(doctype);
|
||||
|
|
@ -40,13 +47,14 @@ frappe.workflow = {
|
|||
is_read_only: function(doctype, name) {
|
||||
var state_fieldname = frappe.workflow.get_state_fieldname(doctype);
|
||||
if(state_fieldname) {
|
||||
if(!locals[doctype][name])
|
||||
var doc = locals[doctype][name];
|
||||
if(!doc)
|
||||
return false;
|
||||
if(locals[doctype][name].__islocal)
|
||||
if(doc.__islocal)
|
||||
return false;
|
||||
|
||||
var state = locals[doctype][name][state_fieldname] ||
|
||||
frappe.workflow.get_default_state(doctype);
|
||||
|
||||
var state = doc[state_fieldname] ||
|
||||
frappe.workflow.get_default_state(doctype, doc.docstatus);
|
||||
|
||||
var allow_edit = state ? frappe.workflow.get_document_state(doctype, state).allow_edit : null;
|
||||
|
||||
|
|
@ -57,10 +65,10 @@ frappe.workflow = {
|
|||
return false;
|
||||
},
|
||||
get_update_fields: function(doctype) {
|
||||
var update_fields = $.unique($.map(frappe.workflow.workflows[doctype].states || [],
|
||||
var update_fields = $.unique($.map(frappe.workflow.workflows[doctype].states || [],
|
||||
function(d) {
|
||||
return d.update_field;
|
||||
}));
|
||||
return update_fields;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -83,8 +83,13 @@ def get_uploaded_content():
|
|||
frappe.msgprint(_('No file attached'))
|
||||
return None, None
|
||||
|
||||
def extract_images_from_html(doc, fieldname):
|
||||
def extract_images_from_doc(doc, fieldname):
|
||||
content = doc.get(fieldname)
|
||||
content = extract_images_from_html(doc, content)
|
||||
if frappe.flags.has_dataurl:
|
||||
doc.set(fieldname, content)
|
||||
|
||||
def extract_images_from_html(doc, content):
|
||||
frappe.flags.has_dataurl = False
|
||||
|
||||
def _save_file(match):
|
||||
|
|
@ -110,8 +115,8 @@ def extract_images_from_html(doc, fieldname):
|
|||
|
||||
if content:
|
||||
content = re.sub('<img[^>]*src\s*=\s*["\'](?=data:)(.*?)["\']', _save_file, content)
|
||||
if frappe.flags.has_dataurl:
|
||||
doc.set(fieldname, content)
|
||||
|
||||
return content
|
||||
|
||||
def get_random_filename(extn=None, content_type=None):
|
||||
if extn:
|
||||
|
|
|
|||
2
setup.py
2
setup.py
|
|
@ -1,6 +1,6 @@
|
|||
from setuptools import setup, find_packages
|
||||
|
||||
version = "5.0.6"
|
||||
version = "5.0.7"
|
||||
|
||||
with open("requirements.txt", "r") as f:
|
||||
install_requires = f.readlines()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue