diff --git a/rhodecode/config/routing.py b/rhodecode/config/routing.py --- a/rhodecode/config/routing.py +++ b/rhodecode/config/routing.py @@ -341,4 +341,8 @@ def make_map(config): rmap.connect('repo_followers_home', '/{repo_name:.*}/followers', controller='followers', action='followers', conditions=dict(function=check_repo)) + + rmap.connect('repo_forks_home', '/{repo_name:.*}/forks', + controller='forks', action='forks', + conditions=dict(function=check_repo)) return rmap diff --git a/rhodecode/controllers/followers.py b/rhodecode/controllers/followers.py --- a/rhodecode/controllers/followers.py +++ b/rhodecode/controllers/followers.py @@ -44,7 +44,7 @@ class FollowersController(BaseRepoContro def followers(self, repo_name): p = int(request.params.get('page', 1)) - repo_id = getattr(Repository.by_repo_name(repo_name), 'repo_id') + repo_id = Repository.by_repo_name(repo_name).repo_id d = UserFollowing.get_repo_followers(repo_id)\ .order_by(UserFollowing.follows_from) c.followers_pager = Page(d, page=p, items_per_page=20) diff --git a/rhodecode/controllers/forks.py b/rhodecode/controllers/forks.py new file mode 100644 --- /dev/null +++ b/rhodecode/controllers/forks.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +""" + rhodecode.controllers.forks + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + forks controller for rhodecode + + :created_on: Apr 23, 2011 + :author: marcink + :copyright: (C) 2009-2011 Marcin Kuzminski + :license: GPLv3, see COPYING for more details. +""" +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +import logging + +from pylons import tmpl_context as c, request + +from rhodecode.lib.helpers import Page +from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator +from rhodecode.lib.base import BaseRepoController, render +from rhodecode.model.db import Repository, User, UserFollowing + +log = logging.getLogger(__name__) + + +class ForksController(BaseRepoController): + + @LoginRequired() + @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', + 'repository.admin') + def __before__(self): + super(ForksController, self).__before__() + + def forks(self, repo_name): + p = int(request.params.get('page', 1)) + repo_id = Repository.by_repo_name(repo_name).repo_id + d = Repository.get_repo_forks(repo_id) + c.forks_pager = Page(d, page=p, items_per_page=20) + + c.forks_data = render('/forks/forks_data.html') + + if request.params.get('partial'): + return c.forks_data + + return render('/forks/forks.html') diff --git a/rhodecode/model/db.py b/rhodecode/model/db.py --- a/rhodecode/model/db.py +++ b/rhodecode/model/db.py @@ -237,6 +237,8 @@ class Repository(Base): enable_statistics = Column("statistics", Boolean(), nullable=True, unique=None, default=True) enable_downloads = Column("downloads", Boolean(), nullable=True, unique=None, default=True) description = Column("description", String(length=10000, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) + created_on = Column('created_on', DateTime(timezone=False), nullable=True, unique=None, default=datetime.datetime.now) + fork_id = Column("fork_id", Integer(), ForeignKey('repositories.repo_id'), nullable=True, unique=False, default=None) group_id = Column("group_id", Integer(), ForeignKey('groups.group_id'), nullable=True, unique=False, default=None) @@ -260,6 +262,11 @@ class Repository(Base): def by_repo_name(cls, repo_name): return Session.query(cls).filter(cls.repo_name == repo_name).one() + + @classmethod + def get_repo_forks(cls, repo_id): + return Session.query(cls).filter(Repository.fork_id == repo_id) + @property def just_name(self): return self.repo_name.split(os.sep)[-1] diff --git a/rhodecode/templates/base/base.html b/rhodecode/templates/base/base.html --- a/rhodecode/templates/base/base.html +++ b/rhodecode/templates/base/base.html @@ -298,7 +298,7 @@
  • - + ${_('Forks')} diff --git a/rhodecode/templates/forks/forks.html b/rhodecode/templates/forks/forks.html new file mode 100644 --- /dev/null +++ b/rhodecode/templates/forks/forks.html @@ -0,0 +1,32 @@ +## -*- coding: utf-8 -*- +<%inherit file="/base/base.html"/> + +<%def name="title()"> + ${c.repo_name} ${_('Forks')} - ${c.rhodecode_name} + + +<%def name="breadcrumbs_links()"> + ${h.link_to(u'Home',h.url('/'))} + » + ${h.link_to(c.repo_name,h.url('summary_home',repo_name=c.repo_name))} + » + ${_('forks')} + + +<%def name="page_nav()"> + ${self.menu('forks')} + +<%def name="main()"> +
    + +
    + ${self.breadcrumbs()} +
    + +
    +
    + ${c.forks_data} +
    +
    +
    + \ No newline at end of file diff --git a/rhodecode/templates/forks/forks_data.html b/rhodecode/templates/forks/forks_data.html new file mode 100644 --- /dev/null +++ b/rhodecode/templates/forks/forks_data.html @@ -0,0 +1,40 @@ +## -*- coding: utf-8 -*- + +% for f in c.forks_pager: +
    +
    +
    + gravatar +
    + + ${f.user.username} (${f.user.name} ${f.user.lastname}) / + ${h.link_to(f.repo_name,h.url('summary_home',repo_name=f.repo_name))} + +
    ${f.description}
    +
    +
    +
    ${_('forked')} - + ${h.age(f.created_on)}
    +
    +
    +% endfor + +
    + + +${c.forks_pager.pager('$link_previous ~2~ $link_next', +onclick="""YAHOO.util.Connect.asyncRequest('GET','$partial_url',{ +success:function(o){YAHOO.util.Dom.get(data_div).innerHTML=o.responseText; +YUE.on(YAHOO.util.Dom.getElementsByClassName('pager_link'),"click",function(){ + YAHOO.util.Dom.setStyle(data_div,'opacity','0.3');}); +YAHOO.util.Dom.setStyle(data_div,'opacity','1');}},null); return false;""")} +
    \ No newline at end of file