Skip to content

Commit 03476ef

Browse files
committed
feat: add an optional link to statistics browserview in user menu
1 parent 91fdd0a commit 03476ef

File tree

18 files changed

+283
-45
lines changed

18 files changed

+283
-45
lines changed

src/collective/plausible/configure.zcml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@
4242

4343
<!-- -*- extra stuff goes here -*- -->
4444

45-
<include package=".controlpanels" />
45+
<include package=".upgrades" />
46+
47+
<include package=".controlpanels" />
4648

4749

4850
<include package=".views" />

src/collective/plausible/controlpanels/plausible_control_panel/controlpanel.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ class IPlausibleControlPanel(Interface):
3535
readonly=False,
3636
)
3737

38+
link_user_action = schema.Bool(
39+
title=_("Add a link in the user menu"),
40+
description=_("Add a link to the statistics browser view in the user menu"),
41+
default=True,
42+
required=False,
43+
readonly=False,
44+
)
45+
3846

3947
class PlausibleControlPanel(RegistryEditForm):
4048
schema = IPlausibleControlPanel

src/collective/plausible/locales/collective.plausible.pot

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
msgid ""
55
msgstr ""
66
"Project-Id-Version: PACKAGE VERSION\n"
7-
"POT-Creation-Date: 2024-02-15 06:13+0000\n"
7+
"POT-Creation-Date: 2024-02-17 11:10+0000\n"
88
"PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n"
99
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1010
"Language-Team: LANGUAGE <[email protected]>\n"
@@ -17,51 +17,66 @@ msgstr ""
1717
"Preferred-Encodings: utf-8 latin1\n"
1818
"Domain: collective.plausible\n"
1919

20-
#: collective/plausible/controlpanels/plausible_control_panel/controlpanel.py:24
20+
#: ../controlpanels/plausible_control_panel/controlpanel.py:39
21+
#: ../upgrades/v1001.py:19
22+
msgid "Add a link in the user menu"
23+
msgstr ""
24+
25+
#: ../controlpanels/plausible_control_panel/controlpanel.py:40
26+
#: ../upgrades/v1001.py:20
27+
msgid "Add a link to the statistics browser view in the user menu"
28+
msgstr ""
29+
30+
#: ../controlpanels/plausible_control_panel/controlpanel.py:24
2131
msgid "Example : imio.be"
2232
msgstr ""
2333

24-
#: collective/plausible/controlpanels/plausible_control_panel/controlpanel.py:16
34+
#: ../controlpanels/plausible_control_panel/controlpanel.py:16
2535
msgid "Example : plausible.imio.be"
2636
msgstr ""
2737

28-
#: collective/plausible/configure.zcml:27
38+
#: ../configure.zcml:27
2939
msgid "Installs the collective.plausible add-on."
3040
msgstr ""
3141

32-
#: collective/plausible/controlpanels/plausible_control_panel/controlpanel.py:42
33-
#: collective/plausible/profiles/default/controlpanel.xml
42+
#: ../controlpanels/plausible_control_panel/controlpanel.py:50
43+
#: ../profiles/default/controlpanel.xml
3444
msgid "Plausible Control Panel"
3545
msgstr ""
3646

37-
#: collective/plausible/controlpanels/plausible_control_panel/controlpanel.py:23
47+
#: ../controlpanels/plausible_control_panel/controlpanel.py:23
3848
msgid "Plausible Site"
3949
msgstr ""
4050

41-
#: collective/plausible/controlpanels/plausible_control_panel/controlpanel.py:15
51+
#: ../controlpanels/plausible_control_panel/controlpanel.py:15
4252
msgid "Plausible URL"
4353
msgstr ""
4454

45-
#: collective/plausible/views/plausible_view.pt:43
55+
#: ../views/plausible_view.pt:43
4656
msgid "Plausible analytics is not set"
4757
msgstr ""
4858

49-
#: collective/plausible/controlpanels/plausible_control_panel/controlpanel.py:32
59+
#: ../controlpanels/plausible_control_panel/controlpanel.py:32
5060
msgid "Plausible authentification token"
5161
msgstr ""
5262

53-
#: collective/plausible/controlpanels/plausible_control_panel/controlpanel.py:31
63+
#: ../controlpanels/plausible_control_panel/controlpanel.py:31
5464
msgid "Plausible token"
5565
msgstr ""
5666

