changeset 74:079c61438b3f

only compute revisions list if navigation is shown
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 06 Mar 2011 03:15:40 +0100
parents d79a50e0a42d
children 26d320fc12a2
files MoinMoin/apps/frontend/views.py MoinMoin/templates/meta.html MoinMoin/templates/show.html
diffstat 3 files changed, 24 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/apps/frontend/views.py	Sun Mar 06 01:36:16 2011 +0100
+++ b/MoinMoin/apps/frontend/views.py	Sun Mar 06 03:15:40 2011 +0100
@@ -109,16 +109,17 @@
                         item_name=item_name)
     try:
         item = Item.create(item_name, rev_no=rev)
-        rev_nos = item.rev.item.list_revisions()
     except AccessDeniedError:
         abort(403)
-    if rev_nos:
-        first_rev = rev_nos[0]
-        last_rev = rev_nos[-1]
-    else:
-        # Note: rev.revno of DummyRev is None
-        first_rev = None
-        last_rev = None
+    show_revision = show_navigation = rev >= 0
+    # Note: rev.revno of DummyRev is None
+    first_rev = None
+    last_rev = None
+    if show_navigation:
+        rev_nos = item.rev.item.list_revisions()
+        if rev_nos:
+            first_rev = rev_nos[0]
+            last_rev = rev_nos[-1]
     if isinstance(item, NonExistent):
         status = 404
     else:
@@ -130,7 +131,8 @@
                               first_rev_no=first_rev,
                               last_rev_no=last_rev,
                               data_rendered=Markup(item._render_data()),
-                              show_navigation=(rev>=0),
+                              show_revision=show_revision,
+                              show_navigation=show_navigation,
                              )
     return Response(content, status)
 
@@ -165,14 +167,15 @@
         item = Item.create(item_name, rev_no=rev)
     except AccessDeniedError:
         abort(403)
-    rev_nos = item.rev.item.list_revisions()
-    if rev_nos:
-        first_rev = rev_nos[0]
-        last_rev = rev_nos[-1]
-    else:
-        # Note: rev.revno of DummyRev is None
-        first_rev = None
-        last_rev = None
+    show_revision = show_navigation = rev >= 0
+    # Note: rev.revno of DummyRev is None
+    first_rev = None
+    last_rev = None
+    if show_navigation:
+        rev_nos = item.rev.item.list_revisions()
+        if rev_nos:
+            first_rev = rev_nos[0]
+            last_rev = rev_nos[-1]
     return render_template('meta.html',
                            item=item, item_name=item.name,
                            rev=item.rev,
@@ -180,7 +183,8 @@
                            first_rev_no=first_rev,
                            last_rev_no=last_rev,
                            meta_rendered=Markup(item._render_meta()),
-                           show_navigation=(rev>=0),
+                           show_revision=show_revision,
+                           show_navigation=show_navigation,
                           )
 
 
--- a/MoinMoin/templates/meta.html	Sun Mar 06 01:36:16 2011 +0100
+++ b/MoinMoin/templates/meta.html	Sun Mar 06 03:15:40 2011 +0100
@@ -7,7 +7,7 @@
 {% block headline %}
 <h1>
     {{ _("Metadata of '%(item_name)s'", item_name=item_name) }}
-    {% if rev.revno != last_rev_no %}({{ _("Revision") }} {{ rev.revno }}){% endif %}
+    {% if show_revision %}({{ _("Revision") }} {{ rev.revno }}){% endif %}
 </h1>
 {% endblock %}
 
--- a/MoinMoin/templates/show.html	Sun Mar 06 01:36:16 2011 +0100
+++ b/MoinMoin/templates/show.html	Sun Mar 06 03:15:40 2011 +0100
@@ -47,7 +47,7 @@
     {{ _("This item exists, but it has no revisions.") }}
     {% else %}
     {% block headline %}
-    {# <h1>{{ rev.item.name }} {% if rev.revno != last_rev_no %}(Revision {{ rev.revno }}){% endif %}</h1> #}
+    {# <h1>{{ rev.item.name }} {% if show_revision %}(Revision {{ rev.revno }}){% endif %}</h1> #}
     {% endblock %}
     {% block content_data %}
     {% if data_rendered %}