Added condition for message about allowed paragraph types
authorThierry Florac <thierry.florac@onf.fr>
Tue, 28 Nov 2017 17:24:57 +0100
changeset 296 aaf2eac56470
parent 295 fb84bba1880f
child 297 4f385d0a5ce7
Added condition for message about allowed paragraph types
src/pyams_content/component/paragraph/zmi/container.py
--- a/src/pyams_content/component/paragraph/zmi/container.py	Sun Nov 26 09:58:35 2017 +0100
+++ b/src/pyams_content/component/paragraph/zmi/container.py	Tue Nov 28 17:24:57 2017 +0100
@@ -116,11 +116,13 @@
         if not self.values:
             translate = self.request.localizer.translate
             message = translate(_("No currently defined paragraph."))
-            manager = get_parent(self.context, IParagraphFactorySettings)
-            if (manager is not None) and not manager.allowed_paragraphs:
-                message = '{0}<br />{1}'.format(message,
-                                                translate(_("Check allowed paragraph types to be able to create new "
-                                                            "paragraphs.")))
+            permission = self.permission
+            if (not permission) or self.request.has_permission(permission, self.context):
+                manager = get_parent(self.context, IParagraphFactorySettings)
+                if (manager is not None) and not manager.allowed_paragraphs:
+                    message = '{0}<br />{1}'.format(message,
+                                                    translate(_("Check allowed paragraph types to be able to create "
+                                                                "new paragraphs.")))
             return message
         return super(ParagraphContainerBaseTable, self).render()
 
@@ -162,10 +164,10 @@
 
     def get_icon(self, item):
         if item.visible:
-            icon_class = 'fa fa-fw fa-eye'
+            icon_class = 'fa-eye'
         else:
-            icon_class = 'fa fa-fw fa-eye-slash text-danger'
-        return '<i class="{icon_class}"></i>'.format(icon_class=icon_class)
+            icon_class = 'fa-eye-slash text-danger'
+        return '<i class="fa fa-fw {icon_class}"></i>'.format(icon_class=icon_class)
 
     def renderCell(self, item):
         if self.permission and not self.request.has_permission(self.permission, context=item):