@@ -2,7 +2,7 @@ | |||||
{ | { | ||||
"creation": "2012-08-02 15:17:28", | "creation": "2012-08-02 15:17:28", | ||||
"docstatus": 0, | "docstatus": 0, | ||||
"modified": "2013-07-05 14:29:33", | |||||
"modified": "2013-08-06 15:36:00", | |||||
"modified_by": "Administrator", | "modified_by": "Administrator", | ||||
"owner": "Administrator" | "owner": "Administrator" | ||||
}, | }, | ||||
@@ -31,7 +31,8 @@ | |||||
"parentfield": "permissions", | "parentfield": "permissions", | ||||
"parenttype": "DocType", | "parenttype": "DocType", | ||||
"permlevel": 0, | "permlevel": 0, | ||||
"read": 1 | |||||
"read": 1, | |||||
"role": "System Manager" | |||||
}, | }, | ||||
{ | { | ||||
"doctype": "DocType", | "doctype": "DocType", | ||||
@@ -68,11 +69,23 @@ | |||||
"label": "Error" | "label": "Error" | ||||
}, | }, | ||||
{ | { | ||||
"doctype": "DocPerm", | |||||
"role": "Administrator" | |||||
"doctype": "DocField", | |||||
"fieldname": "ref_doctype", | |||||
"fieldtype": "Link", | |||||
"label": "Reference DocType", | |||||
"options": "DocType", | |||||
"read_only": 1, | |||||
"reqd": 1 | |||||
}, | }, | ||||
{ | { | ||||
"doctype": "DocPerm", | |||||
"role": "System Manager" | |||||
"doctype": "DocField", | |||||
"fieldname": "ref_docname", | |||||
"fieldtype": "Data", | |||||
"label": "Reference DocName", | |||||
"read_only": 1, | |||||
"reqd": 1 | |||||
}, | |||||
{ | |||||
"doctype": "DocPerm" | |||||
} | } | ||||
] | ] |
@@ -60,35 +60,45 @@ wn.ui.form.Dashboard = Class.extend({ | |||||
}); | }); | ||||
}, | }, | ||||
add_progress: function(title, percent) { | add_progress: function(title, percent) { | ||||
var width = cint(percent) < 1 ? 1 : percent; | |||||
var progress_chart = this.make_progress_chart(title); | |||||
var progress_class = ""; | |||||
if(width < 10) | |||||
progress_class = "progress-bar-danger"; | |||||
if(width > 99.9) | |||||
progress_class = "progress-bar-success"; | |||||
if(!$.isArray(percent)) { | |||||
var width = cint(percent) < 1 ? 1 : percent; | |||||
var progress_class = ""; | |||||
if(width < 10) | |||||
progress_class = "progress-bar-danger"; | |||||
if(width > 99.9) | |||||
progress_class = "progress-bar-success"; | |||||
percent = [{ | |||||
title: title, | |||||
width: width, | |||||
progress_class: progress_class | |||||
}]; | |||||
} | |||||
var progress = $('<div class="progress"></div>').appendTo(progress_chart); | |||||
$.each(percent, function(i, opts) { | |||||
$(repl('<div class="progress-bar %(progress_class)s" style="width: %(width)s%" \ | |||||
title="%(title)s"></div>', opts)).appendTo(progress); | |||||
}); | |||||
this.wrapper.toggle(true); | |||||
}, | |||||
make_progress_chart: function(title) { | |||||
var progress_area = this.body.find(".progress-area"); | var progress_area = this.body.find(".progress-area"); | ||||
if(!progress_area.length) { | if(!progress_area.length) { | ||||
progress_area = $('<div class="progress-area">').appendTo(this.body); | progress_area = $('<div class="progress-area">').appendTo(this.body); | ||||
} | } | ||||
$(repl('<div class="progress-chart">\ | |||||
<h5>%(title)s</h5>\ | |||||
<div class="progress">\ | |||||
<div class="progress-bar %(progress_class)s" style="width: %(width)s%"></div>\ | |||||
</div>\ | |||||
</div>', { | |||||
title:title, | |||||
width: width, | |||||
progress_class: progress_class | |||||
})).appendTo(progress_area); | |||||
var progress_chart = $('<div class="progress-chart"><h5>'+title+'</h5></div>') | |||||
.appendTo(progress_area); | |||||
var n_charts = progress_area.find(".progress-chart").length, | var n_charts = progress_area.find(".progress-chart").length, | ||||
cols = Math.floor(12 / n_charts); | cols = Math.floor(12 / n_charts); | ||||
progress_area.find(".progress-chart") | progress_area.find(".progress-chart") | ||||
.removeClass().addClass("progress-chart col col-lg-" + cols); | .removeClass().addClass("progress-chart col col-lg-" + cols); | ||||
this.wrapper.toggle(true); | |||||
return progress_chart; | |||||
} | } | ||||
}) | |||||
}); |
@@ -66,7 +66,7 @@ wn.number_format_info = { | |||||
window.format_number = function(v, format, decimals){ | window.format_number = function(v, format, decimals){ | ||||
if (!format) { | if (!format) { | ||||
format = get_number_format(); | format = get_number_format(); | ||||
if(decimals == null) decimals = cint(wn.defaults.get_default("float_precision")) || 6; | |||||
if(decimals == null) decimals = cint(wn.defaults.get_default("float_precision")) || 3; | |||||
} | } | ||||
info = get_number_format_info(format); | info = get_number_format_info(format); | ||||
@@ -139,7 +139,7 @@ $.extend(wn.meta, { | |||||
}, | }, | ||||
get_field_precision: function(df, doc) { | get_field_precision: function(df, doc) { | ||||
var precision = wn.defaults.get_default("float_precision") || 6; | |||||
var precision = wn.defaults.get_default("float_precision") || 3; | |||||
if(df && df.fieldtype === "Currency") { | if(df && df.fieldtype === "Currency") { | ||||
var currency = this.get_field_currency(df, doc); | var currency = this.get_field_currency(df, doc); | ||||
var number_format = get_number_format(currency); | var number_format = get_number_format(currency); | ||||
@@ -329,7 +329,7 @@ wn.views.GridReport = Class.extend({ | |||||
var me = this; | var me = this; | ||||
$.each(this.columns, function(i, col) { | $.each(this.columns, function(i, col) { | ||||
if (col.formatter==me.currency_formatter) { | if (col.formatter==me.currency_formatter) { | ||||
item[col.id] = flt(item[col.id], wn.defaults.get_default("float_precision") || 6); | |||||
item[col.id] = flt(item[col.id], wn.defaults.get_default("float_precision") || 3); | |||||
} | } | ||||
}); | }); | ||||
}, | }, | ||||
@@ -91,7 +91,7 @@ class DocListController(object): | |||||
if not hasattr(self, "_precision"): | if not hasattr(self, "_precision"): | ||||
self._precision = webnotes._dict({ | self._precision = webnotes._dict({ | ||||
"default": cint(webnotes.conn.get_default("float_precision")) or 6, | |||||
"default": cint(webnotes.conn.get_default("float_precision")) or 3, | |||||
"options": {} | "options": {} | ||||
}) | }) | ||||
@@ -65,9 +65,9 @@ class DocList(list): | |||||
def get_item_value(self, d, name): | def get_item_value(self, d, name): | ||||
if isinstance(d, dict): | if isinstance(d, dict): | ||||
return d[name] | |||||
return d.get(name) | |||||
else: | else: | ||||
return d.fields[name] | |||||
return d.fields.get(name) | |||||
def filter_valid_fields(self): | def filter_valid_fields(self): | ||||
import webnotes.model | import webnotes.model | ||||
@@ -96,6 +96,6 @@ def get_field_precision(df, doc): | |||||
decimal_str, comma_str, precision = get_number_format_info(number_format) | decimal_str, comma_str, precision = get_number_format_info(number_format) | ||||
if df.fieldtype == "Float": | if df.fieldtype == "Float": | ||||
precision = cint(webnotes.conn.get_default("float_precision")) or 6 | |||||
precision = cint(webnotes.conn.get_default("float_precision")) or 3 | |||||
return precision | return precision |
@@ -37,17 +37,8 @@ class Profile: | |||||
self.doctype_map = {} | self.doctype_map = {} | ||||
for r in webnotes.conn.sql("""select name, in_create, issingle, istable, | for r in webnotes.conn.sql("""select name, in_create, issingle, istable, | ||||
read_only, module from tabDocType""", as_dict=1): | read_only, module from tabDocType""", as_dict=1): | ||||
r['child_tables'] = [] | |||||
self.doctype_map[r['name']] = r | self.doctype_map[r['name']] = r | ||||
for r in webnotes.conn.sql("""select parent, options from tabDocField | |||||
where fieldtype="Table" | |||||
and parent not like "old_parent:%%" | |||||
and ifnull(docstatus,0)=0 | |||||
"""): | |||||
if r[0] in self.doctype_map: | |||||
self.doctype_map[r[0]]['child_tables'].append(r[1]) | |||||
def build_perm_map(self): | def build_perm_map(self): | ||||
"""build map of permissions at level 0""" | """build map of permissions at level 0""" | ||||
@@ -100,7 +91,6 @@ class Profile: | |||||
if (p.get('read') or p.get('write') or p.get('create')): | if (p.get('read') or p.get('write') or p.get('create')): | ||||
if p.get('report'): | if p.get('report'): | ||||
self.can_get_report.append(dt) | self.can_get_report.append(dt) | ||||
self.can_get_report += dtp['child_tables'] | |||||
if not dtp.get('istable'): | if not dtp.get('istable'): | ||||
if not dtp.get('issingle') and not dtp.get('read_only'): | if not dtp.get('issingle') and not dtp.get('read_only'): | ||||
self.can_search.append(dt) | self.can_search.append(dt) | ||||
@@ -9,7 +9,7 @@ from webnotes.utils import cint | |||||
class BulkLimitCrossedError(webnotes.ValidationError): pass | class BulkLimitCrossedError(webnotes.ValidationError): pass | ||||
def send(recipients=None, sender=None, doctype='Profile', email_field='email', | def send(recipients=None, sender=None, doctype='Profile', email_field='email', | ||||
subject='[No Subject]', message='[No Content]'): | |||||
subject='[No Subject]', message='[No Content]', ref_doctype=None, ref_docname=None): | |||||
"""send bulk mail if not unsubscribed and within conf.bulk_mail_limit""" | """send bulk mail if not unsubscribed and within conf.bulk_mail_limit""" | ||||
import webnotes | import webnotes | ||||
@@ -69,9 +69,9 @@ def send(recipients=None, sender=None, doctype='Profile', email_field='email', | |||||
if not is_unsubscribed(doc): | if not is_unsubscribed(doc): | ||||
# add to queue | # add to queue | ||||
add(r, sender, subject, update_message(doc), text_content) | |||||
add(r, sender, subject, update_message(doc), text_content, ref_doctype, ref_docname) | |||||
def add(email, sender, subject, message, text_content = None): | |||||
def add(email, sender, subject, message, text_content=None, ref_doctype=None, ref_docname=None): | |||||
"""add to bulk mail queue""" | """add to bulk mail queue""" | ||||
from webnotes.utils.email_lib.smtp import get_email | from webnotes.utils.email_lib.smtp import get_email | ||||
@@ -86,6 +86,8 @@ def add(email, sender, subject, message, text_content = None): | |||||
return | return | ||||
e.status = 'Not Sent' | e.status = 'Not Sent' | ||||
e.ref_doctype = ref_doctype | |||||
e.ref_docname = ref_docname | |||||
e.save() | e.save() | ||||
@webnotes.whitelist(allow_guest=True) | @webnotes.whitelist(allow_guest=True) | ||||
@@ -108,12 +110,16 @@ def unsubscribe(): | |||||
def flush(from_test=False): | def flush(from_test=False): | ||||
"""flush email queue, every time: called from scheduler""" | """flush email queue, every time: called from scheduler""" | ||||
import webnotes | |||||
import webnotes, conf | |||||
from webnotes.utils.email_lib.smtp import SMTPServer, get_email | from webnotes.utils.email_lib.smtp import SMTPServer, get_email | ||||
smptserver = SMTPServer() | smptserver = SMTPServer() | ||||
auto_commit = not from_test | auto_commit = not from_test | ||||
if webnotes.mute_emails or getattr(conf, "mute_emails", False): | |||||
webnotes.msgprint("Emails are muted") | |||||
from_test = True | |||||
for i in xrange(500): | for i in xrange(500): | ||||
email = webnotes.conn.sql("""select * from `tabBulk Email` where | email = webnotes.conn.sql("""select * from `tabBulk Email` where | ||||