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
 
@@ -49,13 +49,13 @@ class ReposGroupsController(BaseControll
 
    def show(self, id, format='html'):
 
        """GET /repos_groups/id: Show a specific item"""
 
        # url('repos_group', id=ID)
 

	
 
        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'))
 

	
 
        sortables = ['name', 'description', 'last_change', 'tip', 'owner']
 
        current_sort = request.GET.get('sort', 'name')
 
        current_sort_slug = current_sort.replace('-', '')
 
@@ -79,11 +79,15 @@ class ReposGroupsController(BaseControll
 
        else:
 
            c.repos_list = sorted(c.cached_repo_list, key=itemgetter(sort_key),
 
                                  reverse=False)
 

	
 
        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'):
 
        """GET /repos_groups/id/edit: Form to edit an existing item"""
 
        # url('edit_repos_group', id=ID)
rhodecode/controllers/home.py
Show inline comments
 
@@ -28,13 +28,13 @@ from operator import itemgetter
 

	
 
from pylons import tmpl_context as c, request
 
from paste.httpexceptions import HTTPBadRequest
 

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

	
 
from rhodecode.model.db import Group
 

	
 
log = logging.getLogger(__name__)
 

	
 

	
 
class HomeController(BaseController):
 

	
 
@@ -61,12 +61,18 @@ class HomeController(BaseController):
 
                                  reverse=True)
 
        else:
 
            c.repos_list = sorted(c.cached_repo_list, key=itemgetter(sort_key),
 
                                  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):
 
        if request.is_xhr:
 
            c.repos_list = sorted(c.cached_repo_list,
 
                                  key=itemgetter('name_sort'), reverse=False)
rhodecode/model/db.py
Show inline comments
 
@@ -294,16 +294,18 @@ class Repository(Base):
 
        return self.groups_with_parents, self.just_name
 

	
 

	
 
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)
 

	
 

	
 
    def __init__(self, group_name='', parent_group=None):
 
        self.group_name = group_name
 
@@ -333,13 +335,13 @@ class Group(Base):
 
    def full_path(self):
 
        return '/'.join([g.group_name for g in self.parents] +
 
                        [self.group_name])
 

	
 
    @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'
 
    __table_args__ = {'useexisting':True}
 
    permission_id = Column("permission_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
 
    permission_name = Column("permission_name", String(length=255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
rhodecode/model/scm.py
Show inline comments
 
@@ -116,20 +116,22 @@ class ScmModel(BaseModel):
 
            except OSError:
 
                continue
 

	
 
        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]
 

	
 
        #get the repositories that should be invalidated
 
        invalidation_list = [str(x.cache_key) for x in \
 
                             self.sa.query(CacheInvalidation.cache_key)\
rhodecode/templates/admin/repos_groups/repos_groups.html
Show inline comments
 
@@ -4,13 +4,18 @@
 
<%def name="title()">
 
    ${_('Repository group')} - ${c.rhodecode_name}
 
</%def>
 

	
 

	
 
<%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')}
 
</%def>
 
<%def name="main()">
 
    <%def name="get_sort(name)">
 
@@ -30,12 +35,41 @@
 
    <!-- box / title -->
 
    <div class="title">
 
        ${self.breadcrumbs()}       
 
    </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>
 
                    <th class="left">${get_sort(_('Name'))}</th>
 
                    <th class="left">${get_sort(_('Description'))}</th>
 
                    <th class="left">${get_sort(_('Last change'))}</th>
 
@@ -109,13 +143,13 @@
 
                        <a title="${_('Subscribe to %s atom feed')%repo['name']}"  class="atom_icon" href="${h.url('atom_feed_home',repo_name=repo['name'],api_key=c.rhodecode_user.api_key)}"></a>
 
                      %else:
 
                        <a title="${_('Subscribe to %s atom feed')%repo['name']}"  class="atom_icon" href="${h.url('atom_feed_home',repo_name=repo['name'])}"></a>
 
                      %endif:
 
                    </td>
 
                </tr>
 
            %endfor
 
            %endfor          
 
            </tbody>
 
            </table>
 
            </div>
 
</div> 
 
           
 
</%def>    
rhodecode/templates/index.html
Show inline comments
 
@@ -43,12 +43,41 @@
 
		        </ul>  	        
 
		        %endif
 
		    %endif
 
	    </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>
 
			        <th class="left">${get_sort(_('Name'))}</th>
 
			        <th class="left">${get_sort(_('Description'))}</th>
 
			        <th class="left">${get_sort(_('Last change'))}</th>
 
@@ -123,12 +152,13 @@
 
		              %else:
 
		                <a title="${_('Subscribe to %s atom feed')%repo['name']}"  class="atom_icon" href="${h.url('atom_feed_home',repo_name=repo['name'])}"></a>
 
		              %endif:
 
		            </td>
 
		        </tr>
 
		    %endfor
 
		    
 
            </tbody>
 
            </table>
 
            </div>
 
    </div>
 
    
 
    
0 comments (0 inline, 0 general)