Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/MPMCHAC-5_itemWFValidationLevels…
Browse files Browse the repository at this point in the history
…_groups_managing_item' into DLIBBDC-3383_condition_edit_otherMeetingConfigsClonableToFiels
  • Loading branch information
gbastien committed Nov 8, 2024
2 parents a0be03f + 23a916e commit 9ad4396
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 68 deletions.
8 changes: 7 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@ Changelog
=========


4.2.12rc2 (unreleased)
4.2.13rc1 (unreleased)
----------------------

- Nothing changed yet.


4.2.12 (2024-11-07)
-------------------

- Adapted `Migrator.updateWFStatesAndTransitions` to manage item WF states
defined on organizations in item advice related states attributes.
[gbastien]
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ include *.conf
include *.ignore
include *.py
include *.rst
include *.txt
include Makefile
include base.cfg
include buildout.cfg
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from setuptools import setup


version = '4.2.12rc2.dev0'
version = '4.2.13rc1.dev0'

setup(name='Products.PloneMeeting',
version=version,
Expand Down
67 changes: 2 additions & 65 deletions src/Products/PloneMeeting/migrations/migrate_to_4214.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

from imio.helpers.setup import load_type_from_package
from imio.pyutils.utils import replace_in_list
from Products.PloneMeeting.config import GROUP_MANAGING_ITEM_PG_PREFIX
from Products.PloneMeeting.migrations import logger
from Products.PloneMeeting.migrations import Migrator
from Products.PloneMeeting.model.adaptations import WAITING_ADVICES_NEW_STATE_ID_PATTERN
from Products.PloneMeeting.setuphandlers import _configureWebspellchecker
from Products.PloneMeeting.setuphandlers import _installWebspellchecker

Expand All @@ -28,28 +26,6 @@ def _migrateAdviceEditedItemMailEvents(self):
cfg.setMailItemEvents(mailItemEvents)
logger.info('Done.')

def _initGroupsManagingItemToCfgItemWFValidationLevels(self):
"""Update existing MeetingConfig.itemWFValidationLevels to initialize
"group_managing_item/extra_groups_managing_item" based on
"suffix/extra_suffixes" that are removed."""
logger.info('Updating MeetingConfig.itemWFValidationLevels to initialize '
'"group_managing_item/extra_groups_managing_item"...')
for cfg in self.tool.objectValues('MeetingConfig'):
stored = getattr(cfg, 'itemWFValidationLevels', [])
for level in stored:
if 'suffix' not in level:
return self._already_migrated()
# migrate columns 'suffix' to 'group_managing_item' and
# 'extra_suffixes' to 'extra_groups_managing_item'
# and remove 'suffix/extra_suffixes'
level['group_managing_item'] = GROUP_MANAGING_ITEM_PG_PREFIX + level['suffix']
level['extra_groups_managing_item'] = [
GROUP_MANAGING_ITEM_PG_PREFIX + suffix
for suffix in list(level['extra_suffixes'])]
del level['suffix']
del level['extra_suffixes']
cfg.setItemWFValidationLevels(stored)

def _installIMIOWebSpellChecker(self):
"""Configure imio.webspellchecker."""
logger.info('Install and configure "imio.webspellchecker"...')
Expand All @@ -69,57 +45,19 @@ def _updatePortalTypesTitle(self):
cfg.registerPortalTypes()
logger.info('Done.')

def _migrateItemsWaitingAdviceState(self):
"""When using MeetingConfig.itemWFValidationLevels to compute
the waiting_advices state id, we were generating a __or__ complex
state name, now we go back to any_validation_state_waiting_advices."""
logger.info('Migrating items waiting advices state name...')
for cfg in self.tool.objectValues('MeetingConfig'):
wfas = cfg.getWorkflowAdaptations()
if 'waiting_advices_from_every_val_levels' in wfas or \
'waiting_advices_from_before_last_val_level' in wfas or \
'waiting_advices_from_last_val_level' in wfas:
# generate old state id
item_validation_states = cfg.getItemWFValidationLevels(
data='state', only_enabled=True)
state_id = WAITING_ADVICES_NEW_STATE_ID_PATTERN.format(
'__or__'.join(item_validation_states))
self.updateWFStatesAndTransitions(
query={'getConfigId': cfg.getId(),
'meta_type': 'MeetingItem'},
review_state_mappings={
state_id: 'any_validation_state_waiting_advices'})
logger.info('Done.')

def _updateSearchItemsOfMyCommitteesSearchesCondition(self):
"""As these searches are used only when committees editors are used."""
logger.info('Updating committees editors searches TAL condition in every MeetingConfigs...')
for cfg in self.tool.objectValues('MeetingConfig'):
searchitemsofmycommittees = cfg.searches.searches_items.get('searchitemsofmycommittees')
if searchitemsofmycommittees:
searchitemsofmycommittees.tal_condition = "python: cfg.is_committees_using('enable_editors')"
searchitemsofmycommitteeseditable = cfg.searches.searches_items.get('searchitemsofmycommitteeseditable')
if searchitemsofmycommitteeseditable:
searchitemsofmycommitteeseditable.tal_condition = \
"python: cfg.is_committees_using('enable_editors')"
logger.info('Done.')

def run(self, extra_omitted=[], from_migration_to_4200=False):

logger.info('Migrating to PloneMeeting 4214...')
self._initGroupsManagingItemToCfgItemWFValidationLevels()
# reload ConfigurablePODTemplate to use every_annex_types_vocabulary for field store_as_annex
load_type_from_package('ConfigurablePODTemplate', 'Products.PloneMeeting:default')
self._migrateAdviceEditedItemMailEvents()
self._updatePortalTypesTitle()
self._migrateItemsWaitingAdviceState()
# not done for now, we will enable it when necessary
# self._installIMIOWebSpellChecker()
# add text criterion on "item title only" again as it was not in default
# dashboard faceted criteria, new MeetingConfigs created manually in between
# are missing this new criterion
self.updateFacetedFilters(xml_filename='upgrade_step_4211_add_item_widgets.xml')
self._updateSearchItemsOfMyCommitteesSearchesCondition()
# holidays 2025 were added
self.updateHolidays()
logger.info('Migrating to PloneMeeting 4214... Done.')
Expand All @@ -132,10 +70,9 @@ def migrate(context):
2) Update values of MeetingConfig.itemMailEvents as format of
"adviceEdited" values changed;
3) Update Meeting/MeetingItem portal_types title as we store the real title now;
4) Update faceted filters (Add "item title only" search criterion again);
4) Update faceted filters;
5) Not done for now: install and configure "imio.webspellchecker".
6) Add "groups_managing_item" to every MeetingConfig.itemWFValidationLevels;
7) Adapt committees editors searches tal_condition.
'''
migrator = Migrate_To_4214(context)
migrator.run()
Expand Down
90 changes: 90 additions & 0 deletions src/Products/PloneMeeting/migrations/migrate_to_4215.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# -*- coding: utf-8 -*-

from imio.helpers.setup import load_type_from_package
from imio.pyutils.utils import replace_in_list
from Products.PloneMeeting.config import GROUP_MANAGING_ITEM_PG_PREFIX
from Products.PloneMeeting.migrations import logger
from Products.PloneMeeting.migrations import Migrator
from Products.PloneMeeting.model.adaptations import WAITING_ADVICES_NEW_STATE_ID_PATTERN
from Products.PloneMeeting.setuphandlers import _configureWebspellchecker
from Products.PloneMeeting.setuphandlers import _installWebspellchecker


class Migrate_To_4215(Migrator):

def _initGroupsManagingItemToCfgItemWFValidationLevels(self):
"""Update existing MeetingConfig.itemWFValidationLevels to initialize
"group_managing_item/extra_groups_managing_item" based on
"suffix/extra_suffixes" that are removed."""
logger.info('Updating MeetingConfig.itemWFValidationLevels to initialize '
'"group_managing_item/extra_groups_managing_item"...')
for cfg in self.tool.objectValues('MeetingConfig'):
stored = getattr(cfg, 'itemWFValidationLevels', [])
for level in stored:
if 'suffix' not in level:
return self._already_migrated()
# migrate columns 'suffix' to 'group_managing_item' and
# 'extra_suffixes' to 'extra_groups_managing_item'
# and remove 'suffix/extra_suffixes'
level['group_managing_item'] = GROUP_MANAGING_ITEM_PG_PREFIX + level['suffix']
level['extra_groups_managing_item'] = [
GROUP_MANAGING_ITEM_PG_PREFIX + suffix
for suffix in list(level['extra_suffixes'])]
del level['suffix']
del level['extra_suffixes']
cfg.setItemWFValidationLevels(stored)

def _migrateItemsWaitingAdviceState(self):
"""When using MeetingConfig.itemWFValidationLevels to compute
the waiting_advices state id, we were generating a __or__ complex
state name, now we go back to any_validation_state_waiting_advices."""
logger.info('Migrating items waiting advices state name...')
for cfg in self.tool.objectValues('MeetingConfig'):
wfas = cfg.getWorkflowAdaptations()
if 'waiting_advices_from_every_val_levels' in wfas or \
'waiting_advices_from_before_last_val_level' in wfas or \
'waiting_advices_from_last_val_level' in wfas:
# generate old state id
item_validation_states = cfg.getItemWFValidationLevels(
data='state', only_enabled=True)
state_id = WAITING_ADVICES_NEW_STATE_ID_PATTERN.format(
'__or__'.join(item_validation_states))
self.updateWFStatesAndTransitions(
query={'getConfigId': cfg.getId(),
'meta_type': 'MeetingItem'},
review_state_mappings={
state_id: 'any_validation_state_waiting_advices'})
logger.info('Done.')

def _updateSearchItemsOfMyCommitteesSearchesCondition(self):
"""As these searches are used only when committees editors are used."""
logger.info('Updating committees editors searches TAL condition in every MeetingConfigs...')
for cfg in self.tool.objectValues('MeetingConfig'):
searchitemsofmycommittees = cfg.searches.searches_items.get('searchitemsofmycommittees')
if searchitemsofmycommittees:
searchitemsofmycommittees.tal_condition = "python: cfg.is_committees_using('enable_editors')"
searchitemsofmycommitteeseditable = cfg.searches.searches_items.get('searchitemsofmycommitteeseditable')
if searchitemsofmycommitteeseditable:
searchitemsofmycommitteeseditable.tal_condition = \
"python: cfg.is_committees_using('enable_editors')"
logger.info('Done.')

def run(self, extra_omitted=[], from_migration_to_4200=False):

logger.info('Migrating to PloneMeeting 4215...')
self._initGroupsManagingItemToCfgItemWFValidationLevels()
self._migrateItemsWaitingAdviceState()
self._updateSearchItemsOfMyCommitteesSearchesCondition()
logger.info('Migrating to PloneMeeting 4215... Done.')


def migrate(context):
'''This migration function will:
1) Add "groups_managing_item" to every MeetingConfig.itemWFValidationLevels;
2) Move item waiting_advices states to "any_validation_state_waiting_advices";
3) Adapt committees editors searches "tal_condition".
'''
migrator = Migrate_To_4215(context)
migrator.run()
migrator.finish()
8 changes: 8 additions & 0 deletions src/Products/PloneMeeting/profiles.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,12 @@
handler="Products.PloneMeeting.migrations.migrate_to_4214.migrate"
profile="Products.PloneMeeting:default" />

<genericsetup:upgradeStep
title="Go to PloneMeeting 4215"
description="Go to PloneMeeting 4215"
source="4214"
destination="4215"
handler="Products.PloneMeeting.migrations.migrate_to_4215.migrate"
profile="Products.PloneMeeting:default" />

</configure>
2 changes: 1 addition & 1 deletion src/Products/PloneMeeting/profiles/default/metadata.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<metadata>
<version>4214</version>
<version>4215</version>
<dependencies>
<dependency>profile-Products.CMFPlacefulWorkflow:CMFPlacefulWorkflow</dependency>
<dependency>profile-imio.dashboard:default</dependency>
Expand Down

0 comments on commit 9ad4396

Please sign in to comment.