Merge branch 'hotfix'

This commit is contained in:
Saurabh 2017-11-22 18:02:53 +05:30
commit e4630bdbfb
6 changed files with 28 additions and 12 deletions

View file

@ -14,7 +14,7 @@ import os, sys, importlib, inspect, json
from .exceptions import *
from .utils.jinja import get_jenv, get_template, render_template, get_email_from_template
__version__ = '9.2.15'
__version__ = '9.2.16'
__title__ = "Frappe Framework"
local = Local()

View file

@ -5,7 +5,7 @@
<label>
<input type="checkbox" data-module="{{ icon.module_name }}" class="module-select"
{% if not (icon.hidden if user else icon.blocked) %}checked{% endif %}>
{{ _(icon.label or icon.module_name) }}
{{ frappe.db.escape(_(icon.label or icon.module_name)) }}
</label>
</div>
</div>

View file

@ -197,9 +197,11 @@ def check_if_doc_is_linked(doc, method="Delete"):
# raise exception only if
# linked to an non-cancelled doc when deleting
# or linked to a submitted doc when cancelling
frappe.throw(_('Cannot delete or cancel because {0} <a href="#Form/{0}/{1}">{1}</a> is linked with {2} <a href="#Form/{2}/{3}">{3}</a>')
.format(doc.doctype, doc.name, linked_doctype,
item.parent or item.name), frappe.LinkExistsError)
reference_docname = item.parent or item.name
raise_link_exists_exception(doc, linked_doctype, reference_docname)
else:
if frappe.db.get_value(link_dt, None, link_field) == doc.name:
raise_link_exists_exception(doc, link_dt, link_dt)
def check_if_doc_is_dynamically_linked(doc, method="Delete"):
'''Raise `frappe.LinkExistsError` if the document is dynamically linked'''
@ -220,8 +222,7 @@ def check_if_doc_is_dynamically_linked(doc, method="Delete"):
# raise exception only if
# linked to an non-cancelled doc when deleting
# or linked to a submitted doc when cancelling
frappe.throw(_('Cannot delete or cancel because {0} <a href="#Form/{0}/{1}">{1}</a> is linked with {2} <a href="#Form/{2}/{3}">{3}</a>').format(doc.doctype,
doc.name, df.parent, ""), frappe.LinkExistsError)
raise_link_exists_exception(doc, df.parent, df.parent)
else:
# dynamic link in table
df["table"] = ", parent, parenttype, idx" if meta.istable else ""
@ -232,9 +233,23 @@ def check_if_doc_is_dynamically_linked(doc, method="Delete"):
# raise exception only if
# linked to an non-cancelled doc when deleting
# or linked to a submitted doc when cancelling
frappe.throw(_('Cannot delete or cancel because {0} <a href="#Form/{0}/{1}">{1}</a> is linked with {2} <a href="#Form/{2}/{3}">{3}</a> {4}')\
.format(doc.doctype, doc.name, refdoc.parenttype if meta.istable else df.parent,
refdoc.parent if meta.istable else refdoc.name,"Row: {0}".format(refdoc.idx) if meta.istable else ""), frappe.LinkExistsError)
reference_doctype = refdoc.parenttype if meta.istable else df.parent
reference_docname = refdoc.parent if meta.istable else refdoc.name
at_position = "at Row: {0}".format(refdoc.idx) if meta.istable else ""
raise_link_exists_exception(doc, reference_doctype, reference_docname, at_position)
def raise_link_exists_exception(doc, reference_doctype, reference_docname, row=''):
doc_link = '<a href="#Form/{0}/{1}">{1}</a>'.format(doc.doctype, doc.name)
reference_link = '<a href="#Form/{0}/{1}">{1}</a>'.format(reference_doctype, reference_docname)
#hack to display Single doctype only once in message
if reference_doctype == reference_docname:
reference_doctype = ''
frappe.throw(_('Cannot delete or cancel because {0} {1} is linked with {2} {3} {4}')
.format(doc.doctype, doc_link, reference_doctype, reference_link, row), frappe.LinkExistsError)
def delete_dynamic_links(doctype, name):
delete_doc("ToDo", frappe.db.sql_list("""select name from `tabToDo`

View file

@ -308,7 +308,7 @@ frappe.ui.form.GridRow = Class.extend({
} else {
this.row.toggleClass('editable-row', false);
this.columns_list.forEach(function(column) {
if (column.df.hidden == false) {
if (!column.df.hidden) {
column.static_area.toggle(true);
}

View file

@ -153,6 +153,7 @@ def get_allowed_functions_for_jenv():
out['frappe']["db"] = {
"get_value": frappe.db.get_value,
"get_default": frappe.db.get_default,
"escape": frappe.db.escape,
}
return out

View file

@ -41,7 +41,7 @@ class HelpArticle(WebsiteGenerator):
context.parents = self.get_parents(context)
def get_parents(self, context):
return [{"title": context.category.category_name, "name":context.category.route}]
return [{"title": context.category.category_name, "route":context.category.route}]
def get_list_context(context=None):
filters = dict(published=1)