Updated groups management
authorThierry Florac <thierry.florac@onf.fr>
Thu, 03 May 2018 11:29:56 +0200
changeset 544 6928ddfc1c0f
parent 543 2125a235d3a0
child 545 ae803782cc37
child 650 927afb26b1ce
Updated groups management
src/pyams_content/component/gallery/zmi/file.py
src/pyams_content/component/paragraph/zmi/video.py
src/pyams_content/shared/common/zmi/security.py
--- a/src/pyams_content/component/gallery/zmi/file.py	Thu May 03 11:05:45 2018 +0200
+++ b/src/pyams_content/component/gallery/zmi/file.py	Thu May 03 11:29:56 2018 +0200
@@ -208,6 +208,8 @@
             self.widgets['pif_number'].input_css_class = 'col-md-3'
         if 'sound_description' in self.widgets:
             self.widgets['sound_description'].widget_css_class = 'textarea'
+            
+    def updateGroups(self):
         self.add_group(NamedWidgetsGroup(self, 'audio_file', self.widgets,
                                          ('sound', 'sound_title', 'sound_description'),
                                          bordered=False,
@@ -215,6 +217,7 @@
                                          css_class='inner',
                                          switch=True,
                                          hide_if_empty=True))
+        super(GalleryFilePropertiesEditForm, self).updateGroups()
 
 
 @view_config(name='gallery-file-properties.json', context=IGalleryFile, request_type=IPyAMSLayer,
--- a/src/pyams_content/component/paragraph/zmi/video.py	Thu May 03 11:05:45 2018 +0200
+++ b/src/pyams_content/component/paragraph/zmi/video.py	Thu May 03 11:29:56 2018 +0200
@@ -79,15 +79,18 @@
             self.widgets['description'].widget_css_class = 'textarea'
         if 'body' in self.widgets:
             self.widgets['body'].label = ''
-            self.add_group(NamedWidgetsGroup(self, 'body_group', self.widgets, ('body',),
-                                             bordered=False,
-                                             legend=_("HTML content"),
-                                             css_class='inner switcher padding-right-10 no-y-padding pull-left',
-                                             switch=True,
-                                             hide_if_empty=True))
-            self.add_group(NamedWidgetsGroup(self, 'data_group', self.widgets,
-                                             ('description', 'author', 'data', 'renderer'),
-                                             bordered=False))
+            
+    def updateGroups(self):
+        self.add_group(NamedWidgetsGroup(self, 'body_group', self.widgets, ('body',),
+                                         bordered=False,
+                                         legend=_("HTML content"),
+                                         css_class='inner switcher padding-right-10 no-y-padding pull-left',
+                                         switch=True,
+                                         hide_if_empty=True))
+        self.add_group(NamedWidgetsGroup(self, 'data_group', self.widgets,
+                                         ('description', 'author', 'data', 'renderer'),
+                                         bordered=False))
+        super(VideoParagraphAddForm, self).updateGroups()
 
     def create(self, data):
         return VideoParagraph()
@@ -125,16 +128,19 @@
             self.widgets['description'].widget_css_class = 'textarea'
         if 'body' in self.widgets:
             self.widgets['body'].label = ''
-            self.add_group(NamedWidgetsGroup(self, 'body_group', self.widgets, ('body',),
-                                             bordered=False,
-                                             fieldset_class='margin-top-10 padding-y-5',
-                                             legend=_("HTML content"),
-                                             css_class='inner switcher padding-right-10 no-y-padding pull-left',
-                                             switch=True,
-                                             hide_if_empty=True))
-            self.add_group(NamedWidgetsGroup(self, 'data_group', self.widgets,
-                                             ('description', 'author', 'data', 'renderer'),
-                                             bordered=False))
+            
+    def updateGroups(self):
+        self.add_group(NamedWidgetsGroup(self, 'body_group', self.widgets, ('body',),
+                                         bordered=False,
+                                         fieldset_class='margin-top-10 padding-y-5',
+                                         legend=_("HTML content"),
+                                         css_class='inner switcher padding-right-10 no-y-padding pull-left',
+                                         switch=True,
+                                         hide_if_empty=True))
+        self.add_group(NamedWidgetsGroup(self, 'data_group', self.widgets,
+                                         ('description', 'author', 'data', 'renderer'),
+                                         bordered=False))
+        super(VideoParagraphPropertiesEditForm, self).updateGroups()
 
 
 @view_config(name='properties.json', context=IVideoParagraph, request_type=IPyAMSLayer,
--- a/src/pyams_content/shared/common/zmi/security.py	Thu May 03 11:05:45 2018 +0200
+++ b/src/pyams_content/shared/common/zmi/security.py	Thu May 03 11:29:56 2018 +0200
@@ -209,8 +209,12 @@
             manager_restrictions.set_restrictions(self.principal_id, restrictions)
         return restrictions
 
-    def update(self):
-        super(SharedToolManagerRestrictionsEditForm, self).update()
+    def updateWidgets(self, prefix=None):
+        super(SharedToolManagerRestrictionsEditForm, self).updateWidgets(prefix)
+        self.widgets['principal_id'].value = self.principal
+        self.widgets['principal_id'].mode = HIDDEN_MODE
+
+    def updateGroups(self):
         names = getFieldNamesInOrder(self.interface)
         self.add_group(NamedWidgetsGroup(self, 'restricted_access', self.widgets, names,
                                          legend=_("Apply contents restrictions"),
@@ -221,11 +225,7 @@
                                          switch=True,
                                          checkbox_switch=True,
                                          checkbox_field=self.interface['restricted_contents']))
-
-    def updateWidgets(self, prefix=None):
-        super(SharedToolManagerRestrictionsEditForm, self).updateWidgets(prefix)
-        self.widgets['principal_id'].value = self.principal
-        self.widgets['principal_id'].mode = HIDDEN_MODE
+        super(SharedToolManagerRestrictionsEditForm, self).updateGroups()
 
 
 @view_config(name='manager-restrictions.json', context=IBaseSharedTool, request_type=IPyAMSLayer,