Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make the page-list and image-list templates nicer

  • Loading branch information...
commit 9de7e9cf8bf87221cdbe05be6a1e2dc4a713d9a9 1 parent 3089572
@chilts chilts authored
View
11 file.py
@@ -42,12 +42,19 @@
## ----------------------------------------------------------------------------
+file_count = 20
+
# List
class List(webbase.WebBase):
def get(self):
- files = File.all().order('-inserted')
+ files = File.all().order('-inserted').fetch(file_count+1)
+
+ more = True if len(files) > file_count else False
+
vals = {
- 'files' : files
+ 'files' : files,
+ 'file_count' : file_count if more else len(files),
+ 'more' : more,
}
self.template( 'file-list.html', vals, 'admin' );
View
11 image.py
@@ -42,12 +42,19 @@
## ----------------------------------------------------------------------------
+image_count = 20
+
# List
class List(webbase.WebBase):
def get(self):
- images = Image.all().order('-inserted')
+ images = Image.all().order('-inserted').fetch(image_count+1)
+
+ more = True if len(images) > image_count else False
+
vals = {
- 'images' : images
+ 'images' : images,
+ 'image_count' : image_count if more else len(images),
+ 'more' : more,
}
self.template( 'image-list.html', vals, 'admin' );
View
10 theme/admin/file-list.html
@@ -4,9 +4,7 @@
<h2>File List</h2>
-{% if files.count %}
-
-<p>There are {{ files.count|escape }} files.</p>
+<p>There {{ files|length|pluralize:"is,are" }} {{ more|yesno:"more than," }} {{ file_count|escape }} file{{ files|length|pluralize }}.</p>
<table class="list striped">
<thead>
@@ -50,10 +48,4 @@
</tbody>
</table>
-{% else %}
-
-<p>There are no files.</p>
-
-{% endif %}
-
{% endblock %}
View
10 theme/admin/image-list.html
@@ -4,9 +4,7 @@
<h2>Image List</h2>
-{% if images.count %}
-
-<p>There are {{ images.count|escape }} images.</p>
+<p>There {{ images|length|pluralize:"is,are" }} {{ more|yesno:"more than," }} {{ image_count|escape }} image{{ images|length|pluralize }}.</p>
<table class="list striped">
<thead>
@@ -52,10 +50,4 @@
</tbody>
</table>
-{% else %}
-
-<p>There are no images.</p>
-
-{% endif %}
-
{% endblock %}
View
2  theme/admin/page-list.html
@@ -6,7 +6,7 @@
{% include 'section-filter.fhtml' %}
-<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>
+<p>There {{ pages|length|pluralize:"is,are" }} {{ more|yesno:"more than," }} {{ page_count|escape }} page{{ pages|length|pluralize }}{% if section %} in '<strong>{{ section.path|escape }}</strong>'{% endif %}.</p>
<table class="list striped">
<thead>
Please sign in to comment.
Something went wrong with that request. Please try again.