-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into sitesettings_dependency
- Loading branch information
Showing
13 changed files
with
170 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
__pycache__ | ||
.DS_Store | ||
pyvenv.cfg | ||
.coverage | ||
|
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"POT-Creation-Date: 2024-03-21 13:53+0000\n" | ||
"POT-Creation-Date: 2024-03-28 10:20+0000\n" | ||
"PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n" | ||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
"Language-Team: LANGUAGE <[email protected]>\n" | ||
|
@@ -67,10 +67,10 @@ msgstr "Se abilitato, verrà utilizzato un ranking custom per la ricerca testual | |
msgid "enable_advanced_query_ranking_label" | ||
msgstr "Abilita ranking custom con AdvancedQuery" | ||
|
||
#. Default: "The id \"${id}\" is invalid because there is already an alias for that path. Search \"${fixed_path}\" in aliases management to manage it." | ||
#: redturtle/volto/adapters/namechooser.py:35 | ||
#. Default: "The id \"${id}\" is invalid because there is already an alias for that path. Change its id or ask site administrators to remove \"${fixed_path}\" in aliases management." | ||
#: redturtle/volto/adapters/namechooser.py:29 | ||
msgid "name_chooser_alias_error" | ||
msgstr "L'id \"${id}\" non è valido perché già utilizzato per un alias. Puoi verificarlo ed eventualmente cancellarlo, cercando \"${fixed_path}\" nella Gestione URL." | ||
msgstr "L'id \"${id}\" non è valido perché già utilizzato per un alias. Modifca l'id oppure rivolgiti agli amministratori per cancellare l'alias esistente: \"${fixed_path}\"." | ||
|
||
#. Default: "Insert an external link directly into the field,or select an internal link clicking on the icon." | ||
#: redturtle/volto/types/adapters.py:25 | ||
|
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,7 +4,7 @@ | |
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"POT-Creation-Date: 2024-03-21 13:53+0000\n" | ||
"POT-Creation-Date: 2024-03-28 12:42+0000\n" | ||
"PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n" | ||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
"Language-Team: LANGUAGE <[email protected]>\n" | ||
|
@@ -70,8 +70,8 @@ msgstr "" | |
msgid "enable_advanced_query_ranking_label" | ||
msgstr "" | ||
|
||
#. Default: "The id \"${id}\" is invalid because there is already an alias for that path. Search \"${fixed_path}\" in aliases management to manage it." | ||
#: redturtle/volto/adapters/namechooser.py:35 | ||
#. Default: "The id \"${id}\" is invalid because there is already an alias for that path. Change its id or ask site administrators to remove \"${fixed_path}\" in aliases management." | ||
#: redturtle/volto/adapters/namechooser.py:29 | ||
msgid "name_chooser_alias_error" | ||
msgstr "" | ||
|
||
|
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.
25 changes: 25 additions & 0 deletions
25
src/redturtle/volto/restapi/services/copymove/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,25 @@ | ||
<configure | ||
xmlns="http://namespaces.zope.org/zope" | ||
xmlns:plone="http://namespaces.plone.org/plone" | ||
xmlns:zcml="http://namespaces.zope.org/zcml" | ||
> | ||
|
||
<plone:service | ||
method="POST" | ||
factory=".copymove.Copy" | ||
for="Products.CMFCore.interfaces.IFolderish" | ||
permission="zope2.View" | ||
layer="redturtle.volto.interfaces.IRedturtleVoltoLayer" | ||
name="@copy" | ||
/> | ||
|
||
<plone:service | ||
method="POST" | ||
factory=".copymove.Move" | ||
for="Products.CMFCore.interfaces.IFolderish" | ||
permission="zope2.View" | ||
layer="redturtle.volto.interfaces.IRedturtleVoltoLayer" | ||
name="@move" | ||
/> | ||
|
||
</configure> |
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,21 @@ | ||
from plone.restapi.services.copymove.copymove import Copy as BaseCopy | ||
from plone.restapi.services.copymove.copymove import Move as BaseMove | ||
from redturtle.volto.adapters.namechooser import check_alias | ||
|
||
|
||
class Copy(BaseCopy): | ||
"""Copies existing content objects.""" | ||
|
||
def clipboard(self, parent, ids): | ||
for id in ids: | ||
check_alias(context=self.context, id=id) | ||
return super().clipboard(parent, ids) | ||
|
||
|
||
class Move(BaseMove): | ||
"""Moves existing content objects.""" | ||
|
||
def clipboard(self, parent, ids): | ||
for id in ids: | ||
check_alias(context=self.context, id=id) | ||
return super().clipboard(parent, ids) |
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,72 @@ | ||
# -*- coding: utf-8 -*- | ||
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.restapi.testing import RelativeSession | ||
from redturtle.volto.interfaces import IRedTurtleVoltoSettings | ||
from redturtle.volto.testing import REDTURTLE_VOLTO_API_FUNCTIONAL_TESTING | ||
|
||
import transaction | ||
import unittest | ||
|
||
|
||
class TestCopyMoveCustomization(unittest.TestCase): | ||
layer = REDTURTLE_VOLTO_API_FUNCTIONAL_TESTING | ||
|
||
def setUp(self): | ||
self.app = self.layer["app"] | ||
self.portal = self.layer["portal"] | ||
self.portal_url = self.portal.absolute_url() | ||
setRoles(self.portal, TEST_USER_ID, ["Manager"]) | ||
|
||
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) | ||
|
||
foo = api.content.create( | ||
container=self.portal, | ||
type="Document", | ||
title="Foo", | ||
) | ||
api.content.rename(obj=foo, new_id="xxx") | ||
|
||
self.bar = api.content.create( | ||
container=self.portal, | ||
type="Document", | ||
title="Bar", | ||
) | ||
api.content.create( | ||
container=self.bar, | ||
type="Document", | ||
title="foo", | ||
) | ||
|
||
# enable it | ||
api.portal.set_registry_record( | ||
"check_aliases_in_namechooser", True, interface=IRedTurtleVoltoSettings | ||
) | ||
|
||
transaction.commit() | ||
|
||
def tearDown(self): | ||
self.api_session.close() | ||
|
||
def test_move_raise_error_if_id_is_a_valid_alias(self): | ||
response = self.api_session.post("/@move", json={"source": ["/bar/foo"]}) | ||
|
||
self.assertEqual(response.status_code, 400) | ||
self.assertEqual( | ||
response.json()["message"], | ||
'The id "foo" is invalid because there is already an alias for that path. Change its id or ask site administrators to remove "/foo" in aliases management.', | ||
) | ||
|
||
def test_copy_raise_error_if_id_is_a_valid_alias(self): | ||
response = self.api_session.post("/@copy", json={"source": ["/bar/foo"]}) | ||
|
||
self.assertEqual(response.status_code, 400) | ||
self.assertEqual( | ||
response.json()["message"], | ||
'The id "foo" is invalid because there is already an alias for that path. Change its id or ask site administrators to remove "/foo" in aliases management.', | ||
) |
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