'Display workflow based on a username and slug. Format can be html, json, or json-download.'

@web.expose
def display_by_username_and_slug(self, trans, username, slug, format='html'):

    session = trans.sa_session
    user = session.query(model.User).filter_by(username=username).first()
    if (not user):
        raise web.httpexceptions.HTTPNotFound()
    stored_workflow = trans.sa_session.query(model.StoredWorkflow).filter_by(user=user, slug=slug, deleted=False).first()
    if (not stored_workflow):
        raise web.httpexceptions.HTTPNotFound()
    encoded_id = trans.security.encode_id(stored_workflow.id)
    if (format == 'html'):
        return self._display(trans, stored_workflow)
    elif (format == 'json'):
        return self.for_direct_import(trans, encoded_id)
    elif (format == 'json-download'):
        return self.export_to_file(trans, encoded_id)
