added conditions in todo

This commit is contained in:
Rushabh Mehta 2014-01-23 16:39:11 +05:30
parent 563e70727e
commit c4ef07662d
3 changed files with 32 additions and 15 deletions

View file

@ -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

View file

@ -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

View file

@ -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"""