@@ -82,93 +82,102 @@ def run(self):
82
82
reset = load_workflow_from_package ("outgoingmail_workflow" , "imio.dms.mail:default" )
83
83
applied_adaptations = [dic ["adaptation" ] for dic in get_applied_adaptations ()
84
84
if dic ["workflow" ] == "outgoingmail_workflow" ]
85
+ finished1 = finished2 = True
85
86
if reset :
86
87
logger .info ("outgoingmail_workflow reloaded" )
87
88
for name in applied_adaptations :
88
89
success , errors = apply_from_registry (reapply = True , name = name )
89
90
if errors :
90
91
logger .error ("Problem applying wf adaptations '%s': %d errors" % (name , errors ))
91
92
# update permissions, roles and reindex allowedRolesAndUsers
92
- count = self .portal .portal_workflow .updateRoleMappings ()
93
- logger .info ("Updated {} items" .format (count ))
93
+ # count = self.portal.portal_workflow.updateRoleMappings() out of memory
94
+ # logger.info("Updated {} items".format(count))
95
+ finished1 = self .reindexIndexes (['allowedRolesAndUsers' ], portal_types = ['dmsoutgoingmail' ])
96
+ if finished1 :
97
+ finished2 = self .reindexIndexes (['allowedRolesAndUsers' ],
98
+ portal_types = ['dmsommainfile' , "dmsappendixfile" , "task" ])
99
+ else :
100
+ finished2 = False
94
101
else :
95
102
logger .error ("outgoingmail_workflow not reloaded !" )
96
103
97
104
# update localroles
98
- lr , fti = fti_configuration (portal_type = "dmsoutgoingmail" )
99
- changes = False
100
- if "imio.dms.mail.content.behaviors.IDmsMailCreatingGroup" in fti .behaviors :
101
- lrcg = lr ["creating_group" ]
102
- if "signed" not in lrcg :
105
+ finished = finished1 and finished2
106
+ if finished :
107
+ lr , fti = fti_configuration (portal_type = "dmsoutgoingmail" )
108
+ changes = False
109
+ if "imio.dms.mail.content.behaviors.IDmsMailCreatingGroup" in fti .behaviors :
110
+ lrcg = lr ["creating_group" ]
111
+ if "signed" not in lrcg :
112
+ changes = True
113
+ lrcg ["signed" ] = {CREATING_GROUP_SUFFIX : {"roles" : ["Reader" , "Reviewer" ]}}
114
+ if "to_be_signed" in lrcg and CREATING_GROUP_SUFFIX in lrcg ["to_be_signed" ] and "Editor" in \
115
+ lrcg ["to_be_signed" ][CREATING_GROUP_SUFFIX ]["roles" ]:
116
+ changes = True
117
+ # correction !
118
+ lrcg ["to_be_signed" ][CREATING_GROUP_SUFFIX ]["roles" ].remove ("Editor" )
119
+ lrsc = lr ["static_config" ]
120
+ if "signed" not in lrsc :
103
121
changes = True
104
- lrcg ["signed" ] = {CREATING_GROUP_SUFFIX : {"roles" : ["Reader" , "Reviewer" ]}}
105
- if "to_be_signed" in lrcg and CREATING_GROUP_SUFFIX in lrcg ["to_be_signed" ] and "Editor" in \
106
- lrcg ["to_be_signed" ][CREATING_GROUP_SUFFIX ]["roles" ]:
122
+ lrsc ["signed" ] = {
123
+ "expedition" : {"roles" : ["Editor" , "Reviewer" ]},
124
+ "encodeurs" : {"roles" : ["Reader" ]},
125
+ "dir_general" : {"roles" : ["Contributor" , "Editor" , "Reviewer" , "DmsFile Contributor" ]},
126
+ "lecteurs_globaux_cs" : {"roles" : ["Reader" ]},
127
+ }
128
+ lrtg = lr ["treating_groups" ]
129
+ if "signed" not in lrtg :
107
130
changes = True
108
- # correction !
109
- lrcg ["to_be_signed" ][CREATING_GROUP_SUFFIX ]["roles" ].remove ("Editor" )
110
- lrsc = lr ["static_config" ]
111
- if "signed" not in lrsc :
112
- changes = True
113
- lrsc ["signed" ] = {
114
- "expedition" : {"roles" : ["Editor" , "Reviewer" ]},
115
- "encodeurs" : {"roles" : ["Reader" ]},
116
- "dir_general" : {"roles" : ["Contributor" , "Editor" , "Reviewer" , "DmsFile Contributor" ]},
117
- "lecteurs_globaux_cs" : {"roles" : ["Reader" ]},
118
- }
119
- lrtg = lr ["treating_groups" ]
120
- if "signed" not in lrtg :
121
- changes = True
122
- lrtg ["signed" ] = {
123
- "editeur" : {"roles" : ["Reader" ]},
124
- "encodeur" : {"roles" : ["Reader" , "Reviewer" ]},
125
- "lecteur" : {"roles" : ["Reader" ]},
126
- }
127
- if "to_be_signed" in lrtg and "encodeur" in lrtg ["to_be_signed" ] and "Editor" in \
128
- lrtg ["to_be_signed" ]["encodeur" ]["roles" ]:
129
- changes = True
130
- # correction !
131
- lrtg ["to_be_signed" ]["encodeur" ]["roles" ].remove ("Editor" )
132
- lrrg = lr ["recipient_groups" ]
133
- if "signed" not in lrrg :
134
- changes = True
135
- lrrg ["signed" ] = {
136
- "editeur" : {"roles" : ["Reader" ]},
137
- "encodeur" : {"roles" : ["Reader" ]},
138
- "lecteur" : {"roles" : ["Reader" ]},
139
- }
140
- if u"imio.dms.mail.wfadaptations.OMServiceValidation" in applied_adaptations :
141
- if "signed" in lrtg and "n_plus_1" not in lrtg ["signed" ]:
131
+ lrtg ["signed" ] = {
132
+ "editeur" : {"roles" : ["Reader" ]},
133
+ "encodeur" : {"roles" : ["Reader" , "Reviewer" ]},
134
+ "lecteur" : {"roles" : ["Reader" ]},
135
+ }
136
+ if "to_be_signed" in lrtg and "encodeur" in lrtg ["to_be_signed" ] and "Editor" in \
137
+ lrtg ["to_be_signed" ]["encodeur" ]["roles" ]:
142
138
changes = True
143
- lrtg ["signed" ]["n_plus_1" ] = {"roles" : ["Reader" ]}
144
- if "signed" in lrrg and "n_plus_1" not in lrrg ["signed" ]:
139
+ # correction !
140
+ lrtg ["to_be_signed" ]["encodeur" ]["roles" ].remove ("Editor" )
141
+ lrrg = lr ["recipient_groups" ]
142
+ if "signed" not in lrrg :
145
143
changes = True
146
- lrrg ["signed" ]["n_plus_1" ] = {"roles" : ["Reader" ]}
144
+ lrrg ["signed" ] = {
145
+ "editeur" : {"roles" : ["Reader" ]},
146
+ "encodeur" : {"roles" : ["Reader" ]},
147
+ "lecteur" : {"roles" : ["Reader" ]},
148
+ }
149
+ if u"imio.dms.mail.wfadaptations.OMServiceValidation" in applied_adaptations :
150
+ if "signed" in lrtg and "n_plus_1" not in lrtg ["signed" ]:
151
+ changes = True
152
+ lrtg ["signed" ]["n_plus_1" ] = {"roles" : ["Reader" ]}
153
+ if "signed" in lrrg and "n_plus_1" not in lrrg ["signed" ]:
154
+ changes = True
155
+ lrrg ["signed" ]["n_plus_1" ] = {"roles" : ["Reader" ]}
147
156
148
- if changes :
149
- lr ._p_changed = True
157
+ if changes :
158
+ lr ._p_changed = True
150
159
151
- # change back confirmation message
152
- key = "imio.actionspanel.browser.registry.IImioActionsPanelConfig.transitions"
153
- values = list (api .portal .get_registry_record (key , default = []))
154
- if values and "dmsoutgoingmail.back_to_signed|" not in values :
155
- values .append ("dmsoutgoingmail.back_to_signed|" )
156
- api .portal .set_registry_record (key , values )
160
+ # change back confirmation message
161
+ key = "imio.actionspanel.browser.registry.IImioActionsPanelConfig.transitions"
162
+ values = list (api .portal .get_registry_record (key , default = []))
163
+ if values and "dmsoutgoingmail.back_to_signed|" not in values :
164
+ values .append ("dmsoutgoingmail.back_to_signed|" )
165
+ api .portal .set_registry_record (key , values )
157
166
158
- # add signed collection
159
- col_folder = self .portal ["outgoing-mail" ]["mail-searches" ]
160
- createStateCollections (self .portal ["outgoing-mail" ]["mail-searches" ], "dmsoutgoingmail" )
161
- pos = col_folder .getObjectPosition ("searchfor_to_be_signed" )
162
- col_folder .moveObjectToPosition ("searchfor_signed" , pos + 1 )
167
+ # add signed collection
168
+ col_folder = self .portal ["outgoing-mail" ]["mail-searches" ]
169
+ createStateCollections (self .portal ["outgoing-mail" ]["mail-searches" ], "dmsoutgoingmail" )
170
+ pos = col_folder .getObjectPosition ("searchfor_to_be_signed" )
171
+ col_folder .moveObjectToPosition ("searchfor_signed" , pos + 1 )
163
172
164
- # reindex om markers
165
- for brain in self .omf .portal_catalog .unrestrictedSearchResults (portal_type = "dmsoutgoingmail" ):
166
- obj = brain ._unrestrictedGetObject ()
167
- obj .reindexObject (idxs = ["markers" ])
173
+ # reindex om markers
174
+ for brain in self .omf .portal_catalog .unrestrictedSearchResults (portal_type = "dmsoutgoingmail" ):
175
+ obj = brain ._unrestrictedGetObject ()
176
+ obj .reindexObject (idxs = ["markers" ])
168
177
169
- # END
178
+ # END
170
179
171
- finished = True # can be eventually returned and set by batched method
180
+ # finished = True # can be eventually returned and set by batched method
172
181
if finished and old_version != new_version :
173
182
zope_app = self .portal
174
183
while not isinstance (zope_app , OFS .Application .Application ):
0 commit comments