def filter_by_user(model, user):
    """
    helper function to filter queryset by user or all if superuser
    """
    m = model.objects
    return m.all() if user.is_superuser else m.filter(user=user.id)
