Skip to content
Browse files

cil-735547d7: Now paginates the first page (but nothing more)

  • Loading branch information...
1 parent c4d9de6 commit f12d30a3ffaf1b57d8129ed54fa6d977034c8bd3 @chilts chilts committed Jan 26, 2010
Showing with 29 additions and 29 deletions.
  1. +2 −2 issues/i_735547d7.cil
  2. +11 −5 node/recipe.py
  3. +12 −6 page.py
  4. +3 −7 theme/admin/page-list.html
  5. +1 −9 theme/admin/recipe-list.html
View
4 issues/i_735547d7.cil
@@ -1,10 +1,10 @@
Summary: Make the admin screens limit their numbers and paginate properly
-Status: New
+Status: Finished
CreatedBy: Andrew Chilton <andychilton@gmail.com>
AssignedTo: Andrew Chilton <andychilton@gmail.com>
Label: Milestone-v0.05
Inserted: 2010-01-02T02:29:09
-Updated: 2010-01-07T08:43:54
+Updated: 2010-01-26T07:32:15
Now that the website has had lots of nodes migrated to it (from kapiti.geek.nz
and www.retire-at-40.com) it's pretty slow and sometimes times out. The admin
View
16 node/recipe.py
@@ -44,6 +44,8 @@
## ----------------------------------------------------------------------------
+page_count = 20
+
# List
class List(webbase.WebBase):
def get(self):
@@ -54,15 +56,19 @@ def get(self):
except BadKeyError:
# invalid key
self.redirect('.')
- recipes = Recipe.all().filter('section =', section).order('-inserted')
+ recipes = Recipe.all().filter('section =', section).order('-inserted').fetch(page_count+1)
else:
- recipes = Recipe.all().order('-inserted')
+ recipes = Recipe.all().order('-inserted').fetch(page_count+1)
+
+ more = True if len(recipes) > page_count else False
vals = {
- 'title' : 'Recipe List',
- 'sections' : Section.all(),
- 'section' : section,
+ 'title' : 'Recipe List',
+ 'sections' : Section.all(),
+ 'section' : section,
'recipes' : recipes,
+ 'page_count' : page_count if more else len(recipes),
+ 'more' : more,
}
self.template( 'recipe-list.html', vals, 'admin' );
View
18 page.py
@@ -42,6 +42,8 @@
## ----------------------------------------------------------------------------
+page_count = 20
+
# List
class List(webbase.WebBase):
def get(self):
@@ -52,15 +54,19 @@ def get(self):
except BadKeyError:
# invalid key
self.redirect('.')
- pages = Page.all().filter('section =', section).order('-inserted')
+ pages = Page.all().filter('section =', section).order('-inserted').fetch(page_count+1)
else:
- pages = Page.all().order('-inserted')
+ pages = Page.all().order('-inserted').fetch(page_count+1)
+
+ more = True if len(pages) > page_count else False
vals = {
- 'title' : 'Page List',
- 'sections' : Section.all(),
- 'section' : section,
- 'pages' : pages,
+ 'title' : 'Page List',
+ 'sections' : Section.all(),
+ 'section' : section,
+ 'pages' : pages,
+ 'page_count' : page_count if more else len(pages),
+ 'more' : more,
}
self.template( 'page-list.html', vals, 'admin' );
View
10 theme/admin/page-list.html
@@ -6,9 +6,7 @@
{% include 'section-filter.fhtml' %}
-{% if pages.count %}
-
-<p>There are {{ pages.count|escape }} pages{% if section %} in '<strong>{{ section.path|escape }}</strong>'{% endif %}.</p>
+<p>There {{ pages|length|pluralize:"is,are" }} {{ more|yesno:"more than," }} {{ page_count|escape }} page{{ comments|length|pluralize }}{% if section %} in '<strong>{{ section.path|escape }}</strong>'{% endif %}.</p>
<table class="list striped">
<thead>
@@ -39,10 +37,8 @@
</tbody>
</table>
-{% else %}
-
-<p>There are no pages{% if section %} in '<strong>{{ section.path|escape }}</strong>'{% endif %}.</p>
-
+{% if more %}
+<p><a href="/todo.html">Older &raquo;</p></p>
{% endif %}
{% endblock %}
View
10 theme/admin/recipe-list.html
@@ -6,9 +6,7 @@
{% include 'section-filter.fhtml' %}
-{% if recipes.count %}
-
-<p>There are {{ recipes.count|escape }} recipes{% if section %} in '<strong>{{ section.path|escape }}</strong>'{% endif %}.</p>
+<p>There {{ recipes|length|pluralize:"is,are" }} {{ more|yesno:"more than," }} {{ page_count|escape }} recipe{{ comments|length|pluralize }}{% if section %} in '<strong>{{ section.path|escape }}</strong>'{% endif %}.</p>
<table class="list striped">
<thead>
@@ -39,10 +37,4 @@
</tbody>
</table>
-{% else %}
-
-<p>There are no recipes{% if section %} in '<strong>{{ section.path|escape }}</strong>'{% endif %}.</p>
-
-{% endif %}
-
{% endblock %}

0 comments on commit f12d30a

Please sign in to comment.
Something went wrong with that request. Please try again.