Changeset - 923d2f699bd7
[Not reviewed]
beta
0 2 0
Marcin Kuzminski - 14 years ago 2011-06-05 02:09:27
marcin@python-works.com
fixed issue with adding new group. template typo fix for empty group
2 files changed with 3 insertions and 2 deletions:
0 comments (0 inline, 0 general)
rhodecode/model/forms.py
Show inline comments
 
@@ -106,50 +106,51 @@ def ValidUsersGroup(edit, old_data):
 
                                             state)
 

	
 

	
 
            if re.match(r'^[a-zA-Z0-9]{1}[a-zA-Z0-9\-\_\.]+$', value) is None:
 
                raise formencode.Invalid(_('Group name may only contain '
 
                                           'alphanumeric characters '
 
                                           'underscores, periods or dashes '
 
                                           'and must begin with alphanumeric '
 
                                           'character'), value, state)
 

	
 
    return _ValidUsersGroup
 

	
 

	
 
def ValidReposGroup(edit, old_data):
 
    class _ValidReposGroup(formencode.validators.FancyValidator):
 

	
 
        def validate_python(self, value, state):
 
            #TODO WRITE VALIDATIONS
 
            group_name = value.get('group_name')
 
            group_parent_id = int(value.get('group_parent_id') or - 1)
 

	
 
            # slugify repo group just in case :)
 
            slug = repo_name_slug(group_name)
 

	
 
            print old_data
 
            # check for parent of self
 
            if old_data['group_id'] == group_parent_id:
 
            if edit and old_data['group_id'] == group_parent_id:
 
                    e_dict = {'group_parent_id':_('Cannot assign this group '
 
                                                  'as parent')}
 
                    raise formencode.Invalid('', value, state,
 
                                             error_dict=e_dict)
 

	
 
            old_gname = None
 
            if edit:
 
                old_gname = Group.get(
 
                            old_data.get('group_id')).group_name
 

	
 
            if old_gname != group_name or not edit:
 
                # check filesystem
 
                gr = Group.query().filter(Group.group_name == slug)\
 
                    .filter(Group.group_parent_id == group_parent_id).scalar()
 

	
 
                if gr:
 
                    e_dict = {'group_name':_('This group already exists')}
 
                    raise formencode.Invalid('', value, state,
 
                                             error_dict=e_dict)
 

	
 
    return _ValidReposGroup
 

	
 
class ValidPassword(formencode.validators.FancyValidator):
 

	
rhodecode/templates/admin/repos_groups/repos_groups_show.html
Show inline comments
 
@@ -38,31 +38,31 @@
 
                </thead>
 
                
 
                ## REPO GROUPS
 
                
 
                % for gr in c.groups:
 
                  <tr>
 
                      <td>
 
                          <div style="white-space: nowrap">
 
                          <img class="icon" alt="${_('Repositories group')}" src="${h.url('/images/icons/database_link.png')}"/>
 
                          ${h.link_to(h.literal(' &raquo; '.join([g.group_name for g in gr.parents+[gr]])),url('edit_repos_group',id=gr.group_id))}
 
                          </div>
 
                      </td>
 
                      <td>${gr.group_description}</td>
 
                      <td><b>${gr.repositories.count()}</b></td>
 
		               <td>
 
		                 ${h.form(url('repos_group', id=gr.group_id),method='delete')}
 
		                   ${h.submit('remove_%s' % gr.group_name,'delete',class_="delete_icon action_button",onclick="return confirm('Confirm to delete this group');")}
 
		                 ${h.end_form()}
 
		               </td>                      
 
                  </tr>
 
                % endfor
 
                
 
            </table>
 
            % else:
 
                {_('There are no repositories groups yet')}
 
                ${_('There are no repositories groups yet')}
 
            % endif
 
         
 
    </div>
 
</div> 
 
           
 
</%def>    
0 comments (0 inline, 0 general)