changeset 2162:a704bbeb189c

pass item object as argument to render template
author Ana Balica <ana.balica@gmail.com>
date Sat, 20 Jul 2013 21:52:42 +0300
parents 8a90ebee0e42
children 52c47ef351dd
files MoinMoin/apps/frontend/views.py MoinMoin/items/__init__.py
diffstat 2 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/apps/frontend/views.py	Sat Jul 20 21:49:05 2013 +0300
+++ b/MoinMoin/apps/frontend/views.py	Sat Jul 20 21:52:42 2013 +0300
@@ -834,8 +834,13 @@
     :type item_name: unicode
     :returns: a page with all the items which link or transclude item_name
     """
+    try:
+        item = Item.create(item_name)
+    except AccessDenied:
+        abort(403)
     refs_here = _backrefs(item_name)
     return render_template('link_list_item_panel.html',
+                           item=item,
                            item_name=item_name,
                            headline=_(u"Items which refer to '%(item_name)s'", item_name=item_name),
                            item_names=refs_here
@@ -1716,6 +1721,10 @@
     """
     list similar item names
     """
+    try:
+        item = Item.create(item_name)
+    except AccessDenied:
+        abort(403)
     start, end, matches = findMatches(item_name)
     keys = sorted(matches.keys())
     # TODO later we could add titles for the misc ranks:
@@ -1732,6 +1741,7 @@
                 item_names.append(name)
     return render_template("link_list_item_panel.html",
                            headline=_("Items with similar names to '%(item_name)s'", item_name=item_name),
+                           item=item,
                            item_name=item_name,  # XXX no item
                            item_names=item_names)
 
--- a/MoinMoin/items/__init__.py	Sat Jul 20 21:49:05 2013 +0300
+++ b/MoinMoin/items/__init__.py	Sat Jul 20 21:52:42 2013 +0300
@@ -669,6 +669,7 @@
         rev_ids = []
         item_templates = self.content.get_templates(self.contenttype)
         return render_template('modify_select_template.html',
+                               item=self,
                                item_name=self.name,
                                itemtype=self.itemtype,
                                rev=self.rev,
@@ -700,6 +701,7 @@
         if method in ['GET', 'HEAD']:
             if isinstance(self.content, NonExistentContent):
                 return render_template('modify_select_contenttype.html',
+                                       item=self,
                                        item_name=self.name,
                                        itemtype=self.itemtype,
                                        group_names=content_registry.group_names,
@@ -737,6 +739,7 @@
                     return redirect(url_for_item(self.name))
         return render_template(self.modify_template,
                                item_name=self.name,
+                               item=item,
                                rows_meta=str(ROWS_META), cols=str(COLS),
                                form=form,
                                search_form=None,
@@ -787,6 +790,7 @@
 
     def _select_itemtype(self):
         return render_template('modify_select_itemtype.html',
+                               item=self,
                                item_name=self.name,
                                itemtypes=item_registry.shown_entries,
                               )