57-
#: collective/plausible/configure.zcml:36
67+
#: ../profiles/default/actions.xml
68+
#: ../upgrades/1001/actions.xml
69+
msgid "Statistics"
70+
msgstr ""
71+
72+
#: ../configure.zcml:36
5873
msgid "Uninstalls the collective.plausible add-on."
5974
msgstr ""
6075

61-
#: collective/plausible/configure.zcml:27
76+
#: ../configure.zcml:27
6277
msgid "collective.plausible"
6378
msgstr ""
6479

65-
#: collective/plausible/configure.zcml:36
80+
#: ../configure.zcml:36
6681
msgid "collective.plausible (uninstall)"
6782
msgstr ""
Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
msgid ""
22
msgstr ""
33
"Project-Id-Version: PACKAGE VERSION\n"
4-
"POT-Creation-Date: 2024-02-15 06:02+0000\n"
4+
"POT-Creation-Date: 2024-02-17 11:10+0000\n"
55
"PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n"
66
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
77
"Language-Team: LANGUAGE <[email protected]>\n"
@@ -14,51 +14,66 @@ msgstr ""
1414
"Preferred-Encodings: utf-8 latin1\n"
1515
"Domain: DOMAIN\n"
1616

17-
#: collective/plausible/controlpanels/plausible_control_panel/controlpanel.py:24
17+
#: ../controlpanels/plausible_control_panel/controlpanel.py:39
18+
#: ../upgrades/v1001.py:19
19+
msgid "Add a link in the user menu"
20+
msgstr ""
21+
22+
#: ../controlpanels/plausible_control_panel/controlpanel.py:40
23+
#: ../upgrades/v1001.py:20
24+
msgid "Add a link to the statistics browser view in the user menu"
25+
msgstr ""
26+
27+
#: ../controlpanels/plausible_control_panel/controlpanel.py:24
1828
msgid "Example : imio.be"
1929
msgstr ""
2030

21-
#: collective/plausible/controlpanels/plausible_control_panel/controlpanel.py:16
31+
#: ../controlpanels/plausible_control_panel/controlpanel.py:16
2232
msgid "Example : plausible.imio.be"
2333
msgstr ""
2434

25-
#: collective/plausible/configure.zcml:27
35+
#: ../configure.zcml:27
2636
msgid "Installs the collective.plausible add-on."
2737
msgstr ""
2838

29-
#: collective/plausible/controlpanels/plausible_control_panel/controlpanel.py:42
30-
#: collective/plausible/profiles/default/controlpanel.xml
39+
#: ../controlpanels/plausible_control_panel/controlpanel.py:50
40+
#: ../profiles/default/controlpanel.xml
3141
msgid "Plausible Control Panel"
3242
msgstr ""
3343

34-
#: collective/plausible/controlpanels/plausible_control_panel/controlpanel.py:23
44+
#: ../controlpanels/plausible_control_panel/controlpanel.py:23
3545
msgid "Plausible Site"
3646
msgstr ""
3747

38-
#: collective/plausible/controlpanels/plausible_control_panel/controlpanel.py:15
48+
#: ../controlpanels/plausible_control_panel/controlpanel.py:15
3949
msgid "Plausible URL"
4050
msgstr ""
4151

42-
#: collective/plausible/views/plausible_view.pt:43
52+
#: ../views/plausible_view.pt:43
4353
msgid "Plausible analytics is not set"
4454
msgstr ""
4555

46-
#: collective/plausible/controlpanels/plausible_control_panel/controlpanel.py:32
56+
#: ../controlpanels/plausible_control_panel/controlpanel.py:32
4757
msgid "Plausible authentification token"
4858
msgstr ""
4959

50-
#: collective/plausible/controlpanels/plausible_control_panel/controlpanel.py:31
60+
#: ../controlpanels/plausible_control_panel/controlpanel.py:31
5161
msgid "Plausible token"
5262
msgstr ""
5363

54-
#: collective/plausible/configure.zcml:36
64+
#: ../profiles/default/actions.xml
65+
#: ../upgrades/1001/actions.xml
66+
msgid "Statistics"
67+
msgstr ""
68+
69+
#: ../configure.zcml:36
5570
msgid "Uninstalls the collective.plausible add-on."
5671
msgstr ""
5772

