allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [38/50] git commit: [#4595] ticket:421 Pagination by date range
Date Thu, 05 Sep 2013 18:21:03 GMT
[#4595] ticket:421 Pagination by date range


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

Branch: refs/heads/cj/6596
Commit: 815940cca6165e0ae414bd96d8f3032fee2250d7
Parents: f865ddf
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Mon Sep 2 12:43:39 2013 +0300
Committer: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Committed: Wed Sep 4 13:19:55 2013 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/site_admin.py         | 12 ++++++++++-
 .../templates/site_admin_new_projects.html      | 21 ++++++++++++++++++++
 2 files changed, 32 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/815940cc/Allura/allura/controllers/site_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/site_admin.py b/Allura/allura/controllers/site_admin.py
index 818016f..eacf105 100644
--- a/Allura/allura/controllers/site_admin.py
+++ b/Allura/allura/controllers/site_admin.py
@@ -193,7 +193,7 @@ class SiteAdminController(object):
         except ValueError:
             end_dt = None
         start_dt = datetime.now() if not start_dt else start_dt
-        end_dt = start_dt - timedelta(days=15) if not end_dt else end_dt
+        end_dt = start_dt - timedelta(days=3) if not end_dt else end_dt
         start = bson.ObjectId.from_datetime(start_dt)
         end = bson.ObjectId.from_datetime(end_dt)
         nb = M.Neighborhood.query.get(name='Users')
@@ -202,8 +202,18 @@ class SiteAdminController(object):
                 'deleted': False,
                 '_id': {'$lt': start, '$gt': end},
             }).sort('_id', -1))
+        step = start_dt - end_dt
+        params = request.params.copy()
+        params['start-dt'] = (start_dt + step).strftime('%Y/%m/%d %H:%M:%S')
+        params['end-dt'] = (end_dt + step).strftime('%Y/%m/%d %H:%M:%S')
+        newer_url = tg.url(params=params).lstrip('/')
+        params['start-dt'] = (start_dt - step).strftime('%Y/%m/%d %H:%M:%S')
+        params['end-dt'] = (end_dt - step).strftime('%Y/%m/%d %H:%M:%S')
+        older_url = tg.url(params=params).lstrip('/')
         return {
             'projects': projects,
+            'newer_url': newer_url,
+            'older_url': older_url,
             'window_start': start_dt,
             'window_end': end_dt,
         }

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/815940cc/Allura/allura/templates/site_admin_new_projects.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/site_admin_new_projects.html b/Allura/allura/templates/site_admin_new_projects.html
index a3c0b76..b49bf1f 100644
--- a/Allura/allura/templates/site_admin_new_projects.html
+++ b/Allura/allura/templates/site_admin_new_projects.html
@@ -19,6 +19,13 @@
 {% set page="new_projects" %}
 {% extends 'allura:templates/site_admin.html' %}
 
+{% macro _paging() %}
+<div class="paging">
+    <a class="newer" title="Newer" href="{{ newer_url }}">&lt;</a>&nbsp;&hellip;&nbsp;
+    <a class="newer" title="Older" href="{{ older_url }}">&gt;</a>
+</div>
+{% endmacro %}
+
 {% block content %}
   <div class="grid-24">
   <form method="GET">
@@ -29,6 +36,7 @@
     <div class="grid-2"><input type="submit" value="Filter"></div>
   </form>
   </div>
+  {{ _paging() }}
   <table>
     <thead>
       <tr>
@@ -59,9 +67,22 @@
     </tr>
     {% endfor %}
   </table>
+  {{ _paging() }}
   <div id="selected-projects"></div>
 {% endblock %}
 
+{% block extra_css %}
+<style type="text/css">
+    .paging {
+        float: right;
+        margin: 1em;
+    }
+    .pad table {
+      width: 915px;
+    }
+</style>
+{% endblock %}
+
 {% block extra_js %}
   <script type="text/javascript" src="{{g.forge_static('js/site_admin_new_projects.js')}}"></script>
 {% endblock %}


Mime
View raw message