@@ -202,21 +202,22 @@ def msgprint(msg, small=0, raise_exception=0, as_table=False): | |||||
:param raise_exception: [optional] Raise given exception and show message. | :param raise_exception: [optional] Raise given exception and show message. | ||||
:param as_table: [optional] If `msg` is a list of lists, render as HTML table. | :param as_table: [optional] If `msg` is a list of lists, render as HTML table. | ||||
""" | """ | ||||
from utils import cstr, encode | |||||
def _raise_exception(): | def _raise_exception(): | ||||
if raise_exception: | if raise_exception: | ||||
if flags.rollback_on_exception: | if flags.rollback_on_exception: | ||||
db.rollback() | db.rollback() | ||||
import inspect | import inspect | ||||
if inspect.isclass(raise_exception) and issubclass(raise_exception, Exception): | if inspect.isclass(raise_exception) and issubclass(raise_exception, Exception): | ||||
raise raise_exception, msg | |||||
raise raise_exception, encode(msg) | |||||
else: | else: | ||||
raise ValidationError, msg | |||||
raise ValidationError, encode(msg) | |||||
if flags.mute_messages: | if flags.mute_messages: | ||||
_raise_exception() | _raise_exception() | ||||
return | return | ||||
from utils import cstr | |||||
if as_table and type(msg) in (list, tuple): | if as_table and type(msg) in (list, tuple): | ||||
msg = '<table border="1px" style="border-collapse: collapse" cellpadding="2px">' + ''.join(['<tr>'+''.join(['<td>%s</td>' % c for c in r])+'</tr>' for r in msg]) + '</table>' | msg = '<table border="1px" style="border-collapse: collapse" cellpadding="2px">' + ''.join(['<tr>'+''.join(['<td>%s</td>' % c for c in r])+'</tr>' for r in msg]) + '</table>' | ||||
@@ -50,6 +50,7 @@ | |||||
"search_index": 0 | "search_index": 0 | ||||
}, | }, | ||||
{ | { | ||||
"default": "Data", | |||||
"fieldname": "fieldtype", | "fieldname": "fieldtype", | ||||
"fieldtype": "Select", | "fieldtype": "Select", | ||||
"in_filter": 1, | "in_filter": 1, | ||||
@@ -275,7 +276,7 @@ | |||||
], | ], | ||||
"icon": "icon-glass", | "icon": "icon-glass", | ||||
"idx": 1, | "idx": 1, | ||||
"modified": "2015-02-05 05:11:36.425019", | |||||
"modified": "2015-02-25 03:39:23.573928", | |||||
"modified_by": "Administrator", | "modified_by": "Administrator", | ||||
"module": "Custom", | "module": "Custom", | ||||
"name": "Custom Field", | "name": "Custom Field", | ||||
@@ -26,13 +26,20 @@ def get_notifications(): | |||||
if d in notification_count: | if d in notification_count: | ||||
open_count_doctype[d] = notification_count[d] | open_count_doctype[d] = notification_count[d] | ||||
else: | else: | ||||
result = frappe.get_list(d, fields=["count(*)"], | |||||
filters=condition, as_list=True)[0][0] | |||||
try: | |||||
result = frappe.get_list(d, fields=["count(*)"], | |||||
filters=condition, as_list=True)[0][0] | |||||
open_count_doctype[d] = result | |||||
except Exception, e: | |||||
# OperationalError: (1412, 'Table definition has changed, please retry transaction') | |||||
if e.args[0]!=1412: | |||||
raise | |||||
cache.set_value("notification_count:" + frappe.session.user + ":" + d, | |||||
result) | |||||
else: | |||||
open_count_doctype[d] = result | |||||
cache.set_value("notification_count:" + frappe.session.user + ":" + d, | |||||
result) | |||||
for m in config.for_module: | for m in config.for_module: | ||||
if m in notification_count: | if m in notification_count: | ||||
@@ -402,12 +402,12 @@ class DbManager: | |||||
def validate_column_name(n): | def validate_column_name(n): | ||||
n = n.replace(' ','_').strip().lower() | n = n.replace(' ','_').strip().lower() | ||||
if re.search("[\W]", n, re.UNICODE): | |||||
frappe.throw(_("Fieldname {0} cannot contain letters, numbers or spaces").format(n), InvalidColumnName) | |||||
special_characters = re.findall("[\W]", n, re.UNICODE) | |||||
if special_characters: | |||||
special_characters = ", ".join('"{0}"'.format(c) for c in special_characters) | |||||
frappe.throw(_("Fieldname {0} cannot have special characters like {1}").format(cstr(n), special_characters), InvalidColumnName) | |||||
return n | return n | ||||
def remove_all_foreign_keys(): | def remove_all_foreign_keys(): | ||||
frappe.db.sql("set foreign_key_checks = 0") | frappe.db.sql("set foreign_key_checks = 0") | ||||
frappe.db.commit() | frappe.db.commit() | ||||