Skip to content

Commit 3a47901

Browse files
feat: ✨ add subsite package with lineage
1 parent 044d44b commit 3a47901

16 files changed

+219
-4
lines changed

base.cfg

+2
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,11 @@ scripts =
112112

113113
[sources]
114114
cusy.exportimport = git https://github.com/cusyio/cusy.exportimport.git
115+
cusy.patches.cmfplone = git https://github.com/cusyio/cusy.patches.cmfplone.git
115116
cusy.restapi.easyform = git https://github.com/cusyio/cusy.restapi.easyform.git
116117
cusy.restapi.info = git https://github.com/cusyio/cusy.restapi.info.git
117118
cusy.restapi.patches = git https://github.com/cusyio/cusy.restapi.patches.git
119+
lineage.controlpanels = git https://github.com/cusyio/lineage.controlpanels.git branch=features/plone52
118120

119121

120122
[versions]

setup.py

+4
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,13 @@
5353
"collective.easyform",
5454
"collective.lineage",
5555
"cusy.exportimport",
56+
"cusy.patches.cmfplone",
5657
"cusy.restapi.easyform",
5758
"cusy.restapi.info",
5859
"cusy.restapi.patches",
60+
"lineage.controlpanels",
61+
"lineage.registry",
62+
"lineage.themeselection",
5963
"plone.restapi",
6064
],
6165
extras_require={

src/cusy/cms/configure.zcml

+2
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,6 @@
1818
<include file="profiles.zcml" />
1919
<include package=".browser" />
2020

21+
<include package=".packages" />
22+
2123
</configure>

src/cusy/cms/packages/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# -*- coding: utf-8 -*-
2+
"""Cusy CMS packages are sets of add-ons with specific configuration."""

src/cusy/cms/packages/configure.zcml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<configure
2+
xmlns="http://namespaces.zope.org/zope"
3+
i18n_domain="cusy.cms">
4+
5+
<include package=".subsites" />
6+
7+
</configure>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# -*- coding: utf-8 -*-
2+
"""Subsite support for the Cusy CMS using collective.lineage."""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<configure
2+
xmlns="http://namespaces.zope.org/zope"
3+
xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
4+
i18n_domain="cusy.cms">
5+
6+
<include package="collective.lineage" />
7+
<include package="lineage.controlpanels" />
8+
<include package="lineage.registry" />
9+
<include package="lineage.themeselection" />
10+
11+
<genericsetup:registerProfile
12+
name="default"
13+
title="Cusy CMS: Subsites"
14+
directory="profiles/default"
15+
description="Subsite support for the Cusy CMS."
16+
provides="Products.GenericSetup.interfaces.EXTENSION"
17+
post_handler=".setuphandlers.post_install"
18+
/>
19+
20+
<genericsetup:registerProfile
21+
name="uninstall"
22+
title="Cusy CMS: Subsites (uninstall)"
23+
directory="profiles/uninstall"
24+
description="Uninstall cusy.cms.packages.subsites."
25+
provides="Products.GenericSetup.interfaces.EXTENSION"
26+
post_handler=".setuphandlers.uninstall"
27+
/>
28+
29+
<utility
30+
factory=".setuphandlers.HiddenProfiles"
31+
name="cusy.cms.packages.subsites-hiddenprofiles"
32+
/>
33+
34+
</configure>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# -*- coding: utf-8 -*-
2+
"""Module where all interfaces, events and exceptions live."""
3+
4+
from zope.publisher.interfaces.browser import IDefaultBrowserLayer
5+
6+
7+
class ICusyCmsSubsitesLayer(IDefaultBrowserLayer):
8+
"""Marker interface that defines a browser layer."""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<layers>
3+
<layer
4+
name="cusy.cms.packages.subsites"
5+
interface="cusy.cms.packages.subsites.interfaces.ICusyCmsSubsitesLayer"
6+
/>
7+
</layers>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<metadata>
3+
<version>1000</version>
4+
<dependencies>
5+
<dependency>profile-collective.lineage:default</dependency>
6+
<dependency>profile-lineage.controlpanels:default</dependency>
7+
<dependency>profile-lineage.themeselection:default</dependency>
8+
</dependencies>
9+
</metadata>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<layers>
3+
<layer
4+
name="cusy.cms.packages.subsites"
5+
remove="true"
6+
/>
7+
</layers>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# -*- coding: utf-8 -*-
2+
from Products.CMFPlone.interfaces import INonInstallable
3+
from zope.interface import implementer
4+
5+
6+
@implementer(INonInstallable)
7+
class HiddenProfiles(object):
8+
def getNonInstallableProfiles(self):
9+
"""Hide uninstall profile from site-creation and quickinstaller."""
10+
return [
11+
"cusy.cms.packages.subsites:uninstall",
12+
]
13+
14+
def getNonInstallableProducts(self):
15+
"""Hide other products from site-creation and quickinstaller."""
16+
return [
17+
"collective.lineage",
18+
"lineage.controlpanels",
19+
"lineage.registry",
20+
"lineage.themeselection",
21+
]
22+
23+
24+
def post_install(context):
25+
"""Post install script"""
26+
# Do something at the end of the installation of this package.
27+
28+
29+
def uninstall(context):
30+
"""Uninstall script"""
31+
# Do something at the end of the uninstallation of this package.

src/cusy/cms/packages/subsites/tests/__init__.py

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# -*- coding: utf-8 -*-
2+
"""Setup tests for this package."""
3+
from cusy.cms.testing import INTEGRATION_TESTING
4+
from plone import api
5+
from plone.app.testing import setRoles
6+
from plone.app.testing import TEST_USER_ID
7+
8+
import unittest
9+
10+
11+
try:
12+
from Products.CMFPlone.utils import get_installer
13+
except ImportError:
14+
get_installer = None
15+
16+
17+
class TestSetup(unittest.TestCase):
18+
"""Validate that `cusy.cms` is properly installed."""
19+
20+
layer = INTEGRATION_TESTING
21+
22+
def setUp(self):
23+
"""Custom shared utility setup for tests."""
24+
self.portal = self.layer["portal"]
25+
if get_installer:
26+
self.installer = get_installer(self.portal, self.layer["request"])
27+
else:
28+
self.installer = api.portal.get_tool("portal_quickinstaller")
29+
roles_before = api.user.get_roles(TEST_USER_ID)
30+
setRoles(self.portal, TEST_USER_ID, ["Manager"])
31+
self.installer.installProducts(["cusy.cms.packages.subsites"])
32+
setRoles(self.portal, TEST_USER_ID, roles_before)
33+
34+
def test_product_installed(self):
35+
"""Validate that `cusy.cms.packages.subsites` is installed."""
36+
self.assertTrue(self.installer.isProductInstalled("cusy.cms.packages.subsites"))
37+
38+
def test_browserlayer(self):
39+
"""Validate that the browser layer is registered."""
40+
from cusy.cms.packages.subsites.interfaces import ICusyCmsSubsitesLayer
41+
from plone.browserlayer import utils
42+
43+
self.assertIn(ICusyCmsSubsitesLayer, utils.registered_layers())
44+
45+
def test_collective_lineage_installed(self):
46+
"""Validate that `collective.lineage` is installed."""
47+
self.assertTrue(
48+
self.installer.isProductInstalled("collective.lineage"),
49+
)
50+
51+
def test_lineage_controlpanels_installed(self):
52+
"""Validate that `lineage.controlpanels` is installed."""
53+
self.assertTrue(self.installer.isProductInstalled("lineage.controlpanels"))
54+
55+
def test_lineage_registry_installed(self):
56+
"""Validate that `lineage.registry` is installed."""
57+
self.assertTrue(self.installer.isProductInstalled("lineage.registry"))
58+
59+
def test_lineage_themeselection_installed(self):
60+
"""Validate that `lineage.themeselection` is installed."""
61+
self.assertTrue(self.installer.isProductInstalled("lineage.themeselection"))
62+
63+
64+
class TestUninstall(unittest.TestCase):
65+
66+
layer = INTEGRATION_TESTING
67+
68+
def setUp(self):
69+
self.portal = self.layer["portal"]
70+
if get_installer:
71+
self.installer = get_installer(self.portal, self.layer["request"])
72+
else:
73+
self.installer = api.portal.get_tool("portal_quickinstaller")
74+
roles_before = api.user.get_roles(TEST_USER_ID)
75+
setRoles(self.portal, TEST_USER_ID, ["Manager"])
76+
self.installer.installProducts(["cusy.cms.packages.subsites"])
77+
self.installer.uninstallProducts(["cusy.cms.packages.subsites"])
78+
setRoles(self.portal, TEST_USER_ID, roles_before)
79+
80+
def test_product_uninstalled(self):
81+
"""Validate that `cusy.cms.packages.subsites` is cleanly uninstalled."""
82+
self.assertFalse(
83+
self.installer.isProductInstalled("cusy.cms.packages.subsites")
84+
)
85+
86+
def test_browserlayer_removed(self):
87+
"""Validate that the browser layer is removed."""
88+
from cusy.cms.packages.subsites.interfaces import ICusyCmsSubsitesLayer
89+
from plone.browserlayer import utils
90+
91+
self.assertNotIn(ICusyCmsSubsitesLayer, utils.registered_layers())

src/cusy/cms/profiles.zcml

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55

66
<genericsetup:registerProfile
77
name="default"
8-
title="cusy.cms"
8+
title="Cusy CMS"
99
directory="profiles/default"
10-
description="Installs the cusy.cms add-on."
10+
description="Headless CMS based on Plone."
1111
provides="Products.GenericSetup.interfaces.EXTENSION"
1212
post_handler=".setuphandlers.post_install"
1313
/>
1414

1515
<genericsetup:registerProfile
1616
name="uninstall"
17-
title="cusy.cms (uninstall)"
17+
title="Cusy CMS (uninstall)"
1818
directory="profiles/uninstall"
19-
description="Uninstalls the cusy.cms add-on."
19+
description="Uninstall the Cusy CMS."
2020
provides="Products.GenericSetup.interfaces.EXTENSION"
2121
post_handler=".setuphandlers.uninstall"
2222
/>

test_plone52.cfg

+9
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,12 @@ collective.lineage = 2.3
4747
# Required by:
4848
# cusy.exportimport==1.0.0.dev0
4949
collective.relationhelpers = 1.5
50+
51+
# Added by buildout at 2021-07-19 11:35:31.444786
52+
lineage.registry = 1.5
53+
54+
# Added by buildout at 2021-07-19 14:25:56.962780
55+
56+
# Required by:
57+
# cusy.cms==1.0.0.dev0
58+
lineage.themeselection = 2.1

0 commit comments

Comments
 (0)