def check_groups(dashboard, request):
    """
    Check groups authorization for a dashboard
    """
    if dashboard.public is True:
        return True
    if request.user.is_superuser is True:
        return True
    groups = dashboard.groups.all()
    user_groups = request.user.groups.all()
    for group in groups:
        if group in user_groups:
            return True
    return False
