added conditions in todo
This commit is contained in:
parent
563e70727e
commit
c4ef07662d
3 changed files with 32 additions and 15 deletions
|
|
@ -6,4 +6,19 @@ import webnotes
|
|||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
# todo is viewable if either user or assigned_to or System Manager in roles
|
||||
|
||||
def get_permission_query_conditions():
|
||||
if "System Manager" in webnotes.get_roles():
|
||||
return None
|
||||
else:
|
||||
return """(tabToDo.owner = '{user}' or tabToDo.assigned_to = '{user}' or )""".format(user=webnotes.session.user)
|
||||
|
||||
def has_permission(doc):
|
||||
if "System Manager" in webnotes.get_roles():
|
||||
return True
|
||||
else:
|
||||
return doc.owner==webnotes.session.user or doc.assigned_to==webnotes.session.user
|
||||
|
||||
|
|
@ -7,18 +7,6 @@ from webnotes import msgprint, _
|
|||
from webnotes.utils import flt, cint, cstr
|
||||
from webnotes.model.meta import get_field_precision
|
||||
|
||||
error_condition_map = {
|
||||
"=": "!=",
|
||||
"!=": "=",
|
||||
"<": ">=",
|
||||
">": "<=",
|
||||
">=": "<",
|
||||
"<=": ">",
|
||||
"in": _("not in"),
|
||||
"not in": _("in"),
|
||||
"^": _("cannot start with"),
|
||||
}
|
||||
|
||||
class EmptyTableError(webnotes.ValidationError): pass
|
||||
|
||||
class DocListController(object):
|
||||
|
|
@ -37,6 +25,18 @@ class DocListController(object):
|
|||
def validate_value(self, fieldname, condition, val2, doc=None, raise_exception=None):
|
||||
"""check that value of fieldname should be 'condition' val2
|
||||
else throw exception"""
|
||||
error_condition_map = {
|
||||
"=": "!=",
|
||||
"!=": "=",
|
||||
"<": ">=",
|
||||
">": "<=",
|
||||
">=": "<",
|
||||
"<=": ">",
|
||||
"in": _("not in"),
|
||||
"not in": _("in"),
|
||||
"^": _("cannot start with"),
|
||||
}
|
||||
|
||||
if not doc:
|
||||
doc = self.doc
|
||||
|
||||
|
|
|
|||
|
|
@ -265,9 +265,11 @@ def get_permission_query_conditions(doctype):
|
|||
if condition_methods:
|
||||
conditions = []
|
||||
for method in condition_methods:
|
||||
conditions.append(webnotes.get_attr(method)())
|
||||
c = webnotes.get_attr(method)()
|
||||
if c:
|
||||
conditions.append(c)
|
||||
|
||||
return " and ".join(conditions)
|
||||
return " and ".join(conditions) if conditions else None
|
||||
|
||||
def get_tables(doctype, fields):
|
||||
"""extract tables from fields"""
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue