Manage Google Analytics and UserReport services
authorThierry Florac <thierry.florac@onf.fr>
Wed, 15 Jun 2016 12:43:54 +0200
changeset 18 6d1fb0659e7a
parent 17 009454f127d7
child 19 92e1f675035c
Manage Google Analytics and UserReport services
src/pyams_zmi/extension.py
src/pyams_zmi/locales/fr/LC_MESSAGES/pyams_zmi.mo
src/pyams_zmi/locales/fr/LC_MESSAGES/pyams_zmi.po
src/pyams_zmi/locales/pyams_zmi.pot
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_zmi/extension.py	Wed Jun 15 12:43:54 2016 +0200
@@ -0,0 +1,107 @@
+#
+# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+
+# import standard library
+
+# import interfaces
+from pyams_skin.interfaces.extension import IGoogleAnalyticsInfo, IUserReportInfo
+from pyams_skin.layer import IPyAMSLayer
+from pyams_utils.interfaces import MANAGE_SYSTEM_PERMISSION
+from pyams_utils.interfaces.site import ISiteRoot
+from pyams_zmi.interfaces.menu import IPropertiesMenu
+from pyams_zmi.layer import IAdminLayer
+
+# import packages
+from pyams_form.form import AJAXEditForm
+from pyams_pagelet.pagelet import pagelet_config
+from pyams_skin.viewlet.menu import MenuItem
+from pyams_viewlet.viewlet import viewlet_config
+from pyams_zmi.form import AdminDialogEditForm
+from pyramid.view import view_config
+from z3c.form import field
+
+from pyams_zmi import _
+
+
+#
+# Google Analytics views
+#
+
+@viewlet_config(name='analytics-properties.menu', context=ISiteRoot, layer=IAdminLayer, manager=IPropertiesMenu,
+                permission=MANAGE_SYSTEM_PERMISSION, weight=10)
+class GoogleAnalyticsPropertiesMenuItem(MenuItem):
+    """Google Analytics properties menu"""
+
+    label = _("Google Analytics...")
+    icon_class = 'fa-line-chart'
+    url = 'analytics-properties.html'
+    modal_target = True
+
+
+@pagelet_config(name='analytics-properties.html', context=ISiteRoot, layer=IPyAMSLayer,
+                permission=MANAGE_SYSTEM_PERMISSION)
+class GoogleAnalyticsPropertiesEditForm(AdminDialogEditForm):
+    """Google Analytics properties edit form"""
+
+    legend = _("Update Google Analytics properties")
+    ajax_handler = 'analytics-properties.json'
+    edit_permission = MANAGE_SYSTEM_PERMISSION
+
+    fields = field.Fields(IGoogleAnalyticsInfo)
+
+    label_css_class = 'control-label col-md-4'
+    input_css_class = 'col-md-8'
+
+
+@view_config(name='analytics-properties.json', context=ISiteRoot, request_type=IPyAMSLayer,
+             permission=MANAGE_SYSTEM_PERMISSION, renderer='json', xhr=True)
+class GoogleAnalyticsPropertiesAJAXEditForm(AJAXEditForm, GoogleAnalyticsPropertiesEditForm):
+    """Google Analytics properties edit form, JSON renderer"""
+
+
+#
+# UserReport views
+#
+
+@viewlet_config(name='user-report.menu', context=ISiteRoot, layer=IAdminLayer, manager=IPropertiesMenu,
+                permission=MANAGE_SYSTEM_PERMISSION, weight=20)
+class UserReportPropertiesMenuItem(MenuItem):
+    """UserReport properties menu"""
+
+    label = _("UserReport settings...")
+    icon_class = 'fa-comments'
+    url = 'user-report.html'
+    modal_target = True
+
+
+@pagelet_config(name='user-report.html', context=ISiteRoot, layer=IPyAMSLayer,
+                permission=MANAGE_SYSTEM_PERMISSION)
+class UserReportPropertiesEditForm(AdminDialogEditForm):
+    """UserReport properties edit form"""
+
+    legend = _("Update UserReport service properties")
+    ajax_handler = 'user-report.json'
+    edit_permission = MANAGE_SYSTEM_PERMISSION
+
+    fields = field.Fields(IUserReportInfo)
+
+    label_css_class = 'control-label col-md-4'
+    input_css_class = 'col-md-8'
+
+
+@view_config(name='user-report.json', context=ISiteRoot, request_type=IPyAMSLayer,
+             permission=MANAGE_SYSTEM_PERMISSION, renderer='json', xhr=True)
+class UserReportPropertiesAJAXEditForm(AJAXEditForm, UserReportPropertiesEditForm):
+    """UserReport properties edit form, JSON renderer"""
Binary file src/pyams_zmi/locales/fr/LC_MESSAGES/pyams_zmi.mo has changed
--- a/src/pyams_zmi/locales/fr/LC_MESSAGES/pyams_zmi.po	Wed Jun 15 12:43:34 2016 +0200
+++ b/src/pyams_zmi/locales/fr/LC_MESSAGES/pyams_zmi.po	Wed Jun 15 12:43:54 2016 +0200
@@ -5,7 +5,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE 1.0\n"
-"POT-Creation-Date: 2015-09-23 11:15+0200\n"
+"POT-Creation-Date: 2016-06-15 11:29+0200\n"
 "PO-Revision-Date: 2015-02-04 09:50+0100\n"
 "Last-Translator: Thierry Florac <tflorac@ulthar.net>\n"
 "Language-Team: French <traduc@traduc.org>\n"
