def _is_removing_self_admin_role(self, request, project_id, user_id, available_roles, current_role_ids):
    is_current_user = (user_id == request.user.id)
    is_current_project = (project_id == request.user.tenant_id)
    _admin_roles = utils.get_admin_roles()
    available_admin_role_ids = [role.id for role in available_roles if (role.name.lower() in _admin_roles)]
    admin_roles = [role for role in current_role_ids if (role in available_admin_role_ids)]
    if admin_roles:
        removing_admin = any([(role in current_role_ids) for role in admin_roles])
    else:
        removing_admin = False
    if (is_current_user and is_current_project and removing_admin):
        msg = _('You cannot revoke your administrative privileges from the project you are currently logged into. Please switch to another project with administrative privileges or remove the administrative role manually via the CLI.')
        messages.warning(request, msg)
        return True
    else:
        return False
def _is_removing_self_admin_role(self, request, project_id, user_id, available_roles, current_role_ids):
    is_current_user = (user_id == request.user.id)
    is_current_project = (project_id == request.user.tenant_id)
    _admin_roles = utils.get_admin_roles()
    available_admin_role_ids = [role.id for role in available_roles if (role.name.lower() in _admin_roles)]
    admin_roles = [role for role in current_role_ids if (role in available_admin_role_ids)]
    if admin_roles:
        removing_admin = any([(role in current_role_ids) for role in admin_roles])
    else:
        removing_admin = False
    if (is_current_user and is_current_project and removing_admin):
        msg = _('You cannot revoke your administrative privileges from the project you are currently logged into. Please switch to another project with administrative privileges or remove the administrative role manually via the CLI.')
        messages.warning(request, msg)
        return True
    else:
        return False