changeset 2380:7df17df524e7

adds helper function to render action tabs
author sharky93 <rishabhr123@gmail.com>
date Sat, 17 Aug 2013 00:21:30 +0530
parents 095250a9fd84
children aa19b1b69b5c
files MoinMoin/themes/__init__.py MoinMoin/themes/basic/templates/itemviews.html
diffstat 2 files changed, 10 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/themes/__init__.py	Wed Aug 14 20:50:04 2013 +0530
+++ b/MoinMoin/themes/__init__.py	Sat Aug 17 00:21:30 2013 +0530
@@ -79,6 +79,14 @@
         self.content_dir = 'ltr'  # XXX
         self.meta_items = []  # list of (name, content) for html head <meta>
 
+    def get_action_tabs(self, item_name):
+        navtabs = ['frontend.show_item', 'frontend.history',
+                'frontend.show_item_meta', 'frontend.highlight_item', 'frontend.backrefs',
+                'special.comments', 'special.transclusions',]
+        if self.user.may.write(item_name):
+            navtabs.append('frontend.modify_item')
+        return navtabs
+
     def location_breadcrumbs(self, item_name):
         """
         Assemble the location using breadcrumbs (was: title)
--- a/MoinMoin/themes/basic/templates/itemviews.html	Wed Aug 14 20:50:04 2013 +0530
+++ b/MoinMoin/themes/basic/templates/itemviews.html	Sat Aug 17 00:21:30 2013 +0530
@@ -11,9 +11,7 @@
                'special.transclusions' : "icon-edit",
            } %}
 
-{% set navtabs = ['frontend.show_item', 'frontend.modify_item', 'frontend.history',
-                  'frontend.show_item_meta', 'frontend.highlight_item', 'frontend.backrefs',
-                  'special.comments', 'special.transclusions',] %}
+{% set navtabs = theme_supp.get_action_tabs(item_name) %}
 
 {% block views %}
 
@@ -21,15 +19,7 @@
         {%- for endpoint, label, title, check_exists in cfg.item_views if not endpoint in cfg.endpoints_excluded %}
             {%- if not check_exists or check_exists and exists %}
 
-                {%- if endpoint == 'frontend.modify_item' and user.may.write(item_name) %}
-                    <li {% if endpoint == current_endpoint %} class="active"{% endif %}>
-                        <a href="{{ url_for(endpoint, item_name=item_name) }}" title="{{ title }}" rel="nofollow">
-                         <span class={{icon[endpoint]}}></span>   
-                            {{ label }}
-                        </a>
-                    </li>
-
-                {%- elif endpoint == 'special.comments' %}
+                {%- if endpoint == 'special.comments' %}
                     <li class="moin-toggle-comments-button">
                         <a href="#" title="{{ title }}">
                         <span class={{icon[endpoint]}}></span>