@@ -1,61 +1,53 @@ | |||
[ | |||
{ | |||
"owner": "Administrator", | |||
"creation": "2013-01-10 16:34:03", | |||
"docstatus": 0, | |||
"creation": "2012-07-03 13:29:35", | |||
"modified": "2013-01-22 17:40:49", | |||
"modified_by": "Administrator", | |||
"modified": "2012-12-10 19:11:05" | |||
"owner": "Administrator" | |||
}, | |||
{ | |||
"autoname": "field:module_name", | |||
"name": "__common__", | |||
"allow_rename": 1, | |||
"autoname": "field:module_name", | |||
"doctype": "DocType", | |||
"module": "Core" | |||
"module": "Core", | |||
"name": "__common__" | |||
}, | |||
{ | |||
"doctype": "DocField", | |||
"fieldname": "module_name", | |||
"fieldtype": "Data", | |||
"label": "Module Name", | |||
"name": "__common__", | |||
"oldfieldname": "module_name", | |||
"oldfieldtype": "Data", | |||
"parent": "Module Def", | |||
"doctype": "DocField", | |||
"parentfield": "fields", | |||
"parenttype": "DocType", | |||
"permlevel": 0, | |||
"parentfield": "fields" | |||
"permlevel": 0 | |||
}, | |||
{ | |||
"parent": "Module Def", | |||
"read": 1, | |||
"cancel": 1, | |||
"name": "__common__", | |||
"amend": 0, | |||
"cancel": 1, | |||
"create": 1, | |||
"doctype": "DocPerm", | |||
"submit": 0, | |||
"write": 1, | |||
"name": "__common__", | |||
"parent": "Module Def", | |||
"parentfield": "permissions", | |||
"parenttype": "DocType", | |||
"role": "Administrator", | |||
"permlevel": 0, | |||
"parentfield": "permissions" | |||
}, | |||
{ | |||
"name": "Module Def", | |||
"doctype": "DocType" | |||
"read": 1, | |||
"report": 1, | |||
"role": "Administrator", | |||
"submit": 0, | |||
"write": 1 | |||
}, | |||
{ | |||
"oldfieldtype": "Data", | |||
"doctype": "DocField", | |||
"label": "Module Name", | |||
"oldfieldname": "module_name", | |||
"fieldname": "module_name", | |||
"fieldtype": "Data" | |||
"doctype": "DocType", | |||
"name": "Module Def" | |||
}, | |||
{ | |||
"oldfieldtype": "Select", | |||
"doctype": "DocField", | |||
"label": "Disabled", | |||
"oldfieldname": "disabled", | |||
"fieldname": "disabled", | |||
"fieldtype": "Select", | |||
"options": "No\nYes" | |||
"doctype": "DocField" | |||
}, | |||
{ | |||
"doctype": "DocPerm" | |||
@@ -30,14 +30,7 @@ wn.doclistviews['Profile'] = wn.views.ListView.extend({ | |||
columns: [ | |||
{width: '3%', content: 'check'}, | |||
{width: '5%', content: 'avatar'}, | |||
{width: '3%', content: function(parent, data) { | |||
var enabled = cint(data.enabled); | |||
$(parent).html(repl('<span class="docstatus"><i class="%(icon)s" \ | |||
title="%(title)s"></i></span>', { | |||
icon: enabled ? "icon-pencil": "icon-exclamation-sign", | |||
title: enabled ? "Enabled": "Disabled", | |||
})); | |||
}}, | |||
{width: '3%', content: "enabled"}, | |||
{width: '40%', content: 'name'}, | |||
{width: '35%', content: 'fullname+tags'}, | |||
{width: '17%', content:'modified', | |||
@@ -73,6 +73,18 @@ wn.views.ListView = Class.extend({ | |||
<i class="%(docstatus_icon)s" \ | |||
title="%(docstatus_title)s"></i></span>', data)); | |||
} | |||
else if(opts.content=='enabled') { | |||
data.icon = cint(data.enabled) ? "icon-check" : "icon-check-empty"; | |||
data.title = cint(data.enabled) ? wn._("Enabled") : wn._("Disabled"); | |||
$(parent).append(repl('<span class="docstatus"> \ | |||
<i class="%(icon)s" title="%(title)s"></i></span>', data)); | |||
} | |||
else if(opts.content=='disabled') { | |||
data.icon = cint(data.disabled) ? "icon-check-empty" : "icon-check" | |||
data.title = cint(data.disabled) ? wn._("Disabled") : wn._("Enabled"); | |||
$(parent).append(repl('<span class="docstatus"> \ | |||
<i class="%(icon)s"></i></span>', data)); | |||
} | |||
else if(opts.content=='tags') { | |||
this.add_user_tags(parent, data); | |||
} | |||
@@ -81,9 +81,9 @@ def load_country_and_currency(bootinfo, doclist): | |||
if bootinfo.control_panel.country and \ | |||
webnotes.conn.exists("Country", bootinfo.control_panel.country): | |||
doclist += [webnotes.doc("Country", bootinfo.control_panel.country)] | |||
if bootinfo.sysdefaults.currency and \ | |||
webnotes.conn.exists("Currency", bootinfo.sysdefaults.currency): | |||
doclist += [webnotes.doc("Currency", bootinfo.sysdefaults.currency)] | |||
doclist += webnotes.conn.sql("""select * from tabCurrency | |||
where ifnull(enabled,0)=1""", as_dict=1, update={"doctype":"Currency"}) | |||
def add_allowed_pages(bootinfo): | |||
bootinfo.allowed_pages = [p[0] for p in webnotes.conn.sql("""select distinct parent from `tabPage Role` | |||
@@ -51,10 +51,8 @@ def compress(doclist): | |||
Compress a doclist before sending it to the client side. (Internally used by the request handler) | |||
""" | |||
if doclist and hasattr(doclist[0],'fields'): | |||
docs = [d.fields for d in doclist] | |||
else: | |||
docs = doclist | |||
from webnotes.model.doc import Document | |||
docs = [isinstance(d, Document) and d.fields or d for d in doclist] | |||
kl, vl = {}, [] | |||
forbidden = ['server_code_compiled'] | |||
@@ -50,9 +50,18 @@ def getsearchfields(): | |||
webnotes.response['searchfields'] = [['name', 'ID', 'Data', '']] + res | |||
def make_query(fields, dt, key, txt, start, length): | |||
query = """SELECT %(fields)s | |||
doctype = webnotes.get_doctype(dt) | |||
enabled_condition = "" | |||
if doctype.get({"parent":dt, "fieldname":"enabled", "fieldtype":"Check"}): | |||
enabled_condition = " AND ifnull(`tab%s`.`enabled`,0)=1" % dt | |||
if doctype.get({"parent":dt, "fieldname":"disabled", "fieldtype":"Check"}): | |||
enabled_condition = " AND ifnull(`tab%s`.`disabled`,0)!=1" % dt | |||
query = """select %(fields)s | |||
FROM `tab%(dt)s` | |||
WHERE `tab%(dt)s`.`%(key)s` LIKE '%(txt)s' AND `tab%(dt)s`.docstatus != 2 | |||
WHERE `tab%(dt)s`.`%(key)s` LIKE '%(txt)s' | |||
AND `tab%(dt)s`.docstatus != 2 %(enabled_condition)s | |||
ORDER BY `tab%(dt)s`.`%(key)s` | |||
ASC LIMIT %(start)s, %(len)s """ % { | |||
'fields': fields, | |||
@@ -60,7 +69,8 @@ def make_query(fields, dt, key, txt, start, length): | |||
'key': key, | |||
'txt': txt + '%', | |||
'start': start, | |||
'len': length | |||
'len': length, | |||
'enabled_condition': enabled_condition | |||
} | |||
return query | |||