Handle Facebook verification API
authorThierry Florac <tflorac@ulthar.net>
Tue, 13 Jul 2021 08:04:36 +0200
changeset 123 c38e2021bf43
parent 122 3b687562eac0
child 124 329da6d8e159
Handle Facebook verification API
src/pyams_zmi/zmi/extension.py
--- a/src/pyams_zmi/zmi/extension.py	Tue Jul 13 08:04:20 2021 +0200
+++ b/src/pyams_zmi/zmi/extension.py	Tue Jul 13 08:04:36 2021 +0200
@@ -18,7 +18,8 @@
 from pyams_form.form import ajax_config
 from pyams_form.group import NamedWidgetsGroup
 from pyams_pagelet.pagelet import pagelet_config
-from pyams_skin.interfaces.extension import IGoogleAnalyticsInfo, IGoogleTagManagerInfo, IUserReportInfo
+from pyams_skin.interfaces.extension import IFacebookSiteInfo, IGoogleAnalyticsInfo, \
+    IGoogleTagManagerInfo, IUserReportInfo
 from pyams_skin.layer import IPyAMSLayer
 from pyams_skin.viewlet.menu import MenuDivider, MenuItem
 from pyams_utils.interfaces import MANAGE_SYSTEM_PERMISSION
@@ -178,3 +179,35 @@
         self.add_group(NamedWidgetsGroup(self, 'account_id', self.widgets,
                                          ('account_id', 'activation_mode')))
         super(UserReportPropertiesEditForm, self).updateGroups()
+
+
+#
+# Facebook views
+#
+
+@viewlet_config(name='facebook.menu', context=ISiteRoot, layer=IAdminLayer,
+                manager=IPropertiesMenu, permission=MANAGE_SYSTEM_PERMISSION, weight=830)
+class FacebookPropertiesMenuItem(MenuItem):
+    """UserReport properties menu"""
+
+    label = _("Facebook settings...")
+    icon_class = 'fa-facebook'
+    url = 'facebook-properties.html'
+    modal_target = True
+
+
+@pagelet_config(name='facebook-properties.html', context=ISiteRoot, layer=IPyAMSLayer,
+                permission=MANAGE_SYSTEM_PERMISSION)
+@ajax_config(name='facebook-properties.json', context=ISiteRoot, layer=IPyAMSLayer)
+class FacebookPropertiesEditForm(AdminDialogEditForm):
+    """Facebook properties edit form"""
+
+    prefix = 'facebook_properties.'
+
+    legend = _("Update Facebook application properties")
+    edit_permission = MANAGE_SYSTEM_PERMISSION
+
+    fields = field.Fields(IFacebookSiteInfo)
+
+    label_css_class = 'control-label col-md-4'
+    input_css_class = 'col-md-8'