Merge pull request #777 from nabinhait/hotfix

Multiple small fixes
This commit is contained in:
Pratik Vyas 2014-08-18 16:49:02 +05:30
commit 0921d2be21
4 changed files with 20 additions and 16 deletions

View file

@ -235,10 +235,13 @@ def validate_fields(fields):
if fold_exists:
frappe.throw(_("There can be only one Fold in a form"))
fold_exists = True
nxt = fields[i+1]
if nxt.fieldtype != "Section Break" \
or (nxt.fieldtype=="Section Break" and not nxt.label):
frappe.throw(_("Fold must come before a labelled Section Break"))
if i < len(fields)-1:
nxt = fields[i+1]
if nxt.fieldtype != "Section Break" \
or (nxt.fieldtype=="Section Break" and not nxt.label):
frappe.throw(_("Fold must come before a labelled Section Break"))
else:
frappe.throw(_("Fold can not be at the end of the form"))
for d in fields:
if not d.permlevel: d.permlevel = 0

View file

@ -1 +0,0 @@
__("Test") // for test case

View file

@ -9,28 +9,28 @@ from frappe.utils import getdate
def execute(filters=None):
priority_map = {"High": 3, "Medium": 2, "Low": 1}
todo_list = runreport(doctype="ToDo", fields=["name", "date", "description",
"priority", "reference_type", "reference_name", "assigned_by", "owner"],
filters=[["ToDo", "checked", "!=", 1]])
todo_list.sort(key=lambda todo: (priority_map.get(todo.priority, 0),
"priority", "reference_type", "reference_name", "assigned_by", "owner"],
filters=[["ToDo", "status", "=", "Open"]])
todo_list.sort(key=lambda todo: (priority_map.get(todo.priority, 0),
todo.date and getdate(todo.date) or getdate("1900-01-01")), reverse=True)
columns = [_("ID")+":Link/ToDo:90", _("Priority")+"::60", _("Date")+ ":Date",
_("Description")+"::150", _("Assigned To/Owner") + ":Data:120",
columns = [_("ID")+":Link/ToDo:90", _("Priority")+"::60", _("Date")+ ":Date",
_("Description")+"::150", _("Assigned To/Owner") + ":Data:120",
_("Assigned By")+":Data:120", _("Reference")+"::200"]
result = []
for todo in todo_list:
if todo.owner==frappe.session.user or todo.assigned_by==frappe.session.user:
if todo.reference_type:
todo.reference = """<a href="#Form/%s/%s">%s: %s</a>""" % (todo.reference_type,
todo.reference = """<a href="#Form/%s/%s">%s: %s</a>""" % (todo.reference_type,
todo.reference_name, todo.reference_type, todo.reference_name)
else:
todo.reference = None
result.append([todo.name, todo.priority, todo.date, todo.description,
todo.owner, todo.assigned_by, todo.reference])
return columns, result

View file

@ -192,6 +192,8 @@ def remove_file(fid, attached_to_doctype=None, attached_to_name=None):
if attached_to_doctype and attached_to_name:
doc = frappe.get_doc(attached_to_doctype, attached_to_name)
ignore_permissions = doc.has_permission("write") or False
if not file_name:
file_name = frappe.db.get_value("File Data", fid, "file_name")
comment = doc.add_comment("Attachment Removed", _("Removed {0}").format(file_name))
frappe.delete_doc("File Data", fid, ignore_permissions=ignore_permissions)