Commit 5d305f69 authored by Łukasz Nowak's avatar Łukasz Nowak

Explain each change.

parent b3eb13a1
...@@ -80,14 +80,16 @@ if previous_open_sale_order is not None:\n ...@@ -80,14 +80,16 @@ 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 in add_kw_list:\n for (add_kw, explanation) in add_kw_list:\n
existing = portal.portal_catalog.countResults(portal_type=\'Open Sale Order Line\', default_aggregate_uid=portal.restrictedTraverse(add_kw[\'aggregate\']).getUid())[0][0] > 0\n existing = portal.portal_catalog.countResults(portal_type=\'Open Sale Order Line\', default_aggregate_uid=portal.restrictedTraverse(add_kw[\'aggregate\']).getUid())[0][0] > 0\n
if add_kw[\'aggregate\'] not in hosting_subscription_mapping and not existing:\n if add_kw[\'aggregate\'] not in hosting_subscription_mapping and not existing:\n
add_kw_kw[add_kw[\'aggregate\']] = add_kw.copy()\n add_kw_kw[add_kw[\'aggregate\']] = add_kw.copy()\n
add_kw_kw[add_kw[\'aggregate\']][\'explanation\'] = [\'Added because of %s \' % explanation]\n
\n \n
modify_kw_kw = {}\n modify_kw_kw = {}\n
hs_modify_kw_kw = {}\n hs_modify_kw_kw = {}\n
for start_date_tuple in start_date_tuple_list:\n for start_date_tuple 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_tuple[1], 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
...@@ -96,11 +98,13 @@ for start_date_tuple in start_date_tuple_list:\n ...@@ -96,11 +98,13 @@ for start_date_tuple in start_date_tuple_list:\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
else:\n else:\n
# reset start_date to possibly already set up on Open Order Line\n # reset start_date to possibly already set up on Open Order Line\n
start_date = line.getStartDate()\n start_date = line.getStartDate()\n
elif start_date_tuple[0] in add_kw_kw:\n elif start_date_tuple[0] in add_kw_kw:\n
add_kw_kw[start_date_tuple[0]][\'start_date\'] = start_date\n add_kw_kw[start_date_tuple[0]][\'start_date\'] = start_date\n
add_kw_kw[start_date_tuple[0]][\'explanation\'].append(\'Added start date beacuse of %s\' % explanation)\n
hs = portal.restrictedTraverse(start_date_tuple[0])\n hs = portal.restrictedTraverse(start_date_tuple[0])\n
if hs.getPeriodicityMonthDayList() != [start_date.day()]:\n if hs.getPeriodicityMonthDayList() != [start_date.day()]:\n
hs_modify_kw_kw.setdefault(start_date_tuple[0], {})\n hs_modify_kw_kw.setdefault(start_date_tuple[0], {})\n
...@@ -109,6 +113,7 @@ for start_date_tuple in start_date_tuple_list:\n ...@@ -109,6 +113,7 @@ for start_date_tuple in start_date_tuple_list:\n
periodicity_hour_list=[0],\n periodicity_hour_list=[0],\n
periodicity_minute_list=[0]\n periodicity_minute_list=[0]\n
)\n )\n
hs_modify_kw_kw[start_date_tuple[0]][\'explanation\'] = \'Set up because of %s\' % explanation\n
\n \n
if previous_open_sale_order is not None:\n if previous_open_sale_order is not None:\n
for line in previous_open_sale_order.contentValues(portal_type=\'Open Sale Order Line\'):\n for line in previous_open_sale_order.contentValues(portal_type=\'Open Sale Order Line\'):\n
...@@ -116,18 +121,23 @@ if previous_open_sale_order is not None:\n ...@@ -116,18 +121,23 @@ if previous_open_sale_order is not None:\n
if old_stop_date is not None:\n if old_stop_date is not None:\n
if stop_date is not None and old_stop_date < stop_date:\n if stop_date is not None and old_stop_date < stop_date:\n
modify_kw_kw.setdefault(line.getAggregate(portal_type=\'Hosting Subscription\'), {})\n modify_kw_kw.setdefault(line.getAggregate(portal_type=\'Hosting Subscription\'), {})\n
modify_kw_kw[line.getAggregate(portal_type=\'Hosting Subscription\')].setdefault(\'explanation\', [])\n
modify_kw_kw[line.getAggregate(portal_type=\'Hosting Subscription\')][\'stop_date\'] = stop_date\n modify_kw_kw[line.getAggregate(portal_type=\'Hosting Subscription\')][\'stop_date\'] = stop_date\n
modify_kw_kw[line.getAggregate(portal_type=\'Hosting Subscription\')][\'explanation\'].append(\'Set stop date because of stop_date %s\' % stop_date)\n
elif old_stop_date < now:\n elif old_stop_date < now:\n
new_stop_date = addToDate(old_stop_date, to_add={\'month\': 1})\n new_stop_date = addToDate(old_stop_date, to_add={\'month\': 1})\n
while new_stop_date < now:\n while new_stop_date < now:\n
new_stop_date = addToDate(new_stop_date, to_add={\'month\': 1})\n new_stop_date = addToDate(new_stop_date, to_add={\'month\': 1})\n
hosting_id = line.getAggregate(portal_type=\'Hosting Subscription\')\n hosting_id = line.getAggregate(portal_type=\'Hosting Subscription\')\n
modify_kw_kw.setdefault(hosting_id, {})\n modify_kw_kw.setdefault(hosting_id, {})\n
modify_kw_kw[line.getAggregate(portal_type=\'Hosting Subscription\')].setdefault(\'explanation\', [])\n
modify_kw_kw[line.getAggregate(portal_type=\'Hosting Subscription\')][\'stop_date\'] = new_stop_date\n modify_kw_kw[line.getAggregate(portal_type=\'Hosting Subscription\')][\'stop_date\'] = new_stop_date\n
modify_kw_kw[line.getAggregate(portal_type=\'Hosting Subscription\')][\'explanation\'].append(\'Set stop date becase of new_stop_date %s\' % new_stop_date)\n
\n \n
for (key, value) in add_kw_kw.copy().iteritems():\n for (key, value) in add_kw_kw.copy().iteritems():\n
if stop_date is not None:\n if stop_date is not None:\n
add_kw_kw[key][\'stop_date\'] = stop_date\n add_kw_kw[key][\'stop_date\'] = stop_date\n
add_kw_kw[key][\'explanation\'].append(\'Set stop date beacuse of stop_date %s \' % stop_date)\n
else:\n else:\n
start_date = add_kw_kw[key].get(\'start_date\')\n start_date = add_kw_kw[key].get(\'start_date\')\n
if start_date is not None:\n if start_date is not None:\n
...@@ -135,10 +145,12 @@ for (key, value) in add_kw_kw.copy().iteritems():\n ...@@ -135,10 +145,12 @@ for (key, value) in add_kw_kw.copy().iteritems():\n
while new_stop_date < now:\n while new_stop_date < now:\n
new_stop_date = addToDate(new_stop_date, to_add={\'month\': 1})\n new_stop_date = addToDate(new_stop_date, to_add={\'month\': 1})\n
add_kw_kw[key][\'stop_date\'] = new_stop_date\n add_kw_kw[key][\'stop_date\'] = new_stop_date\n
add_kw_kw[key][\'explanation\'].append(\'Set stop date because of new_stop_date %s\' % new_stop_date)\n
\n \n
for (key, value) in modify_kw_kw.copy().iteritems():\n for (key, value) in modify_kw_kw.copy().iteritems():\n
if stop_date is not None:\n if stop_date is not None:\n
modify_kw_kw[key][\'stop_date\'] = stop_date\n modify_kw_kw[key][\'stop_date\'] = stop_date\n
modify_kw_kw[key][\'explanation\'].append(\'Set stop date because of stop_date %s\' % stop_date)\n
else:\n else:\n
start_date = modify_kw_kw[key].get(\'start_date\')\n start_date = modify_kw_kw[key].get(\'start_date\')\n
if start_date is not None:\n if start_date is not None:\n
...@@ -146,10 +158,11 @@ for (key, value) in modify_kw_kw.copy().iteritems():\n ...@@ -146,10 +158,11 @@ for (key, value) in modify_kw_kw.copy().iteritems():\n
while new_stop_date < now:\n while new_stop_date < now:\n
new_stop_date = addToDate(new_stop_date, to_add={\'month\': 1})\n new_stop_date = addToDate(new_stop_date, to_add={\'month\': 1})\n
modify_kw_kw[key][\'stop_date\'] = new_stop_date\n modify_kw_kw[key][\'stop_date\'] = new_stop_date\n
modify_kw_kw[key][\'explanation\'].append(\'Set stop date because of new_stop_date %s\' % new_stop_date)\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 in remove_hosting_list:\n for (remove_hosting, explanation) in remove_hosting_list:\n
if remove_hosting in add_kw_kw or remove_hosting in modify_kw_kw:\n if remove_hosting in add_kw_kw or remove_hosting in modify_kw_kw:\n
# just added, cannot remove yet\n # just added, cannot remove yet\n
continue\n continue\n
......
...@@ -76,7 +76,7 @@ for cleanup_line in catalog(\n ...@@ -76,7 +76,7 @@ for cleanup_line in catalog(\n
**movement_kw):\n **movement_kw):\n
aggregate = cleanup_line.getAggregate(portal_type=\'Hosting Subscription\')\n aggregate = cleanup_line.getAggregate(portal_type=\'Hosting Subscription\')\n
if aggregate not in remove_hosting_list:\n if aggregate not in remove_hosting_list:\n
remove_hosting_list.append(aggregate)\n remove_hosting_list.append((aggregate, cleanup_line.getPath()))\n
\n \n
for cancelled_line in catalog(\n for cancelled_line in catalog(\n
portal_type=\'Sale Order Line\',\n portal_type=\'Sale Order Line\',\n
...@@ -85,7 +85,7 @@ for cancelled_line in catalog(\n ...@@ -85,7 +85,7 @@ for cancelled_line in catalog(\n
**movement_kw):\n **movement_kw):\n
aggregate = cancelled_line.getAggregate(portal_type=\'Hosting Subscription\')\n aggregate = cancelled_line.getAggregate(portal_type=\'Hosting Subscription\')\n
if aggregate not in remove_hosting_list:\n if aggregate not in remove_hosting_list:\n
remove_hosting_list.append(aggregate)\n remove_hosting_list.append((aggregate, cancelled_line.getPath()))\n
\n \n
subscription_service_relative_url=portal.portal_preferences.getPreferredInstanceSubscriptionResource()\n subscription_service_relative_url=portal.portal_preferences.getPreferredInstanceSubscriptionResource()\n
common_add_kw = dict(\n common_add_kw = dict(\n
...@@ -108,7 +108,7 @@ for order in catalog(\n ...@@ -108,7 +108,7 @@ for order in catalog(\n
title=portal.restrictedTraverse(hosting_subscription).getTitle(),\n title=portal.restrictedTraverse(hosting_subscription).getTitle(),\n
aggregate=hosting_subscription\n aggregate=hosting_subscription\n
)\n )\n
add_kw_list.append(add_kw)\n add_kw_list.append((add_kw, order.getPath()))\n
\n \n
def getWorkflowDate(delivery, state):\n def getWorkflowDate(delivery, state):\n
workflow_item_list = portal.portal_workflow.getInfoFor(ob=delivery, name=\'history\', wf_id=\'packing_list_workflow\')\n workflow_item_list = portal.portal_workflow.getInfoFor(ob=delivery, name=\'history\', wf_id=\'packing_list_workflow\')\n
...@@ -128,7 +128,7 @@ for setup_line in catalog(\n ...@@ -128,7 +128,7 @@ for setup_line in catalog(\n
sort_on=((\'movement.start_date\', \'ascending\'),))\n sort_on=((\'movement.start_date\', \'ascending\'),))\n
# start date shall be stopped state reach\n # start date shall be stopped state reach\n
start_date = getWorkflowDate(real_setup_line.getParentValue(), \'stopped\')\n start_date = getWorkflowDate(real_setup_line.getParentValue(), \'stopped\')\n
start_date_tuple_list.append((setup_line.getAggregate(portal_type=\'Hosting Subscription\'), start_date))\n start_date_tuple_list.append((setup_line.getAggregate(portal_type=\'Hosting Subscription\'), start_date, real_setup_line.getPath()))\n
\n \n
result = person.Person_updateOpenOrder(src__=src__, remove_hosting_list=remove_hosting_list, add_kw_list=add_kw_list, start_date_tuple_list=start_date_tuple_list, stop_date=stop_date)\n result = person.Person_updateOpenOrder(src__=src__, remove_hosting_list=remove_hosting_list, add_kw_list=add_kw_list, start_date_tuple_list=start_date_tuple_list, stop_date=stop_date)\n
from pprint import pformat\n from pprint import pformat\n
......
...@@ -62,6 +62,9 @@ if portal.portal_activities.countMessageWithTag(tag) > 0:\n ...@@ -62,6 +62,9 @@ if portal.portal_activities.countMessageWithTag(tag) > 0:\n
# nothing to do\n # nothing to do\n
return\n return\n
\n \n
def storeWorkflowComment(document, comment):\n
portal.portal_workflow.doActionFor(document, \'edit_action\', comment=comment)\n
\n
add_kw_kw, modify_kw_kw, hs_modify_kw_kw, remove_id_list = context.Person_getOpenOrderDifference(\n add_kw_kw, modify_kw_kw, hs_modify_kw_kw, remove_id_list = context.Person_getOpenOrderDifference(\n
remove_hosting_list=remove_hosting_list, add_kw_list=add_kw_list,\n remove_hosting_list=remove_hosting_list, add_kw_list=add_kw_list,\n
stop_date=stop_date, start_date_tuple_list=start_date_tuple_list)\n stop_date=stop_date, start_date_tuple_list=start_date_tuple_list)\n
...@@ -103,11 +106,17 @@ if previous_open_sale_order is not None:\n ...@@ -103,11 +106,17 @@ if previous_open_sale_order is not None:\n
open_sale_order.validate(activate_kw=activate_kw)\n open_sale_order.validate(activate_kw=activate_kw)\n
\n \n
for kw in add_kw_kw.itervalues():\n for kw in add_kw_kw.itervalues():\n
open_sale_order.newContent(activate_kw=activate_kw, **kw)\n explanation_list = kw.pop(\'explanation\', [])\n
line = open_sale_order.newContent(activate_kw=activate_kw, **kw)\n
for explanation in explanation_list:\n
storeWorkflowComment(line, explanation)\n
\n \n
for hs, kw in modify_kw_kw.iteritems():\n for hs, kw in modify_kw_kw.iteritems():\n
line = [q for q in open_sale_order.contentValues() if q.getAggregate(portal_type=\'Hosting Subscription\') == hs][0]\n line = [q for q in open_sale_order.contentValues() if q.getAggregate(portal_type=\'Hosting Subscription\') == hs][0]\n
explanation_list = kw.pop(\'explanation\', [])\n
line.edit(activate_kw=activate_kw, **kw)\n line.edit(activate_kw=activate_kw, **kw)\n
for explanation in explanation_list:\n
storeWorkflowComment(line, explanation)\n
\n \n
open_sale_order.deleteContent(remove_id_list)\n open_sale_order.deleteContent(remove_id_list)\n
if previous_open_sale_order is not None:\n if previous_open_sale_order is not None:\n
......
684 685
\ 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