58-
#: collective/plausible/configure.zcml:27
73+
#: ../configure.zcml:27
5974
msgid "collective.plausible"
6075
msgstr ""
6176

62-
#: collective/plausible/configure.zcml:36
77+
#: ../configure.zcml:36
6378
msgid "collective.plausible (uninstall)"
6479
msgstr ""
Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
msgid ""
22
msgstr ""
33
"Project-Id-Version: PACKAGE VERSION\n"
4-
"POT-Creation-Date: 2024-02-15 06:02+0000\n"
4+
"POT-Creation-Date: 2024-02-17 11:10+0000\n"
55
"PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n"
66
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
77
"Language-Team: LANGUAGE <[email protected]>\n"
@@ -14,51 +14,66 @@ msgstr ""
1414
"Preferred-Encodings: utf-8 latin1\n"
1515
"Domain: DOMAIN\n"
1616

17-
#: collective/plausible/controlpanels/plausible_control_panel/controlpanel.py:24
17+
#: ../controlpanels/plausible_control_panel/controlpanel.py:39
18+
#: ../upgrades/v1001.py:19
19+
msgid "Add a link in the user menu"
20+
msgstr "Ajouter un lien dans le menu utilisateur"
21+
22+
#: ../controlpanels/plausible_control_panel/controlpanel.py:40
23+
#: ../upgrades/v1001.py:20
24+
msgid "Add a link to the statistics browser view in the user menu"
25+
msgstr "Ajouter un lien vers la vue des statistiques dans le menu utilisateur"
26+
27+
#: ../controlpanels/plausible_control_panel/controlpanel.py:24
1828
msgid "Example : imio.be"
1929
msgstr "Exemple : imio.be"
2030

21-
#: collective/plausible/controlpanels/plausible_control_panel/controlpanel.py:16
31+
#: ../controlpanels/plausible_control_panel/controlpanel.py:16
2232
msgid "Example : plausible.imio.be"
2333
msgstr "Exemple : plausible.imio.be"
2434

25-
#: collective/plausible/configure.zcml:27
35+
#: ../configure.zcml:27
2636
msgid "Installs the collective.plausible add-on."
2737
msgstr "Installe le module collective.plausible."
2838

29-
#: collective/plausible/controlpanels/plausible_control_panel/controlpanel.py:42
30-
#: collective/plausible/profiles/default/controlpanel.xml
39+
#: ../controlpanels/plausible_control_panel/controlpanel.py:50
40+
#: ../profiles/default/controlpanel.xml
3141
msgid "Plausible Control Panel"
3242
msgstr "Panneau de configuration Plausible"
3343

34-
#: collective/plausible/controlpanels/plausible_control_panel/controlpanel.py:23
44+
#: ../controlpanels/plausible_control_panel/controlpanel.py:23
3545
msgid "Plausible Site"
3646
msgstr "Site Plausible"
3747

38-
#: collective/plausible/controlpanels/plausible_control_panel/controlpanel.py:15
48+
#: ../controlpanels/plausible_control_panel/controlpanel.py:15
3949
msgid "Plausible URL"
4050
msgstr "URL de l'instance Plausible"
4151

42-
#: collective/plausible/views/plausible_view.pt:43
52+
#: ../views/plausible_view.pt:43
4353
msgid "Plausible analytics is not set"
4454
msgstr "Plausible analytics n'est pas configuré"
4555

46-
#: collective/plausible/controlpanels/plausible_control_panel/controlpanel.py:32
56+
#: ../controlpanels/plausible_control_panel/controlpanel.py:32
4757
msgid "Plausible authentification token"
4858
msgstr "Token d'authentification Plausible"
4959

50-
#: collective/plausible/controlpanels/plausible_control_panel/controlpanel.py:31
60+
#: ../controlpanels/plausible_control_panel/controlpanel.py:31
5161
msgid "Plausible token"
5262
msgstr "Token Plausible"
5363

54-
#: collective/plausible/configure.zcml:36
64+
#: ../profiles/default/actions.xml
65+
#: ../upgrades/1001/actions.xml
66+
msgid "Statistics"
67+
msgstr "Statistiques"
68+
69+
#: ../configure.zcml:36
5570
msgid "Uninstalls the collective.plausible add-on."
5671
msgstr "Désinstalle le module collective.plausible."
5772

