diff MoinMoin/theme/__init__.py @ 3038:07ab9d4b8bb8

bug fix for 1.6.0SupplementationAndAccessRights (thanks to Boleslaw Kulbabinski) (ported from 1.6)
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Sun, 03 Feb 2008 21:55:18 +0100
parents fe0263c5d64c
children 8608b258f8e6
line wrap: on
line diff
--- a/MoinMoin/theme/__init__.py	Sun Feb 03 21:21:52 2008 +0100
+++ b/MoinMoin/theme/__init__.py	Sun Feb 03 21:55:18 2008 +0100
@@ -1107,11 +1107,21 @@
         return editbar_actions
 
     def supplementation_page_nameLink(self, page):
-        """  discussion for page """
+        """Return a link to the discussion page
+
+           If the discussion page doesn't exist and the user
+           has no right to create it, show a disabled link.
+	"""
         _ = self.request.getText
-        return page.link_to(self.request,
-                            text=_(self.request.cfg.supplementation_page_name, formatted=False),
-                            querystr={'action': 'supplementation'}, css_class='nbsupplementation', rel='nofollow')
+        suppl_name = self.request.cfg.supplementation_page_name
+        suppl_name_full = "%s/%s" % (page.page_name, suppl_name)
+
+        test = Page(self.request, suppl_name_full)
+        if not test.exists() and not self.request.user.may.write(suppl_name_full):
+            return ('<span class="disabled">%s</span>' % _(suppl_name, formatted=False))
+        else:
+            return page.link_to(self.request, text=_(suppl_name, formatted=False),
+                                querystr={'action': 'supplementation'}, css_class='nbsupplementation', rel='nofollow')
 
     def guiworks(self, page):
         """ Return whether the gui editor / converter can work for that page.