Commit edc03335 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

erp5_officejs_appstore_base: Update Consistency scripts related to web site. Add Export Tool

parent e86b5a5c
......@@ -226,7 +226,7 @@
</item>
<item>
<key> <string>skin_selection_name</string> </key>
<value> <string>RJS</string> </value>
<value> <string>RJSVersioning</string> </value>
</item>
<item>
<key> <string>static_language_selection</string> </key>
......@@ -421,7 +421,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>950.60581.37797.64716</string> </value>
<value> <string>950.60590.3867.31761</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -439,7 +439,7 @@
</tuple>
<state>
<tuple>
<float>1462201803.21</float>
<float>1462897520.95</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -9,27 +9,59 @@ if not web_site:
web_site.edit(
title=context.getTitle(),
short_title=context.getTitle(),
id=context.getReference().lower(),
)
context.setFollowUpValue(web_site)
# This is dangerous
if not web_site.getId() == context.getReference().lower():
web_site.setId(context.getReference().lower())
# Update version on development document
# XX Do we need version???
document_list = portal.portal_catalog(
portal_type= portal.getPortalDocumentTypeList(),
validation_state="draft",
strict_follow_up_uid=context.getUid(),
)
# XX Doesn't seem to be unique enough
version = context.getReference()[:6] + "-dev"
for document_brain in document_list:
document = document_brain.getObject()
document.setVersion(version)
development_section = web_site["development"]
if not development_section.getAggregate():
aggregate_list = portal.portal_catalog(
portal_type="Web Page",
strict_follow_up_uid=context.getUid(),
strict_publication_section_uid=portal.portal_categories.publication_section.application.landing_page.getUid(),
validation_state="draft",
#XXX Hackish
sort_on=[("modification_date", "descending")],
limit=1,
select_list=["relative_url"],
)
if aggregate_list:
development_section.setAggregate(aggregate_list[0].relative_url)
# Update development section to use version and follow_up
development_section.setCriterionPropertyList([
"version",
"validation_state",
])
development_section.setCriterion('version', version)
development_section.setCriterion('validation_state', 'draft')
development_section.setMembershipCriterionBaseCategoryList(['follow_up'])
development_section.setMembershipCriterionCategoryList(['follow_up/' + context.getRelativeUrl()])
# Update default page for development version.
landing_publication_uid = portal.portal_categories.publication_section.application.landing_page.getUid()
aggregate_list = portal.portal_catalog(
portal_type="Web Page",
strict_follow_up_uid=context.getUid(),
strict_publication_section_uid=landing_publication_uid,
validation_state="draft",
#XXX Hackish
sort_on=[("modification_date", "descending")],
limit=1,
select_list=["relative_url"],
)
if aggregate_list:
development_section.setAggregate(aggregate_list[0].relative_url)
development_section.setTitle(context.getTitle() + " Development")
development_section.setShortTitle(context.getShortTitle())
development_section.setDescription(context.getDescription())
return web_site
# XXX Should fix default page for development version.
portal = context.getPortalObject()
# First make sure the site is in the correct state
website = context.SoftwareProduct_fixRelatedWebSite()
software_product = context
# Should make a script for that
if software_product.getId() != software_product.getReference().lower():
software_product.setId(context.getReference().lower())
base_id = "%s-" % (context.getId())
# Start with the document list
path_list = []
document_list = portal.portal_catalog(
portal_type= portal.getPortalDocumentTypeList(),
validation_state="draft",
strict_follow_up_uid=context.getUid(),
select_list=('relative_url', ),
)
for brain in document_list:
document = brain.getObject()
# Update ID is necessary
if not document.getId() == base_id + document.getReference().replace('.', '_'):
document.setId(base_id + document.getReference().replace('.', '_'))
path_list.append(document.getRelativeUrl())
# Append the software product
path_list.append(context.getRelativeUrl())
# Add the website development section (Really????)
path_list.append(website.getRelativeUrl())
path_list.append(website['development'].getRelativeUrl())
path_list.append(website['development'].getRelativeUrl() + "/**")
if business_template_path:
bt5 = portal.restrictedTraverse(business_template_path)
else:
bt5 = portal.portal_templates.newContent(
portal_type="Business Template",
title='officejs-' + context.getReference().lower() + '-export',
)
bt5.edit(
template_path_list=path_list,
template_keep_last_workflow_history_only_path_list=path_list,
version=DateTime().HTML4(),
)
return bt5.Base_redirect(
'',
keeps_items={
'portal_status_message': portal.Base_translateString("Portal Template updated")
}
)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<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>business_template_path=""</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SoftwareProduct_prepareBT5</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from random import randint
portal = context.getPortalObject()
# Get Software Product Object
software_product = portal.restrictedTraverse(software_product_rurl)
# Should make a script for that
if software_product.getId() != software_product.getReference().lower():
software_product.setId(software_product.getReference().lower())
base_id = "%s-" % (software_product.getId())
data = context.getData()
data_list = data.split('\n')
reference_list = []
started = False
ignore_string_len = len(ignore_string)
for ref in data_list:
if not started:
if ref == "CACHE:":
started = True
continue
else:
if ref == "NETWORK:":
started = False
continue
if ref.startswith(ignore_string):
reference_list.append(ref[ignore_string_len:])
continue
reference_list.append(ref)
# Manifest should also be cloned
reference_list.append(context.getReference())
document_list = portal.portal_catalog(
validation_state=("published", "published_alive"),
reference=reference_list,
)
path_list = [software_product_rurl]
print " Processing File List \r===============================\r"
for document_brain in document_list:
document = document_brain.getObject()
print document.getId()
new_document = document.Base_createCloneDocument(batch_mode=True)
new_id = base_id + new_document.getReference().replace('.', '_')
if new_id in new_document.getParentValue():
print " deleting %s" % new_id
new_document.getParentValue().manage_delObjects([new_id])
new_document.setId(new_id)
path_list.append(new_document.getRelativeUrl())
# version should not be set by this script but by alarm
# new_document.setVersion(base_id + "dev")
new_document.setFollowUp(software_product_rurl)
print "\r\r Here is your path list\r===============================\r\r"
print '\r'.join(path_list)
print "\r\r===============================\r\r"
print " Done"
return printed
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<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>software_product_rurl, ignore_string=""</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebManifest_createCloneFile</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment