'Return query or query results for published visualizations optionally excluding
the user in `exclude_user`.
Set `order_by` to a column or list of columns to change the order
returned. Defaults to `DEFAULT_ORDER_BY`.
Set `query_only` to return just the query for further filtering or
processing.'

def get_published_visualizations(self, trans, exclude_user=None, order_by=None, query_only=False):

    DEFAULT_ORDER_BY = [model.Visualization.title]
    if (not order_by):
        order_by = DEFAULT_ORDER_BY
    if (not isinstance(order_by, list)):
        order_by = [order_by]
    query = trans.sa_session.query(model.Visualization)
    query = query.filter((model.Visualization.published == true()))
    if exclude_user:
        query = query.filter((model.Visualization.user != exclude_user))
    if order_by:
        query = query.order_by(*order_by)
    if query_only:
        return query
    return query.all()
