Reimar Bauer avatar Reimar Bauer committed 42662a4

fix global_history view

Comments (0)

Files changed (2)

MoinMoin/apps/frontend/views.py

         query = And([query, DateRange(MTIME, start=bookmark_time, end=None)])
     # TODO: we need use limit=None to simulate previous implementation's behaviour -
     # it would be better to use search_page (and an appropriate limit, if needed)
-    history = flaskg.storage.search(query, all_revs=True, sortedby=[MTIME], reverse=True, limit=None) # XXX
+    revs = flaskg.storage.search(query, all_revs=True, sortedby=[MTIME], reverse=True, limit=None)
+    history = [dict(rev.meta.iteritems()) for rev in revs]
     item_groups = OrderedDict()
     for doc in history:
         current_item_name = doc[NAME]
-        if bookmark_time and doc[MTIME] <= bookmark_time:
+        if bookmark_time and datetime.utcfromtimestamp(doc[MTIME]) <= bookmark_time:
             break
         elif current_item_name in item_groups:
             latest_doc = item_groups[current_item_name][0]
             tm_latest = latest_doc[MTIME]
             tm_current = doc[MTIME]
-            if format_date(tm_latest) == format_date(tm_current): # this change took place on the same day
+            if format_date(datetime.utcfromtimestamp(tm_latest)) == format_date(datetime.utcfromtimestamp(tm_current)): # this change took place on the same day
                 item_groups[current_item_name].append(doc)
         else:
             item_groups[current_item_name] = [doc]
         current_doc = docs[0]
         item_info["item_name"] = item_name
         item_info["name"] = current_doc[NAME]
-        item_info["timestamp"] = current_doc[MTIME]
+        item_info["timestamp"] = datetime.utcfromtimestamp(current_doc[MTIME])
         item_info["contenttype"] = current_doc[CONTENTTYPE]
         item_info["action"] = current_doc[ACTION]
 
         # Aggregating comments, authors and revno
         for doc in docs:
-            rev_no = doc[REVID]
+            rev_no = ':' + doc[REVID]
             revnos.append(rev_no)
             comment = doc.get(COMMENT)
             if comment:
         else:
             # grouping the revision numbers into a range, which belong to a particular editor(user) for the current item
             for info, positions in editors_info.values():
-                position_range = util.rangelist(positions)
-                position_range = "[%(position_range)s]" % {'position_range': position_range}
+                idx = [revnos.index(pos) for pos in positions]
+                position_range = util.rangelist(idx)
                 info_tuple = (info, position_range)
                 editors.append(info_tuple)
 

MoinMoin/templates/global_history.html

                         <tr>
                             {% set item_latest_revno = rev.revnos[0] %}
                             <td class="moin-action" title="{{ _("DIFF") }}">                                
-                                <a href="{{ url_for('frontend.diff', item_name=rev.item_name, rev1=item_latest_revno, rev2=0) }}" class="moin-history-{{ rev.action|lower }}"></a>
+                                <a href="{{ url_for('frontend.diff', item_name=rev.item_name, rev1=item_latest_revno, rev2=rev.revnos[-1]) }}" class="moin-history-{{ rev.action|lower }}">  </a>
                             </td>
                             <td class="moin-history-item"><a class="{{ rev.contenttype|contenttype_to_class }}" href="{{ url_for('frontend.show_item', item_name=rev.item_name) }}" title="{{ rev.contenttype }}">{{ rev.item_name }}</a></td>
                             <td class="moin-history-time">{{ rev.timestamp|timeformat }}</td>
                             <td class="moin-history-links">
                                 {% for revno in rev.revnos %}
-                                    {% if revno %}
-                                        <a href="{{ url_for('frontend.diff', item_name=rev.item_name, rev1=revno, rev2=revno-1) }}">[{{ revno }}]</a>
+                                    {% set position = rev.revnos.index(revno) %}
+                                    {% if position > 0 %}
+                                        <a href="{{ url_for('frontend.diff', item_name=rev.item_name, rev1=revno, rev2=item_latest_revno) }}">[{{ position }}]</a>
                                     {% else %}
                                         <span>[0]</span>
                                     {% endif %}
                                 {% for info, position in rev.editors %}
                                     <span class="moin-history-editortext">
                                     {{ utils.show_editor_info(info) }}
-                                    {{ position }}
+                                    {% if position %}
+                                        [{{ position }}]
+                                    {% endif %}
                                     </span>
                                 {% endfor %}
                             </td>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.