'Creates a new visualization or returns a form for creating visualization.'

@web.expose
@web.require_login('create    visualizations')
def create(self, trans, visualization_title='', visualization_slug='', visualization_annotation='', visualization_dbkey='', visualization_type=''):

    visualization_title_err = visualization_slug_err = visualization_annotation_err = ''
    if (trans.request.method == 'POST'):
        rval = self.create_visualization(trans, title=visualization_title, slug=visualization_slug, annotation=visualization_annotation, dbkey=visualization_dbkey, type=visualization_type)
        if isinstance(rval, dict):
            visualization_title_err = rval['title_err']
            visualization_slug_err = rval['slug_err']
        else:
            return trans.response.send_redirect(web.url_for(controller='visualizations', action='list'))
    viz_type_options = [(t, t) for t in self.viz_types]
    return trans.show_form(web.FormBuilder(web.url_for(controller='visualization', action='create'), 'Create    new    visualization', submit_text='Submit').add_text('visualization_title', 'Visualization    title', value=visualization_title, error=visualization_title_err).add_select('visualization_type', 'Type', options=viz_type_options, error=None).add_text('visualization_slug', 'Visualization    identifier', value=visualization_slug, error=visualization_slug_err, help="A    unique    identifier    that    will    be    used    for\n                                                                                                                public    links    to    this    visualization.    A    default    is    generated\n                                                                                                                from    the    visualization    title,    but    can    be    edited.    This    field\n                                                                                                                must    contain    only    lowercase    letters,    numbers,    and\n                                                                                                                the    '-'    character.").add_select('visualization_dbkey', 'Visualization    DbKey/Build', value=visualization_dbkey, options=trans.app.genomes.get_dbkeys(trans, chrom_info=True), error=None).add_text('visualization_annotation', 'Visualization    annotation', value=visualization_annotation, error=visualization_annotation_err, help='A    description    of    the    visualization;    annotation    is    shown    alongside    published    visualizations.'), template='visualization/create.mako')
