Skip to content

Commit

Permalink
cil-735547d7: Now paginates the first page (but nothing more)
Browse files Browse the repository at this point in the history
  • Loading branch information
chilts committed Jan 26, 2010
1 parent c4d9de6 commit f12d30a
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions 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
Expand Down
16 changes: 11 additions & 5 deletions node/recipe.py
Expand Up @@ -44,6 +44,8 @@

## ----------------------------------------------------------------------------

page_count = 20

# List
class List(webbase.WebBase):
def get(self):
Expand All @@ -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' );

Expand Down
18 changes: 12 additions & 6 deletions page.py
Expand Up @@ -42,6 +42,8 @@

## ----------------------------------------------------------------------------

page_count = 20

# List
class List(webbase.WebBase):
def get(self):
Expand All @@ -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' );

Expand Down
10 changes: 3 additions & 7 deletions theme/admin/page-list.html
Expand Up @@ -6,9 +6,7 @@ <h2>Page List</h2>

{% 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>
Expand Down Expand Up @@ -39,10 +37,8 @@ <h2>Page List</h2>
</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 %}
10 changes: 1 addition & 9 deletions theme/admin/recipe-list.html
Expand Up @@ -6,9 +6,7 @@ <h2>Recipe List</h2>

{% 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>
Expand Down Expand Up @@ -39,10 +37,4 @@ <h2>Recipe List</h2>
</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.