'Return a list of groups from the DB.
:returns: query that will emit all groups
:rtype:   sqlalchemy query'

def list(self, trans, deleted=False):

    is_admin = trans.user_is_admin()
    query = trans.sa_session.query(trans.app.model.Group)
    if is_admin:
        if (deleted is None):
            pass
        elif deleted:
            query = query.filter((trans.app.model.Group.table.c.deleted == true()))
        else:
            query = query.filter((trans.app.model.Group.table.c.deleted == false()))
    else:
        query = query.filter((trans.app.model.Group.table.c.deleted == false()))
    return query
