changeset 2269:494166b34798

Added fqname support to backrefs view.
author Ashutosh Singla <ashu1461@gmail.com>
date Wed, 11 Sep 2013 23:39:15 +0530
parents 9ad7a108b511
children ff7194d0a709
files MoinMoin/apps/frontend/views.py MoinMoin/templates/link_list_item_panel.html
diffstat 2 files changed, 13 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/apps/frontend/views.py	Wed Sep 11 23:15:03 2013 +0530
+++ b/MoinMoin/apps/frontend/views.py	Wed Sep 11 23:39:15 2013 +0530
@@ -960,26 +960,29 @@
     :type item_name: unicode
     :returns: a page with all the items which link or transclude item_name
     """
-    refs_here = _backrefs(item_name)
+    fqname = split_fqname(item_name)
+    refs_here = _backrefs(fqname)
     return render_template('link_list_item_panel.html',
                            item_name=item_name,
+                           fqname=fqname,
                            headline=_(u"Items which refer to '%(item_name)s'", item_name=item_name),
-                           item_names=refs_here
+                           fq_names=refs_here
     )
 
 
-def _backrefs(item_name):
+def _backrefs(fq_name):
     """
-    Returns a list with all names of items which ref item_name
+    Returns a list with all names of items which ref fq_name
 
     :param item_name: the name of the item transcluded or linked
     :type item_name: unicode
-    :returns: the list of all items which ref item_name
+    :returns: the list of all items which ref fq_name
     """
+    item_name = fq_name.value
     q = And([Term(WIKINAME, app.cfg.interwikiname),
              Or([Term(ITEMTRANSCLUSIONS, item_name), Term(ITEMLINKS, item_name)])])
     revs = flaskg.storage.search(q)
-    return [rev.name for rev in revs]
+    return [fqname for rev in revs for fqname in rev.fqnames]
 
 
 @frontend.route('/+history/<itemname:item_name>')
--- a/MoinMoin/templates/link_list_item_panel.html	Wed Sep 11 23:15:03 2013 +0530
+++ b/MoinMoin/templates/link_list_item_panel.html	Wed Sep 11 23:39:15 2013 +0530
@@ -3,11 +3,11 @@
 {% if headline %}
 <h1>{{ headline }}</h1>
 {% endif %}
-{% if item_names %}
-Total: {{ item_names|count }}
+{% if fq_names %}
+Total: {{ fq_names|count }}
 <ul>
-    {% for item_name in item_names|sort %}
-    <li><a href="{{ url_for('frontend.show_item', item_name=item_name) }}">{{ item_name }}</a></li>
+    {% for fq_name in fq_names|sort(attribute='value') %}
+        <li><a class="moin-fqname" href="{{ url_for('frontend.show_item', item_name=fq_name) }}" data-fqname="{{fq_name}}">{{ fq_name.value }}</a></li>
     {% endfor %}
 </ul>
 {% endif %}