Commit 713c3e2e authored by Romain Courteaud's avatar Romain Courteaud

Simply data structure.

parent 25a90384
...@@ -80,32 +80,32 @@ if previous_open_sale_order is not None:\n ...@@ -80,32 +80,32 @@ if previous_open_sale_order is not None:\n
now = DateTime()\n now = DateTime()\n
\n \n
add_kw_kw = {}\n add_kw_kw = {}\n
for (add_kw, explanation) in add_kw_list:\n for add_kw in add_kw_list:\n
hosting_url = add_kw[\'aggregate\']\n
existing = portal.portal_catalog.countResults(\n existing = portal.portal_catalog.countResults(\n
portal_type=\'Open Sale Order Line\',\n portal_type=\'Open Sale Order Line\',\n
default_aggregate_uid=portal.restrictedTraverse(add_kw[\'aggregate\']).getUid()\n default_aggregate_uid=portal.restrictedTraverse(hosting_url).getUid()\n
)[0][0] > 0\n )[0][0] > 0\n
if add_kw[\'aggregate\'] not in hosting_subscription_mapping and not existing:\n if hosting_url not in hosting_subscription_mapping and not existing:\n
add_kw_kw[add_kw[\'aggregate\']] = add_kw.copy()\n add_kw_kw[hosting_url] = add_kw.copy()\n
add_kw_kw[add_kw[\'aggregate\']][\'explanation\'] = [\'Added because of %s \' % explanation]\n add_kw_kw[hosting_url][\'explanation\'] = [\'Added because of %s \' % hosting_url]\n
\n \n
modify_kw_kw = {}\n modify_kw_kw = {}\n
for start_date_tuple in start_date_tuple_list:\n for hosting_url, start_date in start_date_tuple_list:\n
start_date_tuple, explanation = start_date_tuple[0:2], start_date_tuple[2]\n start_date = getClosestDate(target_date=start_date, precision=\'day\')\n
start_date = getClosestDate(target_date=start_date_tuple[1], precision=\'day\')\n
while start_date.day() >= 29:\n while start_date.day() >= 29:\n
start_date = addToDate(start_date, to_add={\'day\': -1})\n start_date = addToDate(start_date, to_add={\'day\': -1})\n
start_date_modified = False\n start_date_modified = False\n
if start_date_tuple[0] in hosting_subscription_mapping:\n if hosting_url in hosting_subscription_mapping:\n
line_id = hosting_subscription_mapping[start_date_tuple[0]]\n line_id = hosting_subscription_mapping[hosting_url]\n
line = previous_open_sale_order[line_id]\n line = previous_open_sale_order[line_id]\n
if line.getStartDate() is None:\n if line.getStartDate() is None:\n
modify_kw_kw[line.getAggregate(portal_type=\'Hosting Subscription\')] = {\'start_date\': start_date}\n modify_kw_kw[line.getAggregate(portal_type=\'Hosting Subscription\')] = {\'start_date\': start_date}\n
modify_kw_kw[line.getAggregate(portal_type=\'Hosting Subscription\')][\'explanation\'] = [\'Set start date because of %s\' % explanation]\n modify_kw_kw[line.getAggregate(portal_type=\'Hosting Subscription\')][\'explanation\'] = [\'Set start date because of %s\' % hosting_url]\n
start_date_modified = True\n start_date_modified = True\n
elif start_date_tuple[0] in add_kw_kw:\n elif hosting_url in add_kw_kw:\n
add_kw_kw[start_date_tuple[0]][\'start_date\'] = start_date\n add_kw_kw[hosting_url][\'start_date\'] = start_date\n
add_kw_kw[start_date_tuple[0]][\'explanation\'].append(\'Added start date beacuse of %s\' % explanation)\n add_kw_kw[hosting_url][\'explanation\'].append(\'Added start date because of %s\' % hosting_url)\n
start_date_modified = True\n start_date_modified = True\n
\n \n
if previous_open_sale_order is not None:\n if previous_open_sale_order is not None:\n
...@@ -155,7 +155,7 @@ for (key, value) in modify_kw_kw.copy().iteritems():\n ...@@ -155,7 +155,7 @@ for (key, value) in modify_kw_kw.copy().iteritems():\n
\n \n
remove_id_list = set()\n remove_id_list = set()\n
if previous_open_sale_order is not None:\n if previous_open_sale_order is not None:\n
for (remove_hosting, explanation) in remove_hosting_list:\n for remove_hosting in remove_hosting_list:\n
if remove_hosting in add_kw_kw:\n if remove_hosting in add_kw_kw:\n
add_kw_kw[remove_hosting][\'explanation\'].append(\'Not removed because just added\')\n add_kw_kw[remove_hosting][\'explanation\'].append(\'Not removed because just added\')\n
continue\n continue\n
......
...@@ -72,21 +72,18 @@ for hosting_subscription in portal.portal_catalog(\n ...@@ -72,21 +72,18 @@ for hosting_subscription in portal.portal_catalog(\n
default_destination_section_uid=context.getUid(),\n default_destination_section_uid=context.getUid(),\n
):\n ):\n
hosting_subscription = hosting_subscription.getObject()\n hosting_subscription = hosting_subscription.getObject()\n
add_kw = dict(\n add_kw_list.append({\n
title=hosting_subscription.getTitle(),\n \'title\': hosting_subscription.getTitle(),\n
aggregate=hosting_subscription.getRelativeUrl()\n \'aggregate\': hosting_subscription.getRelativeUrl(),\n
)\n })\n
add_kw_list.append((add_kw, hosting_subscription.getPath()))\n
if hosting_subscription.getSlapState() == \'destroy_requested\':\n if hosting_subscription.getSlapState() == \'destroy_requested\':\n
remove_hosting_list.append((hosting_subscription.getRelativeUrl(),\n remove_hosting_list.append(hosting_subscription.getRelativeUrl())\n
hosting_subscription.getPath()))\n
try:\n try:\n
start_date = getWorkflowDate(hosting_subscription, \'request_instance\')\n start_date = getWorkflowDate(hosting_subscription, \'request_instance\')\n
except ValueError:\n except ValueError:\n
start_date = hosting_subscription.getCreationDate()\n start_date = hosting_subscription.getCreationDate()\n
start_date_tuple_list.append((hosting_subscription.getRelativeUrl(),\n start_date_tuple_list.append((hosting_subscription.getRelativeUrl(),\n
start_date,\n start_date))\n
hosting_subscription.getPath()))\n
\n \n
\n \n
result = context.Person_updateOpenSaleOrder(\n result = context.Person_updateOpenSaleOrder(\n
......
220 221
\ No newline at end of file \ No newline at end of file
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