changeset 531:6fc59ac322ca

added info about forked repository in few places added autoloading of parent(forked) for each such repository
author Marcin Kuzminski <marcin@python-works.com>
date Fri, 01 Oct 2010 00:53:38 +0200
parents a08f610e545e
children 946ed2955f48
files pylons_app/model/hg_model.py pylons_app/templates/admin/repos/repos.html pylons_app/templates/admin/users/user_edit_my_account.html pylons_app/templates/index.html pylons_app/templates/summary/summary.html
diffstat 5 files changed, 58 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/pylons_app/model/hg_model.py	Fri Oct 01 00:16:09 2010 +0200
+++ b/pylons_app/model/hg_model.py	Fri Oct 01 00:53:38 2010 +0200
@@ -31,6 +31,7 @@
 from pylons_app.model.db import Repository, User
 from pylons_app.lib import helpers as h
 from vcs.exceptions import RepositoryError, VCSError
+from sqlalchemy.orm import joinedload
 import logging
 import os
 import sys
@@ -123,7 +124,9 @@
                     dbrepo = None
                     if not initial:
                         dbrepo = sa.query(Repository)\
-                            .filter(Repository.repo_name == name).scalar()
+                            .options(joinedload(Repository.fork))\
+                            .filter(Repository.repo_name == name)\
+                            .scalar()
                             
                     if dbrepo:
                         log.info('Adding db instance to cached list')
--- a/pylons_app/templates/admin/repos/repos.html	Fri Oct 01 00:16:09 2010 +0200
+++ b/pylons_app/templates/admin/repos/repos.html	Fri Oct 01 00:53:38 2010 +0200
@@ -27,9 +27,11 @@
     <div class="table">
         <table class="table_disp">
         <tr class="header">
-            <th class="left">${_('name')}</th>
-            <th class="left">${_('owner')}</th>
-            <th class="left">${_('last revision')}</th>
+	        <th class="left">${_('Name')}</th>
+	        <th class="left">${_('Description')}</th>
+	        <th class="left">${_('Last change')}</th>
+	        <th class="left">${_('Tip')}</th>
+	        <th class="left">${_('Contact')}</th>
             <th class="left">${_('action')}</th>
         </tr>
             %for cnt,repo in enumerate(c.repos_list):
@@ -40,9 +42,28 @@
                  %else:
                     <img alt="${_('public')}" src="/images/icons/lock_open.png"/>
                  %endif         
-                ${h.link_to(repo['name'],h.url('edit_repo',repo_name=repo['name']))}</td>
-                <td>${repo['contact']}</td>
-                <td>r${repo['rev']}:${repo['tip']}</td>
+                ${h.link_to(repo['name'],h.url('edit_repo',repo_name=repo['name']))}
+                
+	            %if repo['repo'].dbrepo.fork:
+	            	<a href="${h.url('summary_home',repo_name=repo['repo'].dbrepo.fork.repo_name)}">
+	            	<img class="icon" alt="${_('public')}"
+	            	title="${_('Fork of')} ${repo['repo'].dbrepo.fork.repo_name}" 
+	            	src="/images/icons/arrow_divide.png"/></a>
+	            %endif                
+                </td>
+				<td title="${repo['description']}">${h.truncate(repo['description'],60)}</td>
+	            <td>${h.age(repo['last_change'])}</td>
+	            <td>
+	            	%if repo['rev']>=0:
+	            	${h.link_to('r%s:%s' % (repo['rev'],repo['tip']),
+	                h.url('changeset_home',repo_name=repo['name'],revision=repo['tip']),
+	                class_="tooltip",
+	                tooltip_title=h.tooltip(repo['last_msg']))}
+	            	%else:
+	            		${_('No changesets yet')}
+	            	%endif    
+	            </td>
+	            <td title="${repo['contact']}">${h.person(repo['contact'])}</td>
                 <td>
                   ${h.form(url('repo', repo_name=repo['name']),method='delete')}
                     ${h.submit('remove_%s' % repo['name'],'delete',class_="delete_icon action_button",onclick="return confirm('Confirm to delete this repository');")}
