Changeset - a04fe5986109
[Not reviewed]
beta
0 6 0
Marcin Kuzminski - 14 years ago 2011-05-23 00:00:03
marcin@python-works.com
#47 implemented basic gui for browsing repo groups
6 files changed with 86 insertions and 8 deletions:
0 comments (0 inline, 0 general)
rhodecode/controllers/admin/repos_groups.py
Show inline comments
 
@@ -52,7 +52,7 @@ class ReposGroupsController(BaseControll
 

	
 
        c.group = Group.get(id)
 
        if c.group:
 
            c.group_repos = c.group.repositories
 
            c.group_repos = c.group.repositories.all()
 
        else:
 
            return redirect(url('repos_group'))
 

	
 
@@ -82,6 +82,10 @@ class ReposGroupsController(BaseControll
 

	
 
        c.repo_cnt = len(c.repos_list)
 

	
 

	
 
        c.groups = self.sa.query(Group).order_by(Group.group_name)\
 
            .filter(Group.group_parent_id == id).all()
 

	
 
        return render('admin/repos_groups/repos_groups.html')
 

	
 
    def edit(self, id, format='html'):
rhodecode/controllers/home.py
Show inline comments
 
@@ -31,7 +31,7 @@ from paste.httpexceptions import HTTPBad
 

	
 
from rhodecode.lib.auth import LoginRequired
 
from rhodecode.lib.base import BaseController, render
 

	
 
from rhodecode.model.db import Group
 

	
 
log = logging.getLogger(__name__)
 

	
 
@@ -64,6 +64,12 @@ class HomeController(BaseController):
 
                                  reverse=False)
 

	
 
        c.repo_cnt = len(c.repos_list)
 

	
 

	
 
        c.groups = self.sa.query(Group)\
 
            .filter(Group.group_parent_id == None).all()
 

	
 

	
 
        return render('/index.html')
 

	
 
    def repo_switcher(self):
rhodecode/model/db.py
Show inline comments
 
@@ -297,10 +297,12 @@ class Repository(Base):
 
class Group(Base):
 
    __tablename__ = 'groups'
 
    __table_args__ = (UniqueConstraint('group_name'), {'useexisting':True},)
 
    __mapper_args__ = {'order_by':'group_name'}
 

	
 
    group_id = Column("group_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
 
    group_name = Column("group_name", String(length=255, convert_unicode=False, assert_unicode=None), nullable=False, unique=True, default=None)
 
    group_parent_id = Column("group_parent_id", Integer(), ForeignKey('groups.group_id'), nullable=True, unique=None, default=None)
 
    group_description = Column("group_description", String(length=10000, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
 

	
 
    parent_group = relationship('Group', remote_side=group_id)
 

	
 
@@ -336,7 +338,7 @@ class Group(Base):
 

	
 
    @property
 
    def repositories(self):
 
        return Session.query(Repository).filter(Repository.group == self).all()
 
        return Session.query(Repository).filter(Repository.group == self)
 

	
 
class Permission(Base):
 
    __tablename__ = 'permissions'
rhodecode/model/scm.py
Show inline comments
 
@@ -119,14 +119,16 @@ class ScmModel(BaseModel):
 
        return repos_list
 

	
 
    def get_repos(self, all_repos=None):
 
        """Get all repos from db and for each repo create it's
 
        """
 
        Get all repos from db and for each repo create it's
 
        backend instance and fill that backed with information from database
 

	
 
        :param all_repos: give specific repositories list, good for filtering
 
            this have to be a list of  just the repository names
 
        :param all_repos: list of repository names as strings
 
            give specific repositories list, good for filtering
 
        """
 
        if all_repos is None:
 
            repos = self.sa.query(Repository)\
 
                        .filter(Repository.group_id == None)\
 
                        .order_by(Repository.repo_name).all()
 
            all_repos = [r.repo_name for r in repos]
 

	
rhodecode/templates/admin/repos_groups/repos_groups.html
Show inline comments
 
@@ -7,7 +7,12 @@
 

	
 

	
 
<%def name="breadcrumbs_links()">
 
    ${_('Group')} &raquo; ${c.group.group_name} - ${_(' %s repositories' % c.repo_cnt)} 
 
    ${_('Repository Groups')} 
 
    %if c.group.parent_group:
 
        &raquo; ${h.link_to(c.group.parent_group.group_name,h.url('repos_group',id=c.group.parent_group.group_id))}
 
    %endif
 
    
 
    &raquo; "${c.group.group_name}" ${_('with %s repositories' % c.repo_cnt)} 
 
</%def>
 
<%def name="page_nav()">
 
    ${self.menu('admin')}
 
@@ -33,6 +38,35 @@
 
    </div>
 
    <!-- end box / title -->
 
        <div class="table">
 
           % if c.groups:
 
            <table>
 
            
 
                <thead>
 
                    <tr>
 
                        <th class="left"><a href="#">${_('Group name')}</a></th>
 
                        <th class="left"><a href="#">${_('Description')}</a></th>
 
                        <th class="left"><a href="#">${_('Number of repositories')}</a></th>
 
                    </tr>
 
                </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(gr.group_name,url('repos_group',id=gr.group_id))}
 
                          </div>
 
                      </td>
 
                      <td>${gr.group_description}</td>
 
                      <td><b>${gr.repositories.count()}</b></td>
 
                  </tr>
 
                % endfor            
 
                
 
            </table>
 
            <div style="height: 20px"></div>
 
            % endif        
 
            <table>
 
            <thead>
 
                <tr>
 
@@ -112,7 +146,7 @@
 
                      %endif:
 
                    </td>
 
                </tr>
 
            %endfor
 
            %endfor          
 
            </tbody>
 
            </table>
 
            </div>
rhodecode/templates/index.html
Show inline comments
 
@@ -46,6 +46,35 @@
 
	    </div>
 
	    <!-- end box / title -->
 
        <div class="table">
 
           % if c.groups:
 
            <table>
 
            
 
                <thead>
 
                    <tr>
 
                        <th class="left"><a href="#">${_('Group name')}</a></th>
 
                        <th class="left"><a href="#">${_('Description')}</a></th>
 
                        <th class="left"><a href="#">${_('Number of repositories')}</a></th>
 
                    </tr>
 
                </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(gr.group_name,url('repos_group',id=gr.group_id))}
 
                          </div>
 
                      </td>
 
                      <td>${gr.group_description}</td>
 
                      <td><b>${gr.repositories.count()}</b></td>
 
                  </tr>
 
                % endfor            
 
                
 
            </table>
 
            <div style="height: 20px"></div>
 
            % endif
 
            <table>
 
            <thead>
 
	            <tr>
 
@@ -126,6 +155,7 @@
 
		            </td>
 
		        </tr>
 
		    %endfor
 
		    
 
            </tbody>
 
            </table>
 
            </div>
0 comments (0 inline, 0 general)