<%inherit file="/instance/settings.html" />
<%namespace name="forms" file="/forms.html"/>
<%namespace name="components" file="/components.html"/>


<%block name="settings_content">
<form name="create_instance" class="well" method="POST">

    ${components.flashmessages()}
    <h2>${c.settings_menu.current['label']}</h2>
    <input type="hidden" name="_method" value="PUT" />
    ${h.field_token()|n}

    ${forms.select(_("Language"), 'locale', c.locales, help=_("The language setting will be overridden by the user's personal setting."), autofocus=True)}

    ${forms.checkbox(_("Enable delegated voting"), 'allow_delegate')}
    ${forms.checkbox(_("Enable milestones"), 'milestones', help=_("Milestones link the online discussions with offline events through a calendar function."))}
    ${forms.checkbox(_("Display category pages"), 'display_category_pages')}
    <div style="padding-left: 2em">
        ${components.hidden_badge_table(c.category_badge_tables, 'category', _(u'categories'))}
    </div>

    <% instance_stylesheets = h.config.get_list('adhocracy.instance_stylesheets') %>
    <% instance_themes = h.config.get_list('adhocracy.instance_themes') %>
    %if c.page_instance.is_authenticated and instance_themes and c.page_instance.key not in instance_stylesheets:
    <fieldset>
        <legend>${_('Themes')}</legend>
        <p class="help-block">${_('You can select one of several themes to customize the appearance of this instance.')}</p>
        <table>
            <tr>
                <td>${forms.radio(_('default'), 'theme', '')}</td>
                <td><img src="${'/static_theme/static' if h.config.get_bool('adhocracy.themed') else ''}/images/theme_preview_default.png" alt="${_('preview')}" class="theme-preview" /></td>
            </tr>
            %for theme in instance_themes:
            <tr>
                <td>${forms.radio(theme, 'theme', theme)}</td>
                <td><img src="${'/static_theme/static' if h.config.get_bool('adhocracy.themed') else ''}/images/theme_preview_${theme}.png" alt="${_('preview')}" class="theme-preview" /></td>
            </td>
            %endfor
        </table>
    </fieldset>
    %endif

    ${components.savebox(h.base_url("/instance/%s" % c.page_instance.key))}

    %if can.instance.delete(c.page_instance):
    <div>
        <a class="button" href="${h.entity_url(c.page_instance, member='ask_delete')}">${_("Delete this instance")}</a>
    </div>
    %endif

</form>
</%block>
