Pārlūkot izejas kodu

more fixes to perms, floats and default enabled / disabled in search

version-14
Rushabh Mehta pirms 12 gadiem
vecāks
revīzija
a91c919536
6 mainītis faili ar 57 papildinājumiem un 52 dzēšanām
  1. +26
    -34
      core/doctype/module_def/module_def.txt
  2. +1
    -8
      core/doctype/profile/profile_list.js
  3. +12
    -0
      public/js/wn/views/listview.js
  4. +3
    -3
      webnotes/boot.py
  5. +2
    -4
      webnotes/model/utils.py
  6. +13
    -3
      webnotes/widgets/search.py

+ 26
- 34
core/doctype/module_def/module_def.txt Parādīt failu

@@ -1,61 +1,53 @@
[ [
{ {
"owner": "Administrator",
"creation": "2013-01-10 16:34:03",
"docstatus": 0, "docstatus": 0,
"creation": "2012-07-03 13:29:35",
"modified": "2013-01-22 17:40:49",
"modified_by": "Administrator", "modified_by": "Administrator",
"modified": "2012-12-10 19:11:05"
"owner": "Administrator"
}, },
{ {
"autoname": "field:module_name",
"name": "__common__",
"allow_rename": 1, "allow_rename": 1,
"autoname": "field:module_name",
"doctype": "DocType", "doctype": "DocType",
"module": "Core"
"module": "Core",
"name": "__common__"
}, },
{ {
"doctype": "DocField",
"fieldname": "module_name",
"fieldtype": "Data",
"label": "Module Name",
"name": "__common__", "name": "__common__",
"oldfieldname": "module_name",
"oldfieldtype": "Data",
"parent": "Module Def", "parent": "Module Def",
"doctype": "DocField",
"parentfield": "fields",
"parenttype": "DocType", "parenttype": "DocType",
"permlevel": 0,
"parentfield": "fields"
"permlevel": 0
}, },
{ {
"parent": "Module Def",
"read": 1,
"cancel": 1,
"name": "__common__",
"amend": 0, "amend": 0,
"cancel": 1,
"create": 1, "create": 1,
"doctype": "DocPerm", "doctype": "DocPerm",
"submit": 0,
"write": 1,
"name": "__common__",
"parent": "Module Def",
"parentfield": "permissions",
"parenttype": "DocType", "parenttype": "DocType",
"role": "Administrator",
"permlevel": 0, "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" "doctype": "DocPerm"


+ 1
- 8
core/doctype/profile/profile_list.js Parādīt failu

@@ -30,14 +30,7 @@ wn.doclistviews['Profile'] = wn.views.ListView.extend({
columns: [ columns: [
{width: '3%', content: 'check'}, {width: '3%', content: 'check'},
{width: '5%', content: 'avatar'}, {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: '40%', content: 'name'},
{width: '35%', content: 'fullname+tags'}, {width: '35%', content: 'fullname+tags'},
{width: '17%', content:'modified', {width: '17%', content:'modified',


+ 12
- 0
public/js/wn/views/listview.js Parādīt failu

@@ -73,6 +73,18 @@ wn.views.ListView = Class.extend({
<i class="%(docstatus_icon)s" \ <i class="%(docstatus_icon)s" \
title="%(docstatus_title)s"></i></span>', data)); 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') { else if(opts.content=='tags') {
this.add_user_tags(parent, data); this.add_user_tags(parent, data);
} }


+ 3
- 3
webnotes/boot.py Parādīt failu

@@ -81,9 +81,9 @@ def load_country_and_currency(bootinfo, doclist):
if bootinfo.control_panel.country and \ if bootinfo.control_panel.country and \
webnotes.conn.exists("Country", bootinfo.control_panel.country): webnotes.conn.exists("Country", bootinfo.control_panel.country):
doclist += [webnotes.doc("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): def add_allowed_pages(bootinfo):
bootinfo.allowed_pages = [p[0] for p in webnotes.conn.sql("""select distinct parent from `tabPage Role` bootinfo.allowed_pages = [p[0] for p in webnotes.conn.sql("""select distinct parent from `tabPage Role`


+ 2
- 4
webnotes/model/utils.py Parādīt failu

@@ -51,10 +51,8 @@ def compress(doclist):
Compress a doclist before sending it to the client side. (Internally used by the request handler) 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 = {}, [] kl, vl = {}, []
forbidden = ['server_code_compiled'] forbidden = ['server_code_compiled']


+ 13
- 3
webnotes/widgets/search.py Parādīt failu

@@ -50,9 +50,18 @@ def getsearchfields():
webnotes.response['searchfields'] = [['name', 'ID', 'Data', '']] + res webnotes.response['searchfields'] = [['name', 'ID', 'Data', '']] + res


def make_query(fields, dt, key, txt, start, length): 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` 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` ORDER BY `tab%(dt)s`.`%(key)s`
ASC LIMIT %(start)s, %(len)s """ % { ASC LIMIT %(start)s, %(len)s """ % {
'fields': fields, 'fields': fields,
@@ -60,7 +69,8 @@ def make_query(fields, dt, key, txt, start, length):
'key': key, 'key': key,
'txt': txt + '%', 'txt': txt + '%',
'start': start, 'start': start,
'len': length
'len': length,
'enabled_condition': enabled_condition
} }
return query return query




Notiek ielāde…
Atcelt
Saglabāt