Commit 437d9034 authored by Łukasz Nowak's avatar Łukasz Nowak

Reuse templates.

parent d8b2e1e8
......@@ -72,21 +72,11 @@ def getWorkflowDate(document, action):\n
return item.get(\'time\')\n
raise ValueError(\'Document %s has no action %s\' % (document.getPath(), action))\n
\n
subscription_service_relative_url=portal.portal_preferences.getPreferredInstanceSubscriptionResource()\n
common_add_kw = dict(\n
portal_type="Open Sale Order Line",\n
quantity=1,\n
quantity_unit="unit/piece",\n
# XXX Hardcoded values\n
resource=subscription_service_relative_url,\n
price=portal.restrictedTraverse(subscription_service_relative_url).getSaleSupplyLineBasePrice()\n
)\n
for hosting_subscription in portal.portal_catalog(\n
portal_type=\'Hosting Subscription\',\n
**hosting_kw\n
):\n
add_kw = common_add_kw.copy()\n
add_kw.update(\n
add_kw = dict(\n
title=hosting_subscription.getTitle(),\n
aggregate=hosting_subscription.getRelativeUrl()\n
)\n
......
......@@ -79,14 +79,13 @@ previous_open_sale_order = portal.portal_catalog.getResultValue(\n
validation_state="validated")\n
\n
if previous_open_sale_order is None:\n
open_sale_order = portal.open_sale_order_module.newContent(\n
source=\'organisation_module/vifib_internet\',\n
source_section=\'organisation_module/vifib_internet\',\n
open_sale_order_template = portal.restrictedTraverse(\n
portal.portal_preferences.getPreferredOpenSaleOrderTemplate())\n
open_sale_order = open_sale_order_template.Base_createCloneDocument(batch_mode=1)\n
open_sale_order.edit(\n
destination_section=person.getRelativeUrl(),\n
destination_decision=person.getRelativeUrl(),\n
destination=person.getRelativeUrl(),\n
price_currency=\'currency_module/EUR\',\n
specialise=\'sale_trade_condition_module/vifib_trade_condition\',\n
title="SlapOS Subscription Open Sale Order",\n
effective_date=now,\n
activate_kw=activate_kw)\n
......@@ -102,9 +101,13 @@ if previous_open_sale_order is not None:\n
open_sale_order.order(activate_kw=activate_kw)\n
open_sale_order.validate(activate_kw=activate_kw)\n
\n
open_sale_order_line_template = portal.restrictedTraverse(\n
portal.portal_preferences.getPreferredOpenSaleOrderLineTemplate())\n
for kw in add_kw_kw.itervalues():\n
explanation_list = kw.pop(\'explanation\', [])\n
line = open_sale_order.newContent(activate_kw=activate_kw, **kw)\n
line = open_sale_order_line_template.Base_createCloneDocument(batch_mode=1,\n
destination=open_sale_order)\n
line.edit(activate_kw=activate_kw, **kw)\n
for explanation in explanation_list:\n
storeWorkflowComment(line, explanation)\n
\n
......
......@@ -231,8 +231,10 @@ class TestHostingSubscription_requestUpdateOpenSaleOrder(testSlapOSMixin):
line = open_sale_order_line_list[0].getObject()
self.assertEqual(subscription.getRelativeUrl(), line.getAggregate())
self.assertEqual(self.portal.portal_preferences\
.getPreferredInstanceSubscriptionResource(), line.getResource())
open_sale_order_line_template = self.portal.restrictedTraverse(
self.portal.portal_preferences.getPreferredOpenSaleOrderLineTemplate())
self.assertEqual(open_sale_order_line_template.getResource(),
line.getResource())
self.assertEqual(None, line.getStartDate())
def test_usualLifetime_HostingSubscription(self):
......@@ -276,8 +278,10 @@ class TestHostingSubscription_requestUpdateOpenSaleOrder(testSlapOSMixin):
line = open_sale_order_line_list[0].getObject()
self.assertEqual(subscription.getRelativeUrl(), line.getAggregate())
self.assertEqual(self.portal.portal_preferences\
.getPreferredInstanceSubscriptionResource(), line.getResource())
open_sale_order_line_template = self.portal.restrictedTraverse(
self.portal.portal_preferences.getPreferredOpenSaleOrderLineTemplate())
self.assertEqual(open_sale_order_line_template.getResource(),
line.getResource())
self.assertEqual(request_time, line.getStartDate())
destroy_time = DateTime('2012/02/01')
......@@ -325,8 +329,7 @@ class TestHostingSubscription_requestUpdateOpenSaleOrder(testSlapOSMixin):
self.assertEqual(subscription.getRelativeUrl(),
archived_line.getAggregate())
self.assertEqual(self.portal.portal_preferences\
.getPreferredInstanceSubscriptionResource(),
self.assertEqual(open_sale_order_line_template.getResource(),
archived_line.getResource())
self.assertEqual(request_time, archived_line.getStartDate())
......
13
\ No newline at end of file
14
\ 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