Commits

Marcin Kuzminski  committed fbc762a

unified generation of repo groups choices
added on-the-fly conversion to new repository groups format (supporting path as a link)

  • Participants
  • Parent commits c363267
  • Branches beta

Comments (0)

Files changed (7)

File rhodecode/controllers/admin/repos.py

         super(ReposController, self).__before__()
 
     def __load_defaults(self):
+        c.repo_groups = Group.groups_choices()
+        c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups)
+        
         repo_model = RepoModel()
-
-        c.repo_groups = [('', '')]
-        parents_link = lambda k: h.literal('»'.join(
-                                    map(lambda k: k.group_name,
-                                        k.parents + [k])
-                                    )
-                                )
-
-        c.repo_groups.extend([(x.group_id, parents_link(x)) for \
-                                            x in self.sa.query(Group).all()])
-        c.repo_groups = sorted(c.repo_groups,
-                               key=lambda t: t[1].split('»')[0])
-        c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups)
         c.users_array = repo_model.get_users_js()
         c.users_groups_array = repo_model.get_users_groups_js()
 

File rhodecode/controllers/admin/repos_groups.py

         super(ReposGroupsController, self).__before__()
 
     def __load_defaults(self):
-
-        c.repo_groups = [('', '')]
-        parents_link = lambda k: h.literal('»'.join(k))
-
-        c.repo_groups.extend([(x.group_id, parents_link(x.full_path_splitted))
-                              for x in self.sa.query(Group).all()])
-
-        c.repo_groups = sorted(c.repo_groups,
-                               key=lambda t: t[1].split('»')[0])
+        c.repo_groups = Group.groups_choices()
         c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups)
 
     def __load_data(self, group_id):

File rhodecode/controllers/admin/settings.py

     def create_repository(self):
         """GET /_admin/create_repository: Form to create a new item"""
 
-        c.repo_groups = [('', '')]
-        parents_link = lambda k: h.literal('»'.join(
-                                    map(lambda k: k.group_name,
-                                        k.parents + [k])
-                                    )
-                                )
-
-        c.repo_groups.extend([(x.group_id, parents_link(x)) for \
-                                            x in self.sa.query(Group).all()])
-        c.repo_groups = sorted(c.repo_groups,
-                               key=lambda t: t[1].split('»')[0])
+        c.repo_groups = Group.groups_choices()
         c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups)
 
         new_repo = request.GET.get('repo', '')

File rhodecode/lib/helpers.py

         return repo_name
     else:
         def make_link(group):
-            return link_to(group.group_name, url('repos_group',
-                                                 id=group.group_id))
+            return link_to(group.name, url('repos_group_home',
+                                           group_name=group.group_name))
         return literal(' » '.join(map(make_link, groups)) + \
                        " » " + repo_name)
 
-
 def fancy_file_stats(stats):
     """
     Displays a fancy two colored bar for number of added/deleted

File rhodecode/lib/utils.py

     rm = RepoModel()
     user = sa.query(User).filter(User.admin == True).first()
     added = []
+    # fixup groups paths to new format on the fly
+    # TODO: remove this in future
+    for g in Group.query().all():
+        g.group_name = g.get_new_name(g.name)
+        sa.add(g)    
     for name, repo in initial_repo_list.items():
         group = map_groups(name.split(os.sep))
         if not rm.get_by_repo_name(name, cache=False):

File rhodecode/model/db.py

                                   self.group_name)
 
     @classmethod
+    def groups_choices(cls):
+        from webhelpers.html import literal as _literal
+        repo_groups = [('', '')]
+        sep = ' » '
+        _name = lambda k: _literal(sep.join(k))
+
+        repo_groups.extend([(x.group_id, _name(x.full_path_splitted))
+                              for x in cls.query().all()])
+        
+        repo_groups = sorted(repo_groups,key=lambda t: t[1].split(sep)[0])        
+        return repo_groups
+    
+    @classmethod
     def url_sep(cls):
         return '/'
 

File rhodecode/templates/summary/summary.html

                  
                  ##REPO TYPE
 		         %if c.dbrepo.repo_type =='hg':
-		           <img style="margin-bottom:2px" class="icon" title="${_('Mercurial repository')}" alt="${_('Mercurial repository')}" src="${h.url("/images/icons/hgicon.png")}"/>
+		           <img style="margin-bottom:2px" class="icon" title="${_('Mercurial repository')}" alt="${_('Mercurial repository')}" src="${h.url('/images/icons/hgicon.png')}"/>
 		         %endif
 		         %if c.dbrepo.repo_type =='git':
-		           <img style="margin-bottom:2px" class="icon" title="${_('Git repository')}" alt="${_('Git repository')}" src="${h.url("/images/icons/giticon.png")}"/>
+		           <img style="margin-bottom:2px" class="icon" title="${_('Git repository')}" alt="${_('Git repository')}" src="${h.url('/images/icons/giticon.png')}"/>
 		         %endif 
                             
                  ##PUBLIC/PRIVATE     			  
 	             %if c.dbrepo.private:
-	                <img style="margin-bottom:2px" class="icon" title="${_('private repository')}" alt="${_('private repository')}" src="${h.url("/images/icons/lock.png")}"/>
+	                <img style="margin-bottom:2px" class="icon" title="${_('private repository')}" alt="${_('private repository')}" src="${h.url('/images/icons/lock.png')}"/>
 	             %else:
-	                <img style="margin-bottom:2px" class="icon" title="${_('public repository')}" alt="${_('public repository')}" src="${h.url("/images/icons/lock_open.png")}"/>
+	                <img style="margin-bottom:2px" class="icon" title="${_('public repository')}" alt="${_('public repository')}" src="${h.url('/images/icons/lock_open.png')}"/>
 	             %endif
 	             
 	              ##REPO NAME
 	            	<a href="${h.url('summary_home',repo_name=c.dbrepo.fork.repo_name)}">
 	            	<img class="icon" alt="${_('public')}"
 	            	title="${_('Fork of')} ${c.dbrepo.fork.repo_name}" 
-	            	src="${h.url("/images/icons/arrow_divide.png")}"/>
+	            	src="${h.url('/images/icons/arrow_divide.png')}"/>
 	            	${_('Fork of')} ${c.dbrepo.fork.repo_name}
 	            	</a>
 	            	</div>
                     <a href="${h.url(str(h.hide_credentials(c.dbrepo.clone_uri)))}">
                     <img class="icon" alt="${_('remote clone')}"
                     title="${_('Clone from')} ${h.hide_credentials(c.dbrepo.clone_uri)}" 
-                    src="${h.url("/images/icons/connect.png")}"/>
+                    src="${h.url('/images/icons/connect.png')}"/>
                     ${_('Clone from')} ${h.hide_credentials(c.dbrepo.clone_uri)}
                     </a>
                     </div>