Added Google Tag Extension management interface
authorThierry Florac <tflorac@ulthar.net>
Sun, 26 Nov 2017 10:19:55 +0100
changeset 39 d3f8e3fbe41d
parent 38 144116280b8c
child 40 e7c76c201111
Added Google Tag Extension management interface
src/pyams_zmi/extension.py
--- a/src/pyams_zmi/extension.py	Sun Nov 26 10:18:43 2017 +0100
+++ b/src/pyams_zmi/extension.py	Sun Nov 26 10:19:55 2017 +0100
@@ -16,7 +16,7 @@
 # import standard library
 
 # import interfaces
-from pyams_skin.interfaces.extension import IGoogleAnalyticsInfo, IUserReportInfo
+from pyams_skin.interfaces.extension import IGoogleTagManagerInfo, IGoogleAnalyticsInfo, IUserReportInfo
 from pyams_skin.layer import IPyAMSLayer
 from pyams_utils.interfaces import MANAGE_SYSTEM_PERMISSION
 from pyams_utils.interfaces.site import ISiteRoot
@@ -36,11 +36,47 @@
 
 
 #
+# Google Tag Manager views
+#
+
+@viewlet_config(name='tag-manager-properties.menu', context=ISiteRoot, layer=IAdminLayer, manager=IPropertiesMenu,
+                permission=MANAGE_SYSTEM_PERMISSION, weight=10)
+class GoogleTagManagerPropertiesMenuItem(MenuItem):
+    """Google Tag Manager properties menu"""
+
+    label = _("Google Tag Manager...")
+    icon_class = 'fa-tags'
+    url = 'tag-manager-properties.html'
+    modal_target = True
+
+
+@pagelet_config(name='tag-manager-properties.html', context=ISiteRoot, layer=IPyAMSLayer,
+                permission=MANAGE_SYSTEM_PERMISSION)
+class GoogleTagManagerPropertiesEditForm(AdminDialogEditForm):
+    """Google Tag Manager properties edit form"""
+
+    legend = _("Update Google Tag Manager properties")
+    ajax_handler = 'tag-manager-properties.json'
+    edit_permission = MANAGE_SYSTEM_PERMISSION
+
+    fields = field.Fields(IGoogleTagManagerInfo)
+
+    label_css_class = 'control-label col-md-4'
+    input_css_class = 'col-md-8'
+
+
+@view_config(name='tag-manager-properties.json', context=ISiteRoot, request_type=IPyAMSLayer,
+             permission=MANAGE_SYSTEM_PERMISSION, renderer='json', xhr=True)
+class GoogleTagManagerPropertiesAJAXEditForm(AJAXEditForm, GoogleTagManagerPropertiesEditForm):
+    """Google Tag Manager properties edit form, JSON renderer"""
+
+
+#
 # Google Analytics views
 #
 
 @viewlet_config(name='analytics-properties.menu', context=ISiteRoot, layer=IAdminLayer, manager=IPropertiesMenu,
-                permission=MANAGE_SYSTEM_PERMISSION, weight=10)
+                permission=MANAGE_SYSTEM_PERMISSION, weight=15)
 class GoogleAnalyticsPropertiesMenuItem(MenuItem):
     """Google Analytics properties menu"""