@@ -33,8 +33,7 @@
 msgstr "Supprimer cet utilitaire"
 
 #: src/pyams_zmi/control_panel.py:118 src/pyams_zmi/control_panel.py:248
-#: src/pyams_zmi/control_panel.py:312
-#: src/pyams_zmi/viewlet/menu/__init__.py:60
+#: src/pyams_zmi/control_panel.py:312 src/pyams_zmi/viewlet/menu/__init__.py:60
 msgid "Control panel"
 msgstr "Panneau de configuration"
 
@@ -138,6 +137,22 @@
 msgid "Update site back-office properties"
 msgstr "Mise à jour des propriétés du back-office du site"
 
+#: src/pyams_zmi/extension.py:47
+msgid "Google Analytics..."
+msgstr "Google Analytics..."
+
+#: src/pyams_zmi/extension.py:58
+msgid "Update Google Analytics properties"
+msgstr "Mise à jour des propriétés Google Analytics"
+
+#: src/pyams_zmi/extension.py:83
+msgid "UserReport settings..."
+msgstr "UserReport..."
+
+#: src/pyams_zmi/extension.py:94
+msgid "Update UserReport service properties"
+msgstr "Mise à jour des propriétés du service UserReport"
+
 #: src/pyams_zmi/viewlet/menu/__init__.py:40
 msgid "Content management"
 msgstr "Suivre l'activité"
--- a/src/pyams_zmi/locales/pyams_zmi.pot	Wed Jun 15 12:43:34 2016 +0200
+++ b/src/pyams_zmi/locales/pyams_zmi.pot	Wed Jun 15 12:43:54 2016 +0200
@@ -1,12 +1,12 @@
 # 
 # SOME DESCRIPTIVE TITLE
 # This file is distributed under the same license as the PACKAGE package.
-# FIRST AUTHOR <EMAIL@ADDRESS>, 2015.
+# FIRST AUTHOR <EMAIL@ADDRESS>, 2016.
 #, fuzzy
 msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE 1.0\n"
-"POT-Creation-Date: 2015-09-23 11:15+0200\n"
+"POT-Creation-Date: 2016-06-15 11:29+0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -120,6 +120,22 @@
 msgid "Update site back-office properties"
 msgstr ""
 
+#: ./src/pyams_zmi/extension.py:47
+msgid "Google Analytics..."
+msgstr ""
+
+#: ./src/pyams_zmi/extension.py:58
+msgid "Update Google Analytics properties"
+msgstr ""
+
+#: ./src/pyams_zmi/extension.py:83
+msgid "UserReport settings..."
+msgstr ""
+
+#: ./src/pyams_zmi/extension.py:94
+msgid "Update UserReport service properties"
+msgstr ""
+
 #: ./src/pyams_zmi/viewlet/menu/__init__.py:40
 msgid "Content management"
 msgstr ""