scheduler log now a standard doctype
This commit is contained in:
parent
8f71135af0
commit
870cbdc680
5 changed files with 72 additions and 4 deletions
|
|
@ -226,7 +226,7 @@ def validate_permissions(permissions, for_remove=False):
|
|||
issubmittable = webnotes.conn.get_value("DocType", doctype, "is_submittable")
|
||||
|
||||
def get_txt(d):
|
||||
return "For %s (level %s) in %s:" % (d.role, d.permlevel, d.parent)
|
||||
return "For %s (level %s) in %s row %s:" % (d.role, d.permlevel, d.parent, d.idx)
|
||||
|
||||
def check_atleast_one_set(d):
|
||||
if not d.read and not d.write and not d.submit and not d.cancel and not d.create:
|
||||
|
|
@ -245,7 +245,7 @@ def validate_permissions(permissions, for_remove=False):
|
|||
raise_exception=True)
|
||||
|
||||
def check_level_zero_is_set(d):
|
||||
if d.permlevel > 0 and d.role != 'All':
|
||||
if cint(d.permlevel) > 0 and d.role != 'All':
|
||||
if not permissions.get({"role": d.role, "permlevel": 0}):
|
||||
webnotes.msgprint(get_txt(d) + " Higher level permissions are meaningless if level 0 permission is not set.",
|
||||
raise_exception=True)
|
||||
|
|
|
|||
0
core/doctype/scheduler_log/__init__.py
Normal file
0
core/doctype/scheduler_log/__init__.py
Normal file
8
core/doctype/scheduler_log/scheduler_log.py
Normal file
8
core/doctype/scheduler_log/scheduler_log.py
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
58
core/doctype/scheduler_log/scheduler_log.txt
Normal file
58
core/doctype/scheduler_log/scheduler_log.txt
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
[
|
||||
{
|
||||
"owner": "Administrator",
|
||||
"docstatus": 0,
|
||||
"creation": "2013-01-15 12:42:11",
|
||||
"modified_by": "Administrator",
|
||||
"modified": "2013-01-15 12:42:31"
|
||||
},
|
||||
{
|
||||
"autoname": "SCHLOG.#####",
|
||||
"description": "Log of Scheduler Errors",
|
||||
"doctype": "DocType",
|
||||
"module": "Core",
|
||||
"document_type": "System",
|
||||
"name": "__common__"
|
||||
},
|
||||
{
|
||||
"name": "__common__",
|
||||
"parent": "Scheduler Log",
|
||||
"doctype": "DocField",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0,
|
||||
"parentfield": "fields"
|
||||
},
|
||||
{
|
||||
"parent": "Scheduler Log",
|
||||
"read": 1,
|
||||
"cancel": 1,
|
||||
"name": "__common__",
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"submit": 0,
|
||||
"write": 1,
|
||||
"parenttype": "DocType",
|
||||
"role": "System Manager",
|
||||
"permlevel": 0,
|
||||
"parentfield": "permissions"
|
||||
},
|
||||
{
|
||||
"name": "Scheduler Log",
|
||||
"doctype": "DocType"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"label": "Method",
|
||||
"fieldname": "method",
|
||||
"fieldtype": "Data"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"label": "Error",
|
||||
"fieldname": "error",
|
||||
"fieldtype": "Text"
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm"
|
||||
}
|
||||
]
|
||||
|
|
@ -101,8 +101,10 @@ def log(method):
|
|||
|
||||
import webnotes.utils
|
||||
webnotes.conn.begin()
|
||||
webnotes.conn.sql("""insert into __SchedulerLog (`timestamp`, method, error)
|
||||
values (%s, %s, %s)""", (webnotes.utils.now_datetime(), method, traceback))
|
||||
d = webnotes.doc("Scheduler Log")
|
||||
d.method = method
|
||||
d.error = traceback
|
||||
d.save()
|
||||
webnotes.conn.commit()
|
||||
|
||||
return traceback
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue