Changeset - 4cd0709b6d4b
[Not reviewed]
beta
0 6 0
Marcin Kuzminski - 15 years ago 2010-11-15 18:38:54
marcin@python-works.com
fixes #65, Added reset buttons to edit forms
6 files changed with 28 insertions and 8 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/helpers.py
Show inline comments
 
@@ -4,48 +4,59 @@ Consists of functions to typically be us
 
available to Controllers. This module is available to both as 'h'.
 
"""
 
from pygments.formatters import HtmlFormatter
 
from pygments import highlight as code_highlight
 
from pylons import url, app_globals as g
 
from pylons.i18n.translation import _, ungettext
 
from vcs.utils.annotate import annotate_highlight
 
from webhelpers.html import literal, HTML, escape
 
from webhelpers.html.tools import *
 
from webhelpers.html.builder import make_tag
 
from webhelpers.html.tags import auto_discovery_link, checkbox, css_classes, \
 
    end_form, file, form, hidden, image, javascript_link, link_to, link_to_if, \
 
    link_to_unless, ol, required_legend, select, stylesheet_link, submit, text, \
 
    password, textarea, title, ul, xml_declaration, radio
 
from webhelpers.html.tools import auto_link, button_to, highlight, js_obfuscate, \
 
    mail_to, strip_links, strip_tags, tag_re
 
from webhelpers.number import format_byte_size, format_bit_size
 
from webhelpers.pylonslib import Flash as _Flash
 
from webhelpers.pylonslib.secure_form import secure_form
 
from webhelpers.text import chop_at, collapse, convert_accented_entities, \
 
    convert_misc_entities, lchop, plural, rchop, remove_formatting, \
 
    replace_whitespace, urlify, truncate, wrap_paragraphs
 
from webhelpers.date import time_ago_in_words
 

	
 
from webhelpers.html.tags import _set_input_attrs, _set_id_attr, \
 
    convert_boolean_attrs, NotGiven
 

	
 
def _reset(name, value=None, id=NotGiven, type="reset", **attrs):
 
    _set_input_attrs(attrs, type, name, value)
 
    _set_id_attr(attrs, id, name)
 
    convert_boolean_attrs(attrs, ["disabled"])
 
    return HTML.input(**attrs)
 

	
 
reset = _reset
 

	
 
#Custom helpers here :)
 
class _Link(object):
 
    '''
 
    Make a url based on label and url with help of url_for
 
    :param label:name of link    if not defined url is used
 
    :param url: the url for link
 
    '''
 

	
 
    def __call__(self, label='', *url_, **urlargs):
 
        if label is None or '':
 
            label = url
 
        link_fn = link_to(label, url(*url_, **urlargs))
 
        return link_fn
 

	
 
link = _Link()
 

	
 
class _GetError(object):
 

	
 
    def __call__(self, field_name, form_errors):
 
        tmpl = """<span class="error_msg">%s</span>"""
 
        if form_errors and form_errors.has_key(field_name):
 
            return literal(tmpl % form_errors.get(field_name))
 

	
 
get_error = _GetError()
rhodecode/templates/admin/repos/repo_edit.html
Show inline comments
 
@@ -128,49 +128,50 @@
 
                        <tr id="add_perm_input">
 
                            <td>${h.radio('perm_new_user','repository.none')}</td>
 
                            <td>${h.radio('perm_new_user','repository.read')}</td>
 
                            <td>${h.radio('perm_new_user','repository.write')}</td>
 
                            <td>${h.radio('perm_new_user','repository.admin')}</td>
 
                            <td class='ac'>
 
                                <div class="perm_ac" id="perm_ac">
 
                                    ${h.text('perm_new_user_name',class_='yui-ac-input')}
 
                                    <div id="perm_container"></div>
 
                                </div>
 
                            </td>
 
                            <td></td>
 
                        </tr>
 
                        <tr>
 
                            <td colspan="6">
 
                                <span id="add_perm" class="add_icon" style="cursor: pointer;">
 
                                ${_('Add another user')}
 
                                </span>
 
                            </td>
 
                        </tr>
 
                    </table>             
 
             </div>
 
             
 
            <div class="buttons">
 
              ${h.submit('save','save',class_="ui-button ui-widget ui-state-default ui-corner-all")}
 
              ${h.submit('save','Save',class_="ui-button ui-widget ui-state-default ui-corner-all")}
 
              ${h.reset('reset','Reset',class_="ui-button ui-widget ui-state-default ui-corner-all")}
 
            </div>                                                          
 
        </div>
 
    </div>
 
    </div>    
 
    ${h.end_form()}
 
        <script type="text/javascript">
 
            YAHOO.util.Event.onDOMReady(function(){
 
                var D = YAHOO.util.Dom;
 
                if(!D.hasClass('perm_new_user_name','error')){
 
                    D.setStyle('add_perm_input','display','none');
 
                }
 
                YAHOO.util.Event.addListener('add_perm','click',function(){
 
                    D.setStyle('add_perm_input','display','');
 
                    D.setStyle('add_perm','opacity','0.6');
 
                    D.setStyle('add_perm','cursor','default');
 
                });
 
            });
 
        </script>
 
        <script type="text/javascript">    
 
        YAHOO.example.FnMultipleFields = function(){
 
            var myContacts = ${c.users_array|n}
 
            
 
            // Define a custom search function for the DataSource
 
            var matchNames = function(sQuery) {
rhodecode/templates/admin/settings/settings.html
Show inline comments
 
@@ -21,106 +21,107 @@
 
    </div>
 
    <!-- end box / title -->
 
    
 
    <h3>${_('Remap and rescan repositories')}</h3>
 
    ${h.form(url('admin_setting', setting_id='mapping'),method='put')}
 
    <div class="form">
 
        <!-- fields -->
 
        
 
        <div class="fields">
 
			<div class="field">
 
		        <div class="label label-checkbox">
 
		            <label for="destroy">${_('rescan option')}:</label>
 
		        </div>
 
		        <div class="checkboxes">
 
		            <div class="checkbox">
 
		                ${h.checkbox('destroy',True)}
 
		                <label for="checkbox-1">
 
		                <span class="tooltip" tooltip_title="${h.tooltip(_('In case a repository was deleted from filesystem and there are leftovers in the database check this option to scan obsolete data in database and remove it.'))}">
 
		                ${_('destroy old data')}</span> </label>
 
		            </div>
 
		        </div>
 
			</div>
 
                            
 
            <div class="buttons">
 
            ${h.submit('rescan','rescan repositories',class_="ui-button ui-widget ui-state-default ui-corner-all")}
 
            ${h.submit('rescan','Rescan repositories',class_="ui-button ui-widget ui-state-default ui-corner-all")}
 
            </div>                                                          
 
        </div>
 
    </div>  
 
    ${h.end_form()}
 
    
 
    <h3>${_('Whoosh indexing')}</h3>
 
    ${h.form(url('admin_setting', setting_id='whoosh'),method='put')}
 
    <div class="form">
 
        <!-- fields -->
 
        
 
        <div class="fields">
 
            <div class="field">
 
                <div class="label label-checkbox">
 
                    <label for="destroy">${_('index build option')}:</label>
 
                </div>
 
                <div class="checkboxes">
 
                    <div class="checkbox">
 
                        ${h.checkbox('full_index',True)}
 
                        <label for="checkbox-1">${_('build from scratch')}</label>
 
                    </div>
 
                </div>
 
            </div>
 
                            
 
            <div class="buttons">
 
            ${h.submit('reindex','reindex',class_="ui-button ui-widget ui-state-default ui-corner-all")}
 
            ${h.submit('reindex','Reindex',class_="ui-button ui-widget ui-state-default ui-corner-all")}
 
            </div>                                                          
 
        </div>
 
    </div>  
 
    ${h.end_form()}
 
         
 
    <h3>${_('Global application settings')}</h3> 
 
    ${h.form(url('admin_setting', setting_id='global'),method='put')}
 
    <div class="form">
 
        <!-- fields -->
 
        
 
        <div class="fields">
 
             
 
             <div class="field">
 
                <div class="label">
 
                    <label for="rhodecode_title">${_('Application name')}:</label>
 
                </div>
 
                <div class="input">
 
                    ${h.text('rhodecode_title',size=30)}
 
                </div>
 
             </div>
 
                          
 
            <div class="field">
 
                <div class="label">
 
                    <label for="rhodecode_realm">${_('Realm text')}:</label>
 
                </div>
 
                <div class="input">
 
                    ${h.text('rhodecode_realm',size=30)}
 
                </div>
 
            </div>
 
                                     
 
            <div class="buttons">
 
                ${h.submit('save','save settings',class_="ui-button ui-widget ui-state-default ui-corner-all")}
 
                ${h.submit('save','Save settings',class_="ui-button ui-widget ui-state-default ui-corner-all")}
 
                ${h.reset('reset','Reset',class_="ui-button ui-widget ui-state-default ui-corner-all")}
 
           </div>                                                          
 
        </div>
 
    </div>      
 
    ${h.end_form()}
 

	
 
    <h3>${_('Mercurial settings')}</h3> 
 
    ${h.form(url('admin_setting', setting_id='mercurial'),method='put')}
 
    <div class="form">
 
        <!-- fields -->
 
        
 
        <div class="fields">
 
             
 
             <div class="field">
 
                <div class="label label-checkbox">
 
                    <label for="web_push_ssl">${_('Web')}:</label>
 
                </div>
 
                <div class="checkboxes">
 
					<div class="checkbox">
 
						${h.checkbox('web_push_ssl','true')}
 
						<label for="web_push_ssl">${_('require ssl for pushing')}</label>
 
					</div>
 
				</div>
 
             </div>						
 

	
 
@@ -140,39 +141,40 @@
 
                    <div class="checkbox">
 
                        ${h.checkbox('hooks_pretxnchangegroup_push_logger','True')}
 
                        <label for="hooks_pretxnchangegroup_push_logger">${_('Log user push commands')}</label>
 
                    </div>
 
                    <div class="checkbox">
 
                        ${h.checkbox('hooks_preoutgoing_pull_logger','True')}
 
                        <label for="hooks_preoutgoing_pull_logger">${_('Log user pull commands')}</label>
 
                    </div>                    										
 
				</div>
 
             </div>	
 
							                          
 
            <div class="field">
 
                <div class="label">
 
                    <label for="paths_root_path">${_('Repositories location')}:</label>
 
                </div>
 
                <div class="input">
 
                    ${h.text('paths_root_path',size=30,readonly="readonly")}			                    
 
					<span id="path_unlock" class="tooltip" 
 
						tooltip_title="${h.tooltip(_('This a crucial application setting. If You really sure you need to change this, you must restart application in order to make this settings take effect. Click this label to unlock.'))}">
 
		                ${_('unlock')}</span>
 
                </div>
 
            </div>
 
                                     
 
            <div class="buttons">
 
                ${h.submit('save','save settings',class_="ui-button ui-widget ui-state-default ui-corner-all")}
 
                ${h.submit('save','Save settings',class_="ui-button ui-widget ui-state-default ui-corner-all")}
 
                ${h.reset('reset','Reset',class_="ui-button ui-widget ui-state-default ui-corner-all")}
 
           </div>                                                          
 
        </div>
 
    </div>      
 
    ${h.end_form()}
 
    
 
    <script type="text/javascript">
 
        YAHOO.util.Event.onDOMReady(function(){
 
            YAHOO.util.Event.addListener('path_unlock','click',function(){
 
                YAHOO.util.Dom.get('paths_root_path').removeAttribute('readonly');
 
            });
 
        });
 
    </script>
 
</div>
 
</%def>    
rhodecode/templates/admin/users/user_edit.html
Show inline comments
 
@@ -80,31 +80,32 @@
 
                </div>
 
                <div class="input">
 
                    ${h.text('email',class_='small')}
 
                </div>
 
             </div>
 
            
 
             <div class="field">
 
                <div class="label label-checkbox">
 
                    <label for="active">${_('Active')}:</label>
 
                </div>
 
                <div class="checkboxes">
 
                    ${h.checkbox('active',value=True)}
 
                </div>
 
             </div>
 
             
 
             <div class="field">
 
                <div class="label label-checkbox">
 
                    <label for="admin">${_('Admin')}:</label>
 
                </div>
 
                <div class="checkboxes">
 
                    ${h.checkbox('admin',value=True)}
 
                </div>
 
             </div>             
 
            <div class="buttons">
 
              ${h.submit('save','save',class_="ui-button ui-widget ui-state-default ui-corner-all")}
 
              ${h.submit('save','Save',class_="ui-button ui-widget ui-state-default ui-corner-all")}
 
              ${h.reset('reset','Reset',class_="ui-button ui-widget ui-state-default ui-corner-all")}
 
            </div>             
 
    	</div>    
 
    </div>
 
    ${h.end_form()}
 
</div>    
 
</%def>  
 
\ No newline at end of file
rhodecode/templates/admin/users/user_edit_my_account.html
Show inline comments
 
@@ -50,49 +50,53 @@
 
	                <div class="input">
 
	                    ${h.text('name')}
 
	                </div>
 
	             </div>
 
	            
 
	             <div class="field">
 
	                <div class="label">
 
	                    <label for="lastname">${_('Last Name')}:</label>
 
	                </div>
 
	                <div class="input">
 
	                    ${h.text('lastname')}
 
	                </div>
 
	             </div>
 
	            
 
	             <div class="field">
 
	                <div class="label">
 
	                    <label for="email">${_('Email')}:</label>
 
	                </div>
 
	                <div class="input">
 
	                    ${h.text('email')}
 
	                </div>
 
	             </div>
 
	            
 
	            <div class="buttons">
 
	              ${h.submit('save','save',class_="ui-button ui-widget ui-state-default ui-corner-all")}
 
	              ${h.submit('save','Save',class_="ui-button ui-widget ui-state-default ui-corner-all")}
 
	              ${h.reset('reset','Reset',class_="ui-button ui-widget ui-state-default ui-corner-all")}
 
	              
 
	              
 
	              
 
	            </div>             
 
	    	</div>
 
	    </div>    	
 
    ${h.end_form()}
 
    </div>
 
</div>    
 

	
 
<div class="box box-right">
 
    <!-- box / title -->
 
    <div class="title">
 
        <h5>${_('My repositories')}
 
        <input class="top-right-rounded-corner top-left-rounded-corner bottom-left-rounded-corner bottom-right-rounded-corner" id="q_filter" size="15" type="text" name="filter" value="${_('quick filter...')}"/>
 
        </h5>   
 
    </div>
 
    <!-- end box / title -->
 
    <div class="table">
 
	    <table>
 
	    <thead>
 
            <tr>
 
            <th class="left">${_('Name')}</th>
 
            <th class="left">${_('revision')}</th>
 
            <th colspan="2" class="left">${_('action')}</th>            
 
	    </thead>
 
	     <tbody>
rhodecode/templates/settings/repo_settings.html
Show inline comments
 
@@ -107,49 +107,50 @@
 
                        <tr id="add_perm_input">
 
                            <td>${h.radio('perm_new_user','repository.none')}</td>
 
                            <td>${h.radio('perm_new_user','repository.read')}</td>
 
                            <td>${h.radio('perm_new_user','repository.write')}</td>
 
                            <td>${h.radio('perm_new_user','repository.admin')}</td>
 
                            <td class='ac'>
 
                                <div class="perm_ac" id="perm_ac">
 
                                    ${h.text('perm_new_user_name',class_='yui-ac-input')}
 
                                    <div id="perm_container"></div>
 
                                </div>
 
                            </td>
 
                            <td></td>
 
                        </tr>
 
                        <tr>
 
                            <td colspan="6">
 
                                <span id="add_perm" class="add_icon" style="cursor: pointer;">
 
                                ${_('Add another user')}
 
                                </span>
 
                            </td>
 
                        </tr>
 
                    </table>             
 
             </div>
 
             
 
            <div class="buttons">
 
              ${h.submit('update','update',class_="ui-button ui-widget ui-state-default ui-corner-all")}
 
              ${h.submit('update','Update',class_="ui-button ui-widget ui-state-default ui-corner-all")}
 
              ${h.reset('reset','Reset',class_="ui-button ui-widget ui-state-default ui-corner-all")}
 
            </div>                                                          
 
        </div>
 
    </div>    
 
    ${h.end_form()}
 
        <script type="text/javascript">
 
            YAHOO.util.Event.onDOMReady(function(){
 
                var D = YAHOO.util.Dom;
 
                if(!D.hasClass('perm_new_user_name','error')){
 
                    D.setStyle('add_perm_input','display','none');
 
                }
 
                YAHOO.util.Event.addListener('add_perm','click',function(){
 
                    D.setStyle('add_perm_input','display','');
 
                    D.setStyle('add_perm','opacity','0.6');
 
                    D.setStyle('add_perm','cursor','default');
 
                });
 
            });
 
        </script>
 
        <script type="text/javascript">    
 
        YAHOO.example.FnMultipleFields = function(){
 
            var myContacts = ${c.users_array|n}
 
            
 
            // Define a custom search function for the DataSource
 
            var matchNames = function(sQuery) {
 
                // Case insensitive matching
0 comments (0 inline, 0 general)