Beispiel #1
0
def get_permissions(doctype=None, role=None):
    frappe.only_for("System Manager")
    if role:
        out = get_all_perms(role)
        if doctype:
            out = [p for p in out if p.parent == doctype]
    else:
        filters = dict(parent=doctype)
        if frappe.session.user != 'Administrator':
            custom_roles = frappe.get_all('Role', filters={'is_custom': 1})
            filters['role'] = ['not in', [row.name for row in custom_roles]]

        out = frappe.get_all('Custom DocPerm',
                             fields='*',
                             filters=filters,
                             order_by="permlevel")
        if not out:
            out = frappe.get_all('DocPerm',
                                 fields='*',
                                 filters=filters,
                                 order_by="permlevel")

    linked_doctypes = {}
    for d in out:
        if not d.parent in linked_doctypes:
            linked_doctypes[d.parent] = get_linked_doctypes(d.parent)
        d.linked_doctypes = linked_doctypes[d.parent]
        meta = frappe.get_meta(d.parent)
        if meta:
            d.is_submittable = meta.is_submittable
            d.in_create = meta.in_create

    return out
Beispiel #2
0
def get_permissions(doctype=None, role=None):
    frappe.only_for(("System Manager", "Local Admin"))
    if role:
        out = get_all_perms(role)
        if doctype:
            out = [p for p in out if p.parent == doctype]
    else:
        out = frappe.get_all('Custom DocPerm',
                             fields='*',
                             filters=dict(parent=doctype),
                             order_by="permlevel")
        if not out:
            out = frappe.get_all('DocPerm',
                                 fields='*',
                                 filters=dict(parent=doctype),
                                 order_by="permlevel")

    linked_doctypes = {}
    for d in out:
        if not d.parent in linked_doctypes:
            linked_doctypes[d.parent] = get_linked_doctypes(d.parent)
        d.linked_doctypes = linked_doctypes[d.parent]
        meta = frappe.get_meta(d.parent)
        if meta:
            d.is_submittable = meta.is_submittable

    return out
def get_permissions(doctype=None, role=None):
	frappe.only_for("System Manager")
	if role:
		out = get_all_perms(role)
		if doctype:
			out = [p for p in out if p.parent == doctype]
	else:
		out = frappe.get_all('Custom DocPerm', fields='*', filters=dict(parent = doctype), order_by="permlevel")
		if not out:
			out = frappe.get_all('DocPerm', fields='*', filters=dict(parent = doctype), order_by="permlevel")

	linked_doctypes = {}
	for d in out:
		if not d.parent in linked_doctypes:
			linked_doctypes[d.parent] = get_linked_doctypes(d.parent)
		d.linked_doctypes = linked_doctypes[d.parent]

	return out
Beispiel #4
0
def get_perm_info(role):
    """get permission info"""
    from frappe.permissions import get_all_perms
    return get_all_perms(role)
Beispiel #5
0
def get_perm_info(role):
	"""get permission info"""
	from frappe.permissions import get_all_perms
	return get_all_perms(role)