merge default doc-dc
authorDamien Correia
Wed, 16 May 2018 14:06:28 +0200
branchdoc-dc
changeset 650 927afb26b1ce
parent 649 06ab962b04c5 (current diff)
parent 544 6928ddfc1c0f (diff)
child 651 26a58877d1aa
merge default
--- a/buildout.cfg	Fri Apr 27 12:00:07 2018 +0200
+++ b/buildout.cfg	Wed May 16 14:06:28 2018 +0200
@@ -92,4 +92,4 @@
 eggs = pyams_content [test]
 
 [versions]
-pyams_content = 0.1.13
+pyams_content = 0.1.14
--- a/setup.py	Fri Apr 27 12:00:07 2018 +0200
+++ b/setup.py	Wed May 16 14:06:28 2018 +0200
@@ -22,7 +22,7 @@
 README = os.path.join(DOCS, 'README.txt')
 HISTORY = os.path.join(DOCS, 'HISTORY.txt')
 
-version = '0.1.13'
+version = '0.1.14'
 long_description = open(README).read() + '\n\n' + open(HISTORY).read()
 
 tests_require = []
--- a/src/pyams_content/component/gallery/zmi/file.py	Fri Apr 27 12:00:07 2018 +0200
+++ b/src/pyams_content/component/gallery/zmi/file.py	Wed May 16 14:06:28 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	Fri Apr 27 12:00:07 2018 +0200
+++ b/src/pyams_content/component/paragraph/zmi/video.py	Wed May 16 14:06:28 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/component/video/zmi/paragraph.py	Fri Apr 27 12:00:07 2018 +0200
+++ b/src/pyams_content/component/video/zmi/paragraph.py	Wed May 16 14:06:28 2018 +0200
@@ -82,15 +82,6 @@
             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', 'provider_name'),
-                                             bordered=False))
         if 'provider_name' in self.widgets:
             widget = self.widgets['provider_name']
             widget.object_data = {
@@ -104,6 +95,19 @@
             }
             alsoProvides(widget, IObjectData)
 
+    def updateGroups(self):
+        if 'body' in self.widgets:
+            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', 'provider_name'),
+                                             bordered=False))
+        super(ExternalVideoParagraphAddForm, self).updateGroups()
+
     def create(self, data):
         return ExternalVideoParagraph()
 
@@ -147,6 +151,32 @@
     """External video settings edit form widgets suffix"""
 
 
+class ExternalVideoProviderSettingsAddForm(InnerAdminAddForm):
+    """External video provider settings add form"""
+
+    def __init__(self, context, request, provider):
+        super(ExternalVideoProviderSettingsAddForm, self).__init__(context, request)
+        self.provider = provider
+
+    def updateGroups(self):
+        if 'integration_code' in self.widgets:  # custom video provider
+            self.widgets['integration_code'].widget_css_class = 'textarea'
+            self.add_group(NamedWidgetsGroup(self, 'integration_code', self.widgets, ('integration_code', ),
+                                             bordered=False))
+        elif 'video_id' in self.widgets:
+            self.add_group(NamedWidgetsGroup(self, 'video_id', self.widgets, ('video_id', ), bordered=False))
+        field_names = getFieldNamesInOrder(self.provider.settings_interface)
+        if len(field_names) > 1:
+            self.add_group(NamedWidgetsGroup(self, 'provider_group', self.widgets,
+                                             field_names[1:],
+                                             bordered=False,
+                                             legend=_("Other settings"),
+                                             css_class="inner switcher padding-right-10 no-y-padding",
+                                             switch=True,
+                                             hide_if_empty=True))
+        super(ExternalVideoProviderSettingsAddForm, self).updateGroups()
+
+
 @view_config(name='get-video-provider-settings-add-form.html', context=IParagraphContainerTarget,
              request_type=IPyAMSLayer, permission=MANAGE_CONTENT_PERMISSION, xhr=True)
 def external_video_provider_settings_add_form(request):
@@ -158,28 +188,13 @@
         return Response('')
     else:
         provider = get_utility(IExternalVideoProvider, name=provider_name)
-        form = InnerAdminAddForm(request.context, request)
+        form = ExternalVideoProviderSettingsAddForm(request.context, request, provider)
         form.prefix = ExternalVideoParagraphAddForm.prefix
         form.legend = request.localizer.translate(_("Video provider settings"))
         form.label_css_class = 'control-label col-md-4'
         form.input_css_class = 'col-md-8'
         form.fields = field.Fields(provider.settings_interface)
         form.update()
-        if 'integration_code' in form.widgets:  # custom video provider
-            form.widgets['integration_code'].widget_css_class = 'textarea'
-            form.add_group(NamedWidgetsGroup(form, 'integration_code', form.widgets, ('integration_code', ),
-                                             bordered=False))
-        elif 'video_id' in form.widgets:
-            form.add_group(NamedWidgetsGroup(form, 'video_id', form.widgets, ('video_id', ), bordered=False))
-        field_names = getFieldNamesInOrder(provider.settings_interface)
-        if len(field_names) > 1:
-            form.add_group(NamedWidgetsGroup(form, 'provider_group', form.widgets,
-                                             field_names[1:],
-                                             bordered=False,
-                                             legend=_("Other settings"),
-                                             css_class="inner switcher padding-right-10 no-y-padding",
-                                             switch=True,
-                                             hide_if_empty=True))
         return Response(form.render())
 
 
@@ -210,6 +225,11 @@
             self.widgets['description'].widget_css_class = 'textarea'
         if 'body' in self.widgets:
             self.widgets['body'].label = ''
+        if 'provider_name' in self.widgets:
+            self.widgets['provider_name'].mode = DISPLAY_MODE
+
+    def updateGroups(self):
+        if 'body' in self.widgets:
             self.add_group(NamedWidgetsGroup(self, 'body_group', self.widgets, ('body',),
                                              bordered=False,
                                              fieldset_class='margin-top-10 padding-y-5',
@@ -221,7 +241,6 @@
                                              ('description', 'author', 'provider_name'),
                                              bordered=False))
         if 'provider_name' in self.widgets:
-            self.widgets['provider_name'].mode = DISPLAY_MODE
             provider = self.context.get_provider()
             if provider is not None:
                 if 'integration_code' in self.widgets:  # custom video provider
--- a/src/pyams_content/shared/common/zmi/security.py	Fri Apr 27 12:00:07 2018 +0200
+++ b/src/pyams_content/shared/common/zmi/security.py	Wed May 16 14:06:28 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,