You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2013/02/19 20:26:45 UTC

[4/6] git commit: [#5685] Improved Older paging for commit log

[#5685] Improved Older paging for commit log

Signed-off-by: Cory Johns <jo...@geek.net>


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/9ae902a0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/9ae902a0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/9ae902a0

Branch: refs/heads/master
Commit: 9ae902a01dbe620c7a3572684a1faecaa1004e73
Parents: 3a9359a
Author: Cory Johns <jo...@geek.net>
Authored: Mon Feb 18 22:37:04 2013 +0000
Committer: Dave Brondsema <db...@geek.net>
Committed: Tue Feb 19 19:26:30 2013 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py       |    8 ++++++--
 Allura/allura/templates/repo/log.html         |    2 +-
 Allura/allura/templates/widgets/repo/log.html |    5 ++---
 3 files changed, 9 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/9ae902a0/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index 1beeebb..cf9aaf6 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -432,13 +432,17 @@ class CommitBrowser(BaseController):
         if path:
             path = path.lstrip('/')
         params = dict(path=path, rev=self._commit._id)
-        commits = list(c.app.repo.commits(limit=limit, **params))
-        revisions = M.repo.Commit.query.find({'_id': {'$in': commits}}).sort('committed.date', -1)
+        commits = list(c.app.repo.commits(limit=limit+1, **params))
+        next_commit = None
+        if len(commits) > limit:
+            next_commit = M.repo.Commit.query.get(_id=commits.pop())
+        revisions = sorted(M.repo.Commit.query.find({'_id': {'$in': commits}}), key=lambda c:commits.index(c._id))
         c.log_widget = self.log_widget
         return dict(
             username=c.user._id and c.user.username,
             branch=None,
             log=revisions,
+            next_commit=next_commit,
             limit=limit,
             **kw)
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/9ae902a0/Allura/allura/templates/repo/log.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/log.html b/Allura/allura/templates/repo/log.html
index 4336684..8424422 100644
--- a/Allura/allura/templates/repo/log.html
+++ b/Allura/allura/templates/repo/log.html
@@ -13,7 +13,7 @@
 {% block content %}
   <br style="clear:both"/>
   {% if log %}
-    {{c.log_widget.display(value=log, limit=limit, count=count)}}
+    {{c.log_widget.display(value=log, limit=limit, count=count, next_commit=next_commit)}}
   {% else %}
     <p><b>No (more) commits</b></p>
   {% endif %}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/9ae902a0/Allura/allura/templates/widgets/repo/log.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/repo/log.html b/Allura/allura/templates/widgets/repo/log.html
index c3e024f..fd21ffd 100644
--- a/Allura/allura/templates/widgets/repo/log.html
+++ b/Allura/allura/templates/widgets/repo/log.html
@@ -35,11 +35,10 @@
             <a href="{{commit.url()}}tree/">Tree</a>
           </td>
         </tr>
-        {% do c.__setattr__('last_commit', commit) %}
       {% endfor %}
     </tbody>
   </table>
-  {% if show_paging %}
-      <a class="page_list" href="{{c.last_commit.url()}}log{{tg.url(params=request.params)}}">Older ></a>
+  {% if show_paging and next_commit %}
+      <a class="page_list" href="{{next_commit.url()}}log{{tg.url(params=request.params)}}">Older ></a>
   {% endif %}
 </div>