Changeset - f9801165dc97
[Not reviewed]
stable
0 1 0
Thomas De Schampheleire - 6 years ago 2019-11-30 19:55:45
thomas.de_schampheleire@nokia.com
admin: fix 'Settings > Visual' form validation after commit 574218777086

Commit 574218777086 introduced a setting for 'SSH Clone URL' in 'Admin >
Settings > Visual' and placed it under a check 'if c.ssh_enabled', which
means that the corresponding form field is not present when SSH is not
enabled.
In this case, when trying to save the form (changing any or none setting),
form validation reports an error 'Missing value' without much detail. At the
top of the HTML document, even before the opening HTML tag, we can see:

<!-- for: clone_ssh_tmpl -->
<span class="error-message">Missing value</span><br />


Fix this problem by adding a hidden form field for clone_ssh_tmpl, with the
current value from the database, in case SSH is not enabled.
1 file changed with 2 insertions and 0 deletions:
0 comments (0 inline, 0 general)
kallithea/templates/admin/settings/settings_visual.html
Show inline comments
 
${h.form(url('admin_settings_visual'), method='post')}
 
    <div class="form">
 
            <div class="form-group">
 
                <label class="control-label">${_('General')}:</label>
 
                <div>
 
                    <div class="checkbox">
 
                        <label>
 
                            ${h.checkbox('repository_fields','True')}
 
                            ${_('Use repository extra fields')}
 
                        </label>
 
                    </div>
 
                    <span class="help-block">${_('Allows storing additional customized fields per repository.')}</span>
 

	
 
                    <div class="checkbox">
 
                        <label>
 
                            ${h.checkbox('show_version','True')}
 
                            ${_('Show Kallithea version')}
 
                        </label>
 
                    </div>
 
                    <span class="help-block">${_('Shows or hides a version number of Kallithea displayed in the footer.')}</span>
 

	
 
                    <div class="checkbox">
 
                        <label>
 
                            ${h.checkbox('use_gravatar','True')}
 
                            ${_('Show user Gravatars')}
 
                        </label>
 
                    </div>
 
                    ${h.text('gravatar_url', size=80, class_='form-control')}
 
                    <span class="help-block">${_('''Gravatar URL allows you to use another avatar server application.
 
                                                        The following variables of the URL will be replaced accordingly.
 
                                                        {scheme}    'http' or 'https' sent from running Kallithea server,
 
                                                        {email}     user email,
 
                                                        {md5email}  md5 hash of the user email (like at gravatar.com),
 
                                                        {size}      size of the image that is expected from the server application,
 
                                                        {netloc}    network location/server host of running Kallithea server''')}</span>
 
                </div>
 
            </div>
 

	
 
            <div class="form-group">
 
                <label class="control-label">${_('HTTP Clone URL')}:</label>
 
                <div>
 
                    ${h.text('clone_uri_tmpl', size=80, class_='form-control')}
 
                    <span class="help-block">${_('''Schema of clone URL construction eg. '{scheme}://{user}@{netloc}/{repo}'.
 
                                                    The following variables are available:
 
                                                    {scheme} 'http' or 'https' sent from running Kallithea server,
 
                                                    {user}   current user username,
 
                                                    {netloc} network location/server host of running Kallithea server,
 
                                                    {repo}   full repository name,
 
                                                    {repoid} ID of repository, can be used to construct clone-by-id,
 
                                                    {system_user}  name of the Kallithea system user,
 
                                                    {hostname}  server hostname
 
                                                    ''')}
 
                    </span>
 
                </div>
 
                %if c.ssh_enabled:
 
                <label class="control-label">${_('SSH Clone URL')}:</label>
 
                <div>
 
                    ${h.text('clone_ssh_tmpl', size=80, class_='form-control')}
 
                    <span class="help-block">${_('''Schema for constructing SSH clone URL, eg. 'ssh://{system_user}@{hostname}/{repo}'.''')}</span>
 
                </div>
 
                %else:
 
                ${h.hidden('clone_ssh_tmpl', size=80, class_='form-control')}
 
                %endif
 
            </div>
 

	
 
            <div class="form-group">
 
                <label class="control-label" for="dashboard_items">${_('Repository page size')}:</label>
 
                <div>
 
                    ${h.text('dashboard_items',size=5,class_='form-control')}
 
                    <span class="help-block">${_('Number of items displayed in the repository pages before pagination is shown.')}</span>
 
                </div>
 
            </div>
 

	
 
            <div class="form-group">
 
                <label class="control-label" for="admin_grid_items">${_('Admin page size')}:</label>
 
                <div>
 
                    ${h.text('admin_grid_items',size=5,class_='form-control')}
 
                    <span class="help-block">${_('Number of items displayed in the admin pages grids before pagination is shown.')}</span>
 
                </div>
 
            </div>
 

	
 
            <div class="form-group">
 
                <label class="control-label">${_('Icons')}:</label>
 
                <div>
 
                    <div class="checkbox">
 
                        <label>
 
                            ${h.checkbox('show_public_icon','True')}
 
                            ${_('Show public repository icon on repositories')}
 
                        </label>
 
                    </div>
 
                    <div class="checkbox">
 
                        <label>
 
                            ${h.checkbox('show_private_icon','True')}
 
                            ${_('Show private repository icon on repositories')}
 
                        </label>
 
                    </div>
 
                    <span class="help-block">${_('Show public/private icons next to repository names.')}</span>
 
                 </div>
 
            </div>
 

	
 
            <div class="form-group">
 
                <label class="control-label" for="stylify_metalabels">${_('Meta Tagging')}:</label>
 
                <div>
 
                    <div class="checkbox">
 
                        <label>
 
                            ${h.checkbox('stylify_metalabels','True')}
 
                            ${_('Parses meta tags from the repository description field and turns them into colored tags.')}
 
                        </label>
 
                    </div>
 
                    <div class="help-block">
 
                        ${_('Stylify recognised meta tags:')}
 
                        <ul class="list-unstyled"> <!-- Fix style here -->
 
                            <li>[featured] <span class="label label-meta" data-tag="featured">featured</span></li>
 
                            <li>[stale] <span class="label label-meta" data-tag="stale">stale</span></li>
 
                            <li>[dead] <span class="label label-meta" data-tag="dead">dead</span></li>
 
                            <li>[lang =&gt; lang] <span class="label label-meta" data-tag="lang">lang</span></li>
 
                            <li>[license =&gt; License] <span class="label label-meta" data-tag="license"><a href="http://www.opensource.org/licenses/License">License</a></span></li>
 
                            <li>[requires =&gt; Repo] <span class="label label-meta" data-tag="requires">requires =&gt; <a href="#">Repo</a></span></li>
 
                            <li>[recommends =&gt; Repo] <span class="label label-meta" data-tag="recommends">recommends =&gt; <a href="#">Repo</a></span></li>
 
                            <li>[see =&gt; URI] <span class="label label-meta" data-tag="see">see =&gt; <a href="#">URI</a> </span></li>
 
                        </ul>
 
                    </div>
 
                 </div>
 
            </div>
 

	
 
            <div class="form-group">
 
                <div class="buttons">
 
                    ${h.submit('save',_('Save Settings'),class_="btn btn-default")}
 
                    ${h.reset('reset',_('Reset'),class_="btn btn-default")}
 
                </div>
 
            </div>
 
    </div>
 
${h.end_form()}
0 comments (0 inline, 0 general)