Merge branch 'v7.2.0-beta' into develop

This commit is contained in:
Rushabh Mehta 2016-12-23 09:42:41 +05:30
commit 5ce11a8cb7
5 changed files with 11 additions and 60 deletions

View file

@ -1,53 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt
from __future__ import unicode_literals
import frappe
import json
from frappe.desk.form.linked_with import get_linked_docs, get_linked_doctypes
@frappe.whitelist()
def get_document_completion_status(doctypes, frm_doctype, frm_docname):
if isinstance(doctypes, basestring):
doctypes = json.loads(doctypes)
doc = frappe.get_doc(frm_doctype, frm_docname)
linkinfo = get_linked_doctypes(frm_doctype)
flow_completion = {}
if hasattr(doc, "prev_link_mapper"):
for doctype in doc.prev_link_mapper:
fieldname = doc.prev_link_mapper[doctype]["fieldname"]
lookup_doctype = doc.prev_link_mapper[doctype]["doctype"]
limit = doc.prev_link_mapper[doctype].get("limit") or 1
condition = make_condition(doc.prev_link_mapper[doctype].get("filters"))
if condition:
condition = "where {condition}".format(condition=condition)
else:
condition = ""
result = frappe.db.sql_list("select {fieldname} from `tab{doctype}` \
{condition} limit {limit}".format(fieldname=fieldname, doctype=lookup_doctype,
condition=condition, limit=limit))
if result:
flow_completion[doctype] = True
for doctype in doctypes:
if doctype not in flow_completion:
links = get_linked_docs(frm_doctype, frm_docname, linkinfo, for_doctype=doctype)
if links:
flow_completion[doctype] = True
return flow_completion
def make_condition(filters=None):
condition = []
if filters and isinstance(filters, list):
for cond in filters:
condition.append("`tab{0}`.{1} {2} '{3}'".format(*cond))
return " and ".join(condition)

View file

@ -93,7 +93,7 @@ frappe.ui.form.Grid = Class.extend({
this.wrapper.find('.grid-body .grid-row-check:checked:first').length ? false : true);
},
get_selected: function() {
return this.grid_rows.map(function(row) { return row.doc.__checked ? row.doc.name : null; })
return (this.grid_rows || []).map(function(row) { return row.doc.__checked ? row.doc.name : null; })
.filter(function(d) { return d; });
},
make_head: function() {

View file

@ -622,8 +622,6 @@ frappe.views.QueryReport = Class.extend({
item._collapsed = collapse;
me.dataView.updateItem(item.id, item);
}
$(".collapse-all").prop('disabled', collapse);
$(".expand-all").prop('disabled', !collapse);
},
tree_filter: function(item) {
var me = frappe.query_report;
@ -788,10 +786,8 @@ frappe.views.QueryReport = Class.extend({
if (item) {
if (!item._collapsed) {
item._collapsed = true;
$(".expand-all").prop('disabled', false);
} else {
item._collapsed = false;
$(".collapse-all").prop('disabled', false);
}
me.dataView.updateItem(item.id, item);

View file

@ -66,7 +66,7 @@ def clear_sessions(user=None, keep_current=False, device=None):
condition = ''
if keep_current:
condition = ' and sid != "{0}"'.format(frappe.session.sid)
condition = ' and sid != "{0}"'.format(frappe.db.escape(frappe.session.sid))
for i, sid in enumerate(frappe.db.sql_list("""select sid from tabSessions

View file

@ -2,7 +2,7 @@
# MIT License. See license.txt
from __future__ import unicode_literals
import frappe
import frappe, os, json
from frappe.website.doctype.website_settings.website_settings import get_website_settings
from frappe.website.router import get_page_context
@ -105,6 +105,13 @@ def build_context(context):
if context.show_sidebar:
context.no_cache = 1
add_sidebar_data(context)
else:
sidebar_json_path = os.path.join(context.basepath, '_sidebar.json')
if os.path.exists(sidebar_json_path):
with open(sidebar_json_path, 'r') as sidebarfile:
context.sidebar_items = json.loads(sidebarfile.read())
context.show_sidebar = 1
# determine templates to be used
if not context.base_template_path:
@ -118,6 +125,7 @@ def add_sidebar_data(context):
import frappe.www.list
if not context.sidebar_items:
sidebar_items = frappe.cache().hget('portal_menu_items', frappe.session.user)
if sidebar_items == None:
sidebar_items = []