58-
#: collective/plausible/configure.zcml:27
73+
#: ../configure.zcml:27
5974
msgid "collective.plausible"
6075
msgstr "collective.plausible"
6176

62-
#: collective/plausible/configure.zcml:36
77+
#: ../configure.zcml:36
6378
msgid "collective.plausible (uninstall)"
6479
msgstr "collective.plausible (désinstallation)"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0"?>
2+
<object name="portal_actions" meta_type="Plone Actions Tool"
3+
xmlns:i18n="http://xml.zope.org/namespaces/i18n">
4+
<object meta_type="CMF Action Category" name="user">
5+
<object meta_type="CMF Action" name="statistics" i18n:domain="collective.plausible">
6+
<property name="title" i18n:translate="">Statistics</property>
7+
<property name="description" i18n:translate=""/>
8+
<property name="url_expr">string:$portal_url/@@plausible-view</property>
9+
<property name="icon_expr">string:activity</property>
10+
<property name="available_expr">python: portal.restrictedTraverse('@@plausible-utils/is_plausible_set')() and portal.restrictedTraverse('@@plausible-utils/add_link_user_action')()</property>
11+
<property name="permissions">
12+
<element value="Add portal content"/>
13+
</property>
14+
<property name="visible">True</property>
15+
</object>
16+
</object>
17+
</object>

src/collective/plausible/profiles/default/metadata.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
1+
<?xml version='1.0' encoding='UTF-8'?>
22
<metadata>
3-
<version>1000</version>
3+
<version>1001</version>
44
<dependencies>
55
<!--<dependency>profile-plone.app.dexterity:default</dependency>-->
66
</dependencies>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# -*- coding: utf-8 -*-
2+
from plone.app.testing import setRoles
3+
from plone.app.testing import TEST_USER_ID
4+
from Products.CMFCore.utils import getToolByName
5+
6+
# from collective.plausible.testing import COLLECTIVE_PLAUSIBLE_FUNCTIONAL_TESTING
7+
from collective.plausible.testing import COLLECTIVE_PLAUSIBLE_INTEGRATION_TESTING
8+
9+
import unittest
10+
11+
12+
class UpgradeStepIntegrationTest(unittest.TestCase):
13+
14+
layer = COLLECTIVE_PLAUSIBLE_INTEGRATION_TESTING
15+
16+
def setUp(self):
17+
self.portal = self.layer["portal"]
18+
setRoles(self.portal, TEST_USER_ID, ["Manager"])
19+
20+
def test_upgrade_step(self):
21+
portal_setup = getToolByName(self.portal, "portal_setup")
22+
portal_setup.runAllImportStepsFromProfile("collective.plausible:default")
23+
actions_tool = getToolByName(self.portal, "portal_actions")
24+
action_ids = actions_tool["user"].objectIds()
25+
self.assertIn("statistics", action_ids)
26+
27+
28+
# class UpgradeStepFunctionalTest(unittest.TestCase):
29+
#
30+
# layer = COLLECTIVE_PLAUSIBLE_FUNCTIONAL_TESTING
31+
#
32+
# def setUp(self):
33+
# self.portal = self.layer['portal']
34+
# setRoles(self.portal, TEST_USER_ID, ['Manager'])
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<configure xmlns="http://namespaces.zope.org/zope"
2+
xmlns:gs="http://namespaces.zope.org/genericsetup">
3+
4+
<gs:registerProfile name="1001"
5+
title="Add action linking to @@plausible-view"
6+
directory="1001"
7+
description='Configuration for version 1001'
8+
for="Products.CMFPlone.interfaces.IMigratingPloneSiteRoot"
9+
provides="Products.GenericSetup.interfaces.EXTENSION" />
10+
11+
<gs:upgradeSteps source="1000"
12+
destination="1001"
13+
profile="collective.plausible:default">
14+
15+
<gs:upgradeStep title="Add action linking to @@plausible-view"
16+
description=""
17+
handler=".v1001.upgrade" />
18+
19+
<gs:upgradeDepends title="Add action linking to @@plausible-view (GS profile)"
20+
description=""
21+
import_profile="collective.plausible.upgrades:1001" />
22+
23+
</gs:upgradeSteps>
24+
25+
</configure>

src/collective/plausible/upgrades/1001/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)