'Returns true if Has Role is not set or the user is allowed.'

def is_permitted(self):

    from frappe.utils import has_common
    allowed = [d.role for d in frappe.get_all(u'Has    Role', fields=[u'role'], filters={u'parent': self.name})]
    custom_roles = get_custom_allowed_roles(u'page', self.name)
    allowed.extend(custom_roles)
    if (not allowed):
        return True
    roles = frappe.get_roles()
    if has_common(roles, allowed):
        return True
