changeset 2270:ff7194d0a709

Added fqname support to forwardrefs view + updated +backrefs.
author Ashutosh Singla <ashu1461@gmail.com>
date Sat, 14 Sep 2013 00:58:52 +0530
parents 494166b34798
children 8db46c3b7760
files MoinMoin/apps/frontend/views.py
diffstat 1 files changed, 11 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/apps/frontend/views.py	Wed Sep 11 23:39:15 2013 +0530
+++ b/MoinMoin/apps/frontend/views.py	Sat Sep 14 00:58:52 2013 +0530
@@ -927,8 +927,9 @@
     refs = _forwardrefs(item_name)
     return render_template('link_list_item_panel.html',
                            item_name=item_name,
+                           fqname=split_fqname(item_name),
                            headline=_(u"Items that are referred by '%(item_name)s'", item_name=item_name),
-                           item_names=refs
+                           fq_names=split_fqname_list(refs),
     )
 
 
@@ -940,15 +941,15 @@
     :type item_name: unicode
     :returns: the list of all items which are referenced from this item
     """
-    q = {WIKINAME: app.cfg.interwikiname,
-         NAME_EXACT: item_name,
-        }
+    fqname = split_fqname(item_name)
+    q = fqname.query
+    q[WIKINAME] = app.cfg.interwikiname
     rev = flaskg.storage.document(**q)
     if rev is None:
         refs = []
     else:
         refs = rev.meta.get(ITEMLINKS, []) + rev.meta.get(ITEMTRANSCLUSIONS, [])
-    return refs
+    return set(refs)
 
 
 @frontend.route('/+backrefs/<itemname:item_name>')
@@ -960,17 +961,16 @@
     :type item_name: unicode
     :returns: a page with all the items which link or transclude item_name
     """
-    fqname = split_fqname(item_name)
-    refs_here = _backrefs(fqname)
+    refs_here = _backrefs(item_name)
     return render_template('link_list_item_panel.html',
                            item_name=item_name,
-                           fqname=fqname,
+                           fqname=split_fqname(item_name),
                            headline=_(u"Items which refer to '%(item_name)s'", item_name=item_name),
-                           fq_names=refs_here
+                           fq_names=refs_here,
     )
 
 
-def _backrefs(fq_name):
+def _backrefs(item_name):
     """
     Returns a list with all names of items which ref fq_name
 
@@ -978,11 +978,10 @@
     :type item_name: unicode
     :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 [fqname for rev in revs for fqname in rev.fqnames]
+    return set([fqname for rev in revs for fqname in rev.fqnames])
 
 
 @frontend.route('/+history/<itemname:item_name>')