Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Rafael Monnerat
slapos.core
Commits
8755c713
Commit
8755c713
authored
Jul 11, 2024
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_erp5: Add Upgrade Constraint to Migrate Region Categories
parent
0e81a818
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
286 additions
and
1 deletion
+286
-1
master/bt5/slapos_erp5/PortalTypePropertySheetTemplateItem/property_sheet_list.xml
...rtalTypePropertySheetTemplateItem/property_sheet_list.xml
+3
-0
master/bt5/slapos_erp5/PropertySheetTemplateItem/portal_property_sheets/CategoryToolUpgraderRegionConstraint.xml
..._property_sheets/CategoryToolUpgraderRegionConstraint.xml
+65
-0
master/bt5/slapos_erp5/PropertySheetTemplateItem/portal_property_sheets/CategoryToolUpgraderRegionConstraint/region_migration_upgrade_constraint.xml
...rRegionConstraint/region_migration_upgrade_constraint.xml
+78
-0
master/bt5/slapos_erp5/SkinTemplateItem/portal_skins/slapos_erp5/CategoryTool_checkRegionMigrationConsistency.py
...apos_erp5/CategoryTool_checkRegionMigrationConsistency.py
+75
-0
master/bt5/slapos_erp5/SkinTemplateItem/portal_skins/slapos_erp5/CategoryTool_checkRegionMigrationConsistency.xml
...pos_erp5/CategoryTool_checkRegionMigrationConsistency.xml
+62
-0
master/bt5/slapos_erp5/bt/template_portal_type_property_sheet_list
...5/slapos_erp5/bt/template_portal_type_property_sheet_list
+1
-0
master/bt5/slapos_erp5/bt/template_property_sheet_id_list
master/bt5/slapos_erp5/bt/template_property_sheet_id_list
+2
-1
No files found.
master/bt5/slapos_erp5/PortalTypePropertySheetTemplateItem/property_sheet_list.xml
View file @
8755c713
...
...
@@ -2,6 +2,9 @@
<portal_type
id=
"Catalog Tool"
>
<item>
CatalogToolNoneCreationDateConstraint
</item>
</portal_type>
<portal_type
id=
"Category Tool"
>
<item>
CategoryToolUpgraderRegionConstraint
</item>
</portal_type>
<portal_type
id=
"Contract Invitation Token"
>
<item>
Reference
</item>
<item>
SlapOSCloudContractAccounting
</item>
...
...
master/bt5/slapos_erp5/PropertySheetTemplateItem/portal_property_sheets/CategoryToolUpgraderRegionConstraint.xml
0 → 100644
View file @
8755c713
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Property Sheet"
module=
"erp5.portal_type"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_count
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
_mt_index
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAM=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
_tree
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAQ=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<string>
Migrate and unify the constraints related to Region changes\n
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
CategoryToolUpgraderRegionConstraint
</string>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Property Sheet
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<pickle>
<global
name=
"Length"
module=
"BTrees.Length"
/>
</pickle>
<pickle>
<int>
0
</int>
</pickle>
</record>
<record
id=
"3"
aka=
"AAAAAAAAAAM="
>
<pickle>
<global
name=
"OOBTree"
module=
"BTrees.OOBTree"
/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record
id=
"4"
aka=
"AAAAAAAAAAQ="
>
<pickle>
<global
name=
"OOBTree"
module=
"BTrees.OOBTree"
/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_erp5/PropertySheetTemplateItem/portal_property_sheets/CategoryToolUpgraderRegionConstraint/region_migration_upgrade_constraint.xml
0 → 100644
View file @
8755c713
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Script Constraint"
module=
"erp5.portal_type"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_identity_criterion
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
_range_criterion
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAM=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
categories
</string>
</key>
<value>
<tuple>
<string>
constraint_type/post_upgrade
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<string
encoding=
"base64"
>
Cg==
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
region_migration_upgrade_constraint
</string>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Script Constraint
</string>
</value>
</item>
<item>
<key>
<string>
script_id
</string>
</key>
<value>
<string>
CategoryTool_checkRegionMigrationConsistency
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<pickle>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
data
</string>
</key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"3"
aka=
"AAAAAAAAAAM="
>
<pickle>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
data
</string>
</key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_erp5/SkinTemplateItem/portal_skins/slapos_erp5/CategoryTool_checkRegionMigrationConsistency.py
0 → 100644
View file @
8755c713
from
zExceptions
import
Unauthorized
from
Products.ZSQLCatalog.SQLCatalog
import
SimpleQuery
,
NegatedQuery
if
REQUEST
is
not
None
:
raise
Unauthorized
# check if is consistent
portal
=
context
.
getPortalObject
()
not_expired_category_list
=
portal
.
portal_catalog
(
portal_type
=
"Category"
,
path
=
"%portal_categories/region/%"
,
validation_state
=
NegatedQuery
(
SimpleQuery
(
validation_state
=
'expired'
))
)
# Filter the list, since search for None dont work properly.
category_to_migrate_list
=
[
c
for
c
in
not_expired_category_list
if
c
.
getIntIndex
(
0
)
<
1
]
if
not
len
(
category_to_migrate_list
):
# Skip everything is consistent
return
[]
if
fixit
:
# Build a Map to not search inside the loop, this makes upgrade faster
new_category_map
=
{}
for
category
in
not_expired_category_list
:
if
c
.
getIntIndex
(
0
)
<
1
or
category
.
getValidationState
()
==
'expired'
:
continue
title
=
category
.
getTitle
()
if
title
not
in
new_category_map
:
new_category_map
[
title
]
=
[
category
]
else
:
new_category_map
[
title
].
append
(
category
)
message_list
=
[]
for
category
in
category_to_migrate_list
:
if
category
.
getIntIndex
()
==
1
:
raise
ValueError
(
"Selected the wrong thing"
)
if
category
.
getValidationState
()
==
'expired'
:
# skip, we seems to be rerunning the migration
# and some reindexation is going on.
continue
message_list
.
append
(
"%s requires migration (int_index: %s, validation_state: %s)"
%
(
category
.
getRelativeUrl
(),
category
.
getIntIndex
(),
category
.
getValidationState
())
)
if
fixit
:
new_category_list
=
new_category_map
[
category
.
getTitle
()]
if
len
(
new_category_list
)
!=
1
:
raise
ValueError
(
'Cannot decide which one to migrate into (%s options)'
%
len
(
new_category_list
))
new_category
=
new_category_list
[
0
]
# Can we make it cheaper
related_document_list
=
category
.
Base_getRelatedObjectList
(
**
{
'portal_type'
:
NegatedQuery
(
SimpleQuery
(
portal_type
=
'Category'
)),
'category.category_strict_membership'
:
1
})
for
document
in
related_document_list
:
# does it actually has the category?
document
.
edit
(
region
=
new_category
)
document
.
reindexObject
()
# 1) Search for the all related objects
# 2) Migrate all related objects
# 3) reindex everything
# 4) Expire the category
category
.
expire
()
message_list
.
append
(
"%s migrated and expired (int_index: %s, validation_state: %s)"
%
(
category
.
getRelativeUrl
(),
category
.
getIntIndex
(),
category
.
getValidationState
())
)
return
message_list
master/bt5/slapos_erp5/SkinTemplateItem/portal_skins/slapos_erp5/CategoryTool_checkRegionMigrationConsistency.xml
0 → 100644
View file @
8755c713
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"_reconstructor"
module=
"copy_reg"
/>
</klass>
<tuple>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
<global
name=
"object"
module=
"__builtin__"
/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_container
</string>
</key>
<value>
<string>
container
</string>
</value>
</item>
<item>
<key>
<string>
name_context
</string>
</key>
<value>
<string>
context
</string>
</value>
</item>
<item>
<key>
<string>
name_m_self
</string>
</key>
<value>
<string>
script
</string>
</value>
</item>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
fixit=False, REQUEST=None, **kw
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
CategoryTool_checkRegionMigrationConsistency
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_erp5/bt/template_portal_type_property_sheet_list
View file @
8755c713
Catalog Tool | CatalogToolNoneCreationDateConstraint
Category Tool | CategoryToolUpgraderRegionConstraint
Contract Invitation Token | Reference
Contract Invitation Token | SlapOSCloudContractAccounting
Contract Invitation Token | Url
...
...
master/bt5/slapos_erp5/bt/template_property_sheet_id_list
View file @
8755c713
CatalogToolNoneCreationDateConstraint
CategoryToolUpgraderRegionConstraint
GeographicOrganisation
TemplateToolPASConsistencyConstraint
PreferenceSlapOSConstraintPreference
ShacacheSystemPreference
SlapOSModuleIdGeneratorConstraint
TemplateToolBusinessApplicationModuleCategoryConstraint
TemplateToolPASConsistencyConstraint
WebSiteModuleShacacheConstraint
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment