Merge branch 'master' of github.com:webnotes/wnframework
This commit is contained in:
commit
0f2680cbc4
9 changed files with 46 additions and 33 deletions
|
|
@ -136,7 +136,8 @@ wn.ui.form.AssignTo = Class.extend({
|
|||
msgprint("Email sent to " + assign_to);
|
||||
me.render(r.message);
|
||||
}
|
||||
}
|
||||
},
|
||||
btn: this
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -146,14 +146,17 @@ class Database:
|
|||
return self._cursor.fetchall()
|
||||
|
||||
def explain_query(self, query, values=None):
|
||||
webnotes.errprint("--- query explain ---")
|
||||
if values is None:
|
||||
self._cursor.execute("explain " + query)
|
||||
else:
|
||||
self._cursor.execute("explain " + query, values)
|
||||
import json
|
||||
webnotes.errprint(json.dumps(self.fetch_as_dict(), indent=1))
|
||||
webnotes.errprint("--- query explain end ---")
|
||||
try:
|
||||
webnotes.errprint("--- query explain ---")
|
||||
if values is None:
|
||||
self._cursor.execute("explain " + query)
|
||||
else:
|
||||
self._cursor.execute("explain " + query, values)
|
||||
import json
|
||||
webnotes.errprint(json.dumps(self.fetch_as_dict(), indent=1))
|
||||
webnotes.errprint("--- query explain end ---")
|
||||
except:
|
||||
webnotes.errprint("error in query explain")
|
||||
|
||||
def sql_list(self, query, values=(), debug=False):
|
||||
return [r[0] for r in self.sql(query, values, debug=debug)]
|
||||
|
|
@ -336,10 +339,10 @@ class Database:
|
|||
return []
|
||||
|
||||
if as_dict:
|
||||
return values
|
||||
return values and [values] or []
|
||||
|
||||
if isinstance(fields, list):
|
||||
return map(lambda d: values.get(d), fields)
|
||||
return [map(lambda d: values.get(d), fields)]
|
||||
|
||||
else:
|
||||
r = self.sql("""select field, value
|
||||
|
|
@ -350,10 +353,7 @@ class Database:
|
|||
if as_dict:
|
||||
return r and [webnotes._dict(r)] or []
|
||||
else:
|
||||
if r:
|
||||
return [[i[1] for i in r]]
|
||||
else:
|
||||
return []
|
||||
return r and [[i[1] for i in r]] or []
|
||||
|
||||
def get_values_from_table(self, fields, filters, doctype, as_dict, debug):
|
||||
fl = fields
|
||||
|
|
|
|||
|
|
@ -29,7 +29,8 @@ class DocList(list):
|
|||
def get(self, filters, limit=0):
|
||||
"""pass filters as:
|
||||
{"key": "val", "key": ["!=", "val"],
|
||||
"key": ["in", "val"], "key": ["not in", "val"], "key": "^val"}"""
|
||||
"key": ["in", "val"], "key": ["not in", "val"], "key": "^val",
|
||||
"key" : True (exists), "key": False (does not exist) }"""
|
||||
|
||||
out = []
|
||||
|
||||
|
|
@ -39,7 +40,11 @@ class DocList(list):
|
|||
for f in filters:
|
||||
fval = filters[f]
|
||||
|
||||
if not isinstance(fval, list):
|
||||
if fval==True:
|
||||
fval = ["not None", fval]
|
||||
elif fval==False:
|
||||
fval = ["None", fval]
|
||||
elif not isinstance(fval, list):
|
||||
if isinstance(fval, basestring) and fval.startswith("^"):
|
||||
fval = ["^", fval[1:]]
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -214,9 +214,7 @@ def check_if_doc_is_linked(dt, dn, method="Delete"):
|
|||
link_fields = get_link_fields(dt)
|
||||
link_fields = [[lf['parent'], lf['fieldname']] for lf in link_fields]
|
||||
|
||||
for l in link_fields:
|
||||
link_dt, link_field = l
|
||||
|
||||
for link_dt, link_field in link_fields:
|
||||
item = webnotes.conn.get_value(link_dt, {link_field:dn}, ["name", "parent", "parenttype",
|
||||
"docstatus"], as_dict=True)
|
||||
|
||||
|
|
|
|||
|
|
@ -825,6 +825,8 @@ operator_map = {
|
|||
"<": lambda (a, b): operator.lt(a, b),
|
||||
">=": lambda (a, b): operator.ge(a, b),
|
||||
"<=": lambda (a, b): operator.le(a, b),
|
||||
"not None": lambda (a, b): a and True or False,
|
||||
"None": lambda (a, b): (not a) and True or False
|
||||
}
|
||||
|
||||
def compare(val1, condition, val2):
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes.utils import extract_email_id, convert_utc_to_user_timezone
|
||||
|
||||
class IncomingMail:
|
||||
|
|
@ -31,7 +32,6 @@ class IncomingMail:
|
|||
import email
|
||||
import email.utils
|
||||
import datetime
|
||||
import time
|
||||
|
||||
self.mail = email.message_from_string(content)
|
||||
|
||||
|
|
|
|||
|
|
@ -52,14 +52,19 @@ def execute():
|
|||
|
||||
out = []
|
||||
|
||||
# if first task of the day execute daily tasks
|
||||
nowtime = webnotes.utils.now_datetime()
|
||||
last = webnotes.conn.get_global('scheduler_last_event')
|
||||
|
||||
# set scheduler last event
|
||||
webnotes.conn.begin()
|
||||
webnotes.conn.set_global('scheduler_last_event', nowtime.strftime(format))
|
||||
webnotes.conn.commit()
|
||||
|
||||
if last:
|
||||
last = datetime.strptime(last, format)
|
||||
|
||||
if nowtime.day != last.day:
|
||||
|
||||
# if first task of the day execute daily tasks
|
||||
out.append('daily:' + trigger('execute_daily'))
|
||||
|
||||
if nowtime.month != last.month:
|
||||
|
|
@ -73,10 +78,6 @@ def execute():
|
|||
|
||||
out.append('all:' + trigger('execute_all'))
|
||||
|
||||
webnotes.conn.begin()
|
||||
webnotes.conn.set_global('scheduler_last_event', nowtime.strftime(format))
|
||||
webnotes.conn.commit()
|
||||
|
||||
return '\n'.join(out)
|
||||
|
||||
def trigger(method):
|
||||
|
|
@ -90,12 +91,16 @@ def trigger(method):
|
|||
webnotes.conn.commit()
|
||||
return 'ok'
|
||||
|
||||
except Exception, e:
|
||||
except Exception:
|
||||
return log(method)
|
||||
|
||||
def log(method):
|
||||
"""log error in patch_log"""
|
||||
import webnotes
|
||||
|
||||
if not (webnotes.conn and webnotes.conn._conn):
|
||||
webnotes.connect()
|
||||
|
||||
webnotes.conn.rollback()
|
||||
traceback = webnotes.getTraceback()
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ def get_html(page_name):
|
|||
|
||||
# load from cache, if auto cache clear is falsy
|
||||
if not (hasattr(conf, 'auto_cache_clear') and conf.auto_cache_clear or 0):
|
||||
if not get_page_settings().get("page_name", {}).get("no_cache", None):
|
||||
if not get_page_settings().get(page_name, {}).get("no_cache"):
|
||||
html = webnotes.cache().get_value("page:" + page_name)
|
||||
from_cache = True
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ def add(args=None):
|
|||
|
||||
# notify
|
||||
if not args.get("no_notification"):
|
||||
notify_assignment(d.assigned_by, d.owner, d.reference_type, d.reference_name, action='ASSIGN', notify=args.get('notify'))
|
||||
notify_assignment(d.assigned_by, d.owner, d.reference_type, d.reference_name, action='ASSIGN', description=args.get("description"), notify=args.get('notify'))
|
||||
|
||||
# update feeed
|
||||
try:
|
||||
|
|
@ -106,7 +106,8 @@ def clear(doctype, name):
|
|||
where reference_type=%(doctype)s and reference_name=%(name)s""", locals()):
|
||||
remove(doctype, name, assign_to)
|
||||
|
||||
def notify_assignment(assigned_by, owner, doc_type, doc_name, action='CLOSE', notify=0):
|
||||
def notify_assignment(assigned_by, owner, doc_type, doc_name, action='CLOSE',
|
||||
description=None, notify=0):
|
||||
"""
|
||||
Notify assignee that there is a change in assignment
|
||||
"""
|
||||
|
|
@ -143,9 +144,10 @@ def notify_assignment(assigned_by, owner, doc_type, doc_name, action='CLOSE', no
|
|||
else:
|
||||
arg = {
|
||||
'contact': owner,
|
||||
'txt': "A new task, %s, has been assigned to you by %s." \
|
||||
'txt': "A new task, %s, has been assigned to you by %s. %s" \
|
||||
% (assignment,
|
||||
user_info.get(webnotes.session.get('user'), {}).get('fullname')),
|
||||
user_info.get(webnotes.session.get('user'), {}).get('fullname'),
|
||||
description and ("<p>Description: " + description + "</p>") or ""),
|
||||
'notify': notify
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue