changeset 2783:d75032c39f11

fix #459 Reverting a deleted item fails on Basic theme, fix Name/Item ID column display bug
author RogerHaase <haaserd@gmail.com>
date Tue, 09 Sep 2014 10:30:02 -0700
parents d63def457cc5
children 6869a5b522d3
files MoinMoin/apps/frontend/views.py MoinMoin/templates/history.html MoinMoin/themes/basic/templates/history.html
diffstat 3 files changed, 57 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/apps/frontend/views.py	Fri Sep 05 14:17:15 2014 -0700
+++ b/MoinMoin/apps/frontend/views.py	Tue Sep 09 10:30:02 2014 -0700
@@ -1120,6 +1120,7 @@
                            item_name=item_name,  # XXX no item here
                            history_page=history_page,
                            bookmark_time=bookmark_time,
+                           NAME_EXACT=NAME_EXACT,
     )
 
 
--- a/MoinMoin/templates/history.html	Fri Sep 05 14:17:15 2014 -0700
+++ b/MoinMoin/templates/history.html	Tue Sep 09 10:30:02 2014 -0700
@@ -8,23 +8,23 @@
     {% if history %}
         <div class='moin-offset-links'>
             {% if previous_offset >= 0 %}
-                <a href="{{ url_for('frontend.history', item_name=item_name, offset=previous_offset) }}" title="{{ _("Previous") }}">&laquo;</a>
+                <a href="{{ url_for('frontend.history', item_name=fqname, offset=previous_offset) }}" title="{{ _("Previous") }}">&laquo;</a>
             {% endif %}
             {% if next_offset %}
-                <a href="{{ url_for('frontend.history', item_name=item_name, offset=next_offset) }}" title="{{ _("Next") }}">&raquo;</a>
+                <a href="{{ url_for('frontend.history', item_name=fqname, offset=next_offset) }}" title="{{ _("Next") }}">&raquo;</a>
             {% endif %}
         </div>
         <h1>{{ title }}</h1>
         <div class="moin-clr"></div>
-        <form action="{{ url_for('frontend.diff', item_name=item_name) }}" method="GET">
+        <form action="{{ url_for('frontend.diff', item_name=fqname) }}" method="GET">
             <div id="moin-page-history">
                 <table class="zebra">
                     <thead>
                         <tr>
-                            {% if fqname.field == 'name_exact' %}
-                                <th>{{ _("Item ID") }}</th>
+                            {% if fqname.field == NAME_EXACT %}
+                                <th>{{ _("Name") }}</th>
                             {% else %}
-                                <th>{{ _("Name") }}</th>
+                                <th>{{ _("ID or Name") }}</th>
                             {% endif %}
 
                             <th>{{ _("Rev.") }}</th>
@@ -40,18 +40,27 @@
                     <tbody>
                         {% for doc in history %}
                             <tr>
-                                {% if fqname.field == 'name_exact' %}
-                                    <td class="moin-wordbreak">
-                                        <a href="{{ url_for_item(doc.itemid, field='itemid', namespace=fqname.namespace, endpoint='frontend.history') }}">{{ doc.itemid|shorten_id }}</a>
-                                    </td>
-                                {% else %}
+                                {% if fqname.field == NAME_EXACT %}
                                     <td class="moin-wordbreak">
                                         {% for name in doc.name %}
                                             {% if not loop.first %}|{% endif %}
                                             <a href="{{ url_for_item(name, namespace=fqname.namespace, endpoint='frontend.history') }}">{{ name }}</a>
                                         {% endfor %}
                                     </td>
+                                {% else %}
+                                    <td class="moin-wordbreak">
+                                        {% if doc.name %}
+                                            {# If this is deleted item, earlier versions may have names. #}
+                                            {% for name in doc.name %}
+                                                {% if not loop.first %}|{% endif %}
+                                                <a href="{{ url_for_item(name, namespace=fqname.namespace, endpoint='frontend.history') }}">{{ name }}</a>
+                                            {% endfor %}
+                                        {% else %}
+                                            <a href="{{ url_for_item(doc.itemid, field='itemid', namespace=fqname.namespace, endpoint='frontend.history') }}">{{ doc.itemid|shorten_id }}</a>
+                                        {% endif %}
+                                    </td>
                                 {% endif %}
+
                                 <td>{{ doc.revid|shorten_id }}</td>
                                 <td>{{ doc.mtime|datetimeformat }}</td>
                                 <td class="moin-integer">{{ doc.size }}</td>
--- a/MoinMoin/themes/basic/templates/history.html	Fri Sep 05 14:17:15 2014 -0700
+++ b/MoinMoin/themes/basic/templates/history.html	Tue Sep 09 10:30:02 2014 -0700
@@ -2,7 +2,7 @@
 {% import "utils.html" as utils %}
 {% import theme("itemviews.html") as itemviews with context %}
 
-{% set title = _("History of '%(item_name)s'", item_name=item_name) %}
+{% set title = _("History of '%(fqname)s'", fqname=fqname|shorten_fqname) %}
 
 {% block views %}
     {{ itemviews }}
@@ -13,19 +13,24 @@
     {% if history %}
         <div>
             {% if previous_offset >= 0 %}
-                <a href="{{ url_for('frontend.history', item_name=item_name, offset=previous_offset) }}" title="{{ _("Previous") }}">&laquo;</a>
+                <a href="{{ url_for('frontend.history', item_name=fqname, offset=previous_offset) }}" title="{{ _("Previous") }}">&laquo;</a>
             {% endif %}
             {% if next_offset %}
-                <a href="{{ url_for('frontend.history', item_name=item_name, offset=next_offset) }}" title="{{ _("Next") }}">&raquo;</a>
+                <a href="{{ url_for('frontend.history', item_name=fqname, offset=next_offset) }}" title="{{ _("Next") }}">&raquo;</a>
             {% endif %}
         </div>
         <h1>{{ title }}</h1>
-        <form action="{{ url_for('frontend.diff', item_name=item_name) }}" method="GET">
+        <form action="{{ url_for('frontend.diff', item_name=fqname) }}" method="GET">
             <div>
                 <table class="table table-hover table-condensed">
                     <thead>
                         <tr>
-                            <th>{{ _("Name") }}</th>
+                            {% if fqname.field == NAME_EXACT %}
+                                <th>{{ _("Name") }}</th>
+                            {% else %}
+                                <th>{{ _("ID or Name") }}</th>
+                            {% endif %}
+
                             <th>{{ _("Rev.") }}</th>
                             <th>{{ _("Timestamp") }}</th>
                             <th id="moin-button-diff"><button class="btn btn-sm btn-primary">Diff</button></th>
@@ -37,7 +42,26 @@
                     <tbody>
                         {% for doc in history %}
                             <tr>
-                                <td>{{ doc.name|join(' | ') }}</td>
+                                {% if fqname.field == NAME_EXACT %}
+                                    <td>
+                                        {% for name in doc.name %}
+                                            {% if not loop.first %}|{% endif %}
+                                            <a href="{{ url_for_item(name, namespace=fqname.namespace, endpoint='frontend.history') }}">{{ name }}</a>
+                                        {% endfor %}
+                                    </td>
+                                {% else %}
+                                    <td>
+                                        {% if doc.name %}
+                                            {% for name in doc.name %}
+                                                {% if not loop.first %}|{% endif %}
+                                                <a href="{{ url_for_item(name, namespace=fqname.namespace, endpoint='frontend.history') }}">{{ name }}</a>
+                                            {% endfor %}
+                                        {% else %}
+                                            <a href="{{ url_for_item(doc.itemid, field='itemid', namespace=fqname.namespace, endpoint='frontend.history') }}">{{ doc.itemid|shorten_id }}</a>
+                                        {% endif %}
+                                    </td>
+                                {% endif %}
+
                                 <td title="{{ _("Size") }}: {{ doc.size }} &#10;{{ doc.contenttype|shorten_ctype }}: {{ doc.contenttype }}" >
                                     {{ doc.revid | shorten_id }}
                                 </td>
@@ -57,35 +81,35 @@
                                         </button>
                                         <ul class="dropdown-menu pull-right submenu">
                                             <li>
-                                                <a href="{{ url_for('frontend.show_item', item_name=doc.name[0], rev=doc.revid) }}">
+                                                <a href="{{ url_for('frontend.show_item', item_name=fqname, rev=doc.revid) }}">
                                                     {{ _('show') }}
                                                 </a>
                                             </li>
                                             <li>
-                                                <a href="{{ url_for('frontend.show_item_meta', item_name=doc.name[0], rev=doc.revid) }}">
+                                                <a href="{{ url_for('frontend.show_item_meta', item_name=fqname, rev=doc.revid) }}">
                                                     {{ _('meta') }}
                                                 </a>
                                             </li>
                                             <li>
-                                                <a href="{{ url_for('frontend.download_item', item_name=doc.name[0], rev=doc.revid) }}">
+                                                <a href="{{ url_for('frontend.download_item', item_name=fqname, rev=doc.revid) }}">
                                                     {{ _('download') }}
                                                 </a>
                                             </li>
                                             <li>
-                                                <a href="{{ url_for('frontend.highlight_item', item_name=doc.name[0], rev=doc.revid) }}">
+                                                <a href="{{ url_for('frontend.highlight_item', item_name=fqname, rev=doc.revid) }}">
                                                     {{ _('highlight') }}
                                                 </a>
                                             </li>
                                             {% if user.may.write(item_name) -%}
                                                 <li>
-                                                    <a href="{{ url_for('frontend.revert_item', item_name=doc.name[0], rev=doc.revid) }}">
+                                                    <a href="{{ url_for('frontend.revert_item', item_name=fqname, rev=doc.revid) }}">
                                                         {{ _('revert') }}
                                                     </a>
                                                 </li>
                                             {%- endif %}
                                             {% if user.may.destroy(item_name) -%}
                                                 <li>
-                                                    <a href="{{ url_for('frontend.destroy_item', item_name=doc.name[0], rev=doc.revid) }}">
+                                                    <a href="{{ url_for('frontend.destroy_item', item_name=fqname, rev=doc.revid) }}">
                                                         {{ _('destroy') }}
                                                     </a>
                                                 </li>