(domain, couch_user, allow_admin_role)
return sorted([
        (role.get_qualified_id(), role.name or _('(No Name)'))
        for role in roles
    ], key=lambda c: c[1].lower())
:param domain: roles for domain
    :param couch_user: user accessing the roles
    :param allow_admin_role: to include admin role, in case user is admin
:param domain: roles for domain
    :param couch_user: user accessing the roles
    :param allow_admin_role: to include admin role, in case user is admin
: param domain : roles for domain : param couch_user : user accessing the roles : param allow_admin_role : to include admin role in case user is admin
def get_editable_role_choices(domain, couch_user, allow_admin_role):
    """
    :param domain: roles for domain
    :param couch_user: user accessing the roles
    :param allow_admin_role: to include admin role, in case user is admin
    """
    roles = UserRole.objects.get_by_domain(domain)
    if not couch_user.is_domain_admin(domain):
        try:
            user_role = couch_user.get_role(domain)
        except DomainMembershipError:
            user_role = None
        user_role_id = user_role.get_id if user_role else None
        roles = [
            role for role in roles
            if role.accessible_by_non_admin_role(user_role_id)
        ]
    elif allow_admin_role:
        roles = [StaticRole.domain_admin(domain)] + roles
    return sorted([
        (role.get_qualified_id(), role.name or _('(No Name)'))
        for role in roles
    ], key=lambda c: c[1].lower())
def get_editable_role_choices ( domain , couch_user , allow_admin_role ) : roles = UserRole . objects . get_by_domain ( domain ) if not couch_user . is_domain_admin ( domain ) : try : user_role = couch_user . get_role ( domain ) except DomainMembershipError : user_role = None user_role_id = user_role . get_id if user_role else None roles = [ role for role in roles if role . accessible_by_non_admin_role ( user_role_id ) ] elif allow_admin_role : roles = [ StaticRole . domain_admin ( domain ) ] + roles return sorted ( [ ( role . get_qualified_id ( ) , role . name or _ ( '(No Name)' ) ) for role in roles ] , key = lambda c : c [ 1 ] . lower ( ) )