-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into quaive-app
- Loading branch information
Showing
3 changed files
with
35 additions
and
0 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
Empty file.
32 changes: 32 additions & 0 deletions
32
src/osha/oira/upgrade/v1/20240527102446_remove_unused_behavior/upgrade.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 ftw.upgrade import UpgradeStep | ||
from logging import getLogger | ||
from plone import api | ||
|
||
|
||
logger = getLogger(__name__) | ||
|
||
|
||
class RemoveUnusedBehavior(UpgradeStep): | ||
"""Remove unused behavior.""" | ||
|
||
def __call__(self): | ||
"""Remove from the euphorie.sector | ||
fti the behavior osha.oira.sector.IOSHASector | ||
""" | ||
portal_types = api.portal.get_tool("portal_types") | ||
fti = portal_types.get("euphorie.sector") | ||
if fti and "osha.oira.sector.IOSHASector" in fti.behaviors: | ||
fti.behaviors = tuple( | ||
[ | ||
behavior | ||
for behavior in fti.behaviors | ||
if behavior != "osha.oira.sector.IOSHASector" | ||
] | ||
) | ||
logger.info( | ||
"Removed behavior osha.oira.sector.IOSHASector from euphorie.sector" | ||
) | ||
else: | ||
logger.info( | ||
"Behavior osha.oira.sector.IOSHASector not found in euphorie.sector" | ||
) |