--- a/pylons_app/templates/admin/users/user_edit_my_account.html	Fri Oct 01 00:16:09 2010 +0200
+++ b/pylons_app/templates/admin/users/user_edit_my_account.html	Fri Oct 01 00:53:38 2010 +0200
@@ -98,7 +98,14 @@
 		                <img class="icon" alt="${_('public')}" src="/images/icons/lock_open.png"/>
 		             %endif
 		                                             
-		            ${h.link_to(repo.name, h.url('summary_home',repo_name=repo.name))}</td> 
+		            ${h.link_to(repo.name, h.url('summary_home',repo_name=repo.name))}
+		            %if repo.dbrepo.fork:
+		            	<a href="${h.url('summary_home',repo_name=repo.dbrepo.fork.repo_name)}">
+		            	<img class="icon" alt="${_('public')}"
+		            	title="${_('Fork of')} ${repo.dbrepo.fork.repo_name}" 
+		            	src="/images/icons/arrow_divide.png"/></a>
+		            %endif		            
+		            </td> 
 		            <td>${_('revision')}: ${h.get_changeset_safe(repo,'tip').revision}</td>
 		            <td>${_('last changed')}: ${h.age(repo.last_change)}</td>
 		            <td><img class="icon" alt="${_('private')}" src="/images/icons/application_form_edit.png"/> ${h.link_to(_('edit'),h.url('repo_settings_home',repo_name=repo.name))}</td>
--- a/pylons_app/templates/index.html	Fri Oct 01 00:16:09 2010 +0200
+++ b/pylons_app/templates/index.html	Fri Oct 01 00:53:38 2010 +0200
@@ -61,7 +61,14 @@
 					                <img class="icon" alt="${_('public')}" src="/images/icons/lock_open.png"/>
 					             %endif  
 					            ${h.link_to(repo['name'],
-					                h.url('summary_home',repo_name=repo['name']))}</td>
+					                h.url('summary_home',repo_name=repo['name']))}
+					            %if repo['repo'].dbrepo.fork:
+					            	<a href="${h.url('summary_home',repo_name=repo['repo'].dbrepo.fork.repo_name)}">
+					            	<img class="icon" alt="${_('public')}"
+					            	title="${_('Fork of')} ${repo['repo'].dbrepo.fork.repo_name}" 
+					            	src="/images/icons/arrow_divide.png"/></a>
+					            %endif
+					            </td>
 					            <td title="${repo['description']}">${h.truncate(repo['description'],60)}</td>
 					            <td>${h.age(repo['last_change'])}</td>
 					            <td>
--- a/pylons_app/templates/summary/summary.html	Fri Oct 01 00:16:09 2010 +0200
+++ b/pylons_app/templates/summary/summary.html	Fri Oct 01 00:53:38 2010 +0200
@@ -42,7 +42,17 @@
 			      <label>${_('Name')}:</label>
 			  </div>
 			  <div class="input-short">
-			      <span style="font-size: 1.6em;font-weight: bold">${c.repo_info.name}</span>
+			      <span style="font-size: 1.6em;font-weight: bold;">${c.repo_info.name}</span><br/>
+		            %if c.repo_info.dbrepo.fork:
+		            	<span style="margin-top:5px">
+		            	<a href="${h.url('summary_home',repo_name=c.repo_info.dbrepo.fork.repo_name)}">
+		            	<img class="icon" alt="${_('public')}"
+		            	title="${_('Fork of')} ${c.repo_info.dbrepo.fork.repo_name}" 
+		            	src="/images/icons/arrow_divide.png"/>
+		            	${_('Fork of')} ${c.repo_info.dbrepo.fork.repo_name}
+		            	</a>
+		            	</span>
+		            %endif			      
 			  </div>
 			 </div>