-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into add_getobjsize_info_in_serializer
- Loading branch information
Showing
20 changed files
with
324 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 0 additions & 30 deletions
30
...plone/contenttypes/browser/overrides/plone.app.contenttypes.browser.templates.newsitem.pt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
name="Document" | ||
i18n:domain="plone" | ||
> | ||
|
||
<property name="behaviors" | ||
purge="False" | ||
> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
<element value="File" /> | ||
|
||
</property> | ||
|
||
<property name="behaviors" | ||
purge="False" | ||
> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
22 changes: 22 additions & 0 deletions
22
src/design/plone/contenttypes/restapi/services/navigation/configure.zcml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<configure | ||
xmlns="http://namespaces.zope.org/zope" | ||
xmlns:cache="http://namespaces.zope.org/cache" | ||
xmlns:plone="http://namespaces.plone.org/plone" | ||
xmlns:zcml="http://namespaces.zope.org/zcml" | ||
> | ||
|
||
<adapter | ||
factory=".get.Navigation" | ||
name="navigation" | ||
/> | ||
|
||
<plone:service | ||
method="GET" | ||
factory=".get.NavigationGet" | ||
for="zope.interface.Interface" | ||
permission="zope2.View" | ||
layer="design.plone.contenttypes.interfaces.IDesignPloneContenttypesLayer" | ||
name="@navigation" | ||
/> | ||
|
||
</configure> |
32 changes: 32 additions & 0 deletions
32
src/design/plone/contenttypes/restapi/services/navigation/get.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from design.plone.contenttypes.controlpanels.settings import IDesignPloneSettings | ||
from design.plone.contenttypes.interfaces import IDesignPloneContenttypesLayer | ||
from plone import api | ||
from plone.restapi.interfaces import IExpandableElement | ||
from plone.restapi.services import Service | ||
from plone.restapi.services.navigation.get import Navigation as BaseNavigation | ||
from zope.component import adapter | ||
from zope.interface import implementer | ||
from zope.interface import Interface | ||
|
||
|
||
@implementer(IExpandableElement) | ||
@adapter(Interface, IDesignPloneContenttypesLayer) | ||
class Navigation(BaseNavigation): | ||
def __call__(self, expand=False): | ||
result = super().__call__(expand=expand) | ||
try: | ||
show_dynamic_folders_in_footer = api.portal.get_registry_record( | ||
"show_dynamic_folders_in_footer", | ||
interface=IDesignPloneSettings, | ||
default=True, | ||
) | ||
except KeyError: | ||
show_dynamic_folders_in_footer = True | ||
result["navigation"]["show_in_footer"] = show_dynamic_folders_in_footer | ||
return result | ||
|
||
|
||
class NavigationGet(Service): | ||
def reply(self): | ||
navigation = Navigation(self.context, self.request) | ||
return navigation(expand=True)["navigation"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
src/design/plone/contenttypes/tests/test_custom_service_navigation.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# -*- coding: utf-8 -*- | ||
from design.plone.contenttypes.controlpanels.settings import IDesignPloneSettings | ||
from design.plone.contenttypes.testing import ( | ||
DESIGN_PLONE_CONTENTTYPES_API_FUNCTIONAL_TESTING, | ||
) | ||
from plone import api | ||
from plone.app.testing import setRoles | ||
from plone.app.testing import SITE_OWNER_NAME | ||
from plone.app.testing import SITE_OWNER_PASSWORD | ||
from plone.app.testing import TEST_USER_ID | ||
from plone.dexterity.utils import createContentInContainer | ||
from plone.restapi.testing import RelativeSession | ||
from transaction import commit | ||
|
||
import unittest | ||
|
||
|
||
class CustomNavigationTest(unittest.TestCase): | ||
layer = DESIGN_PLONE_CONTENTTYPES_API_FUNCTIONAL_TESTING | ||
|
||
def setUp(self): | ||
self.app = self.layer["app"] | ||
self.portal = self.layer["portal"] | ||
self.portal_url = self.portal.absolute_url() | ||
self.api_session = RelativeSession(self.portal_url) | ||
self.api_session.headers.update({"Accept": "application/json"}) | ||
self.api_session.auth = (SITE_OWNER_NAME, SITE_OWNER_PASSWORD) | ||
setRoles(self.portal, TEST_USER_ID, ["Manager"]) | ||
|
||
self.folder = createContentInContainer( | ||
self.portal, "Folder", id="folder", title="Some Folder" | ||
) | ||
self.folder2 = createContentInContainer( | ||
self.portal, "Folder", id="folder2", title="Some Folder 2" | ||
) | ||
self.subfolder1 = createContentInContainer( | ||
self.folder, "Folder", id="subfolder1", title="SubFolder 1" | ||
) | ||
self.subfolder2 = createContentInContainer( | ||
self.folder, "Folder", id="subfolder2", title="SubFolder 2" | ||
) | ||
self.thirdlevelfolder = createContentInContainer( | ||
self.subfolder1, | ||
"Folder", | ||
id="thirdlevelfolder", | ||
title="Third Level Folder", | ||
) | ||
self.fourthlevelfolder = createContentInContainer( | ||
self.thirdlevelfolder, | ||
"Folder", | ||
id="fourthlevelfolder", | ||
title="Fourth Level Folder", | ||
) | ||
createContentInContainer(self.folder, "Document", id="doc1", title="A document") | ||
commit() | ||
|
||
def tearDown(self): | ||
self.api_session.close() | ||
|
||
def test_return_show_in_footer_info_based_on_registry(self): | ||
# by default is True | ||
response = self.api_session.get( | ||
"/@navigation", params={"expand.navigation.depth": 2} | ||
).json() | ||
|
||
self.assertIn("show_in_footer", response) | ||
self.assertTrue(response["show_in_footer"]) | ||
|
||
# change it | ||
api.portal.set_registry_record( | ||
"show_dynamic_folders_in_footer", | ||
False, | ||
interface=IDesignPloneSettings, | ||
) | ||
commit() | ||
|
||
response = self.api_session.get( | ||
"/@navigation", params={"expand.navigation.depth": 2} | ||
).json() | ||
|
||
self.assertIn("show_in_footer", response) | ||
self.assertFalse(response["show_in_footer"]) |
Oops, something went wrong.