Commit ab0dd57f authored by Romain Courteaud's avatar Romain Courteaud

slapos_subscription_request: stop creating project from subscription request

It is too complex (as it requires to create Trade Condition, Assignment, Project, etc...), and I don't know for now how to make something generic from it.
Use a custom action for now.
parent 66b0138e
...@@ -6,6 +6,7 @@ if subscriber_person_value is None: ...@@ -6,6 +6,7 @@ if subscriber_person_value is None:
source_project_value = None source_project_value = None
destination_project_value = None destination_project_value = None
item = None
if resource.getPortalType() == "Software Product": if resource.getPortalType() == "Software Product":
source_project_value = project_value source_project_value = project_value
...@@ -15,8 +16,9 @@ elif resource.getPortalType() == "Service": ...@@ -15,8 +16,9 @@ elif resource.getPortalType() == "Service":
raise AssertionError('A project is required for %s %s' % (resource.getRelativeUrl(), project_value)) raise AssertionError('A project is required for %s %s' % (resource.getRelativeUrl(), project_value))
destination_project_value = project_value destination_project_value = project_value
elif resource.getRelativeUrl() == "service_module/slapos_virtual_master_subscription": elif resource.getRelativeUrl() == "service_module/slapos_virtual_master_subscription":
if project_value is not None: if project_value is None:
raise AssertionError('No project is required for %s %s' % (resource.getRelativeUrl(), project_value)) raise AssertionError('Project is required for %s %s' % (resource.getRelativeUrl(), project_value))
item = project_value
else: else:
raise NotImplementedError('Unsupported resource: %s' % resource.getRelativeUrl()) raise NotImplementedError('Unsupported resource: %s' % resource.getRelativeUrl())
else: else:
...@@ -104,7 +106,7 @@ subscription_request = portal.subscription_request_module.newContent( ...@@ -104,7 +106,7 @@ subscription_request = portal.subscription_request_module.newContent(
effective_date=now, effective_date=now,
resource_value=resource, resource_value=resource,
variation_category_list=variation_category_list, variation_category_list=variation_category_list,
# XXX aggregate_value=item, aggregate_value=item,
quantity_unit=resource.getQuantityUnit(), quantity_unit=resource.getQuantityUnit(),
quantity=1, quantity=1,
ledger="automated", ledger="automated",
......
subscription_request = context subscription_request = context
portal = context.getPortalObject()
item = subscription_request.getAggregateValue() item = subscription_request.getAggregateValue()
if item is None: if item is None:
resource = subscription_request.getResourceValue() resource = subscription_request.getResourceValue()
customer = subscription_request.getSourceValue() raise ValueError('Unsupported resource: %s' % resource.getRelativeUrl())
if resource.getPortalType() == "Service":
if resource.getRelativeUrl() == "service_module/slapos_virtual_master_subscription":
# create the project
item = portal.project_module.newContent(
portal_type='Project',
destination_value=customer
)
item.validate()
# and create default assignments for the user
# who can manage compute nodes and create instances
customer.newContent(
portal_type='Assignment',
destination_project_value=item,
function='production/manager'
).open()
customer.newContent(
portal_type='Assignment',
destination_project_value=item,
function='customer'
).open()
sale_trade_condition = portal.sale_trade_condition_module.newContent(
portal_type="Sale Trade Condition",
reference='node_project_%s' % item.getTitle(),
# XXX hardcoded
specialise="business_process_module/slapos_ultimate_business_process",
destination_project_value=item,
source_value=subscription_request.getDestinationValue(),
#source_section_value=subscription_request.getDestinationSectionValue(),
#destination_section_value=subscription_request.getDestinationSectionValue(),
#source_section_value=seller_organisation,
#source_payment_value=seller_bank_account,
price_currency_value=subscription_request.getPriceCurrencyValue(),
#payment_condition_payment_mode='test-%s' % self.generateNewId()
)
sale_trade_condition.validate()
sale_trade_condition = portal.sale_trade_condition_module.newContent(
portal_type="Sale Trade Condition",
reference='instance_project_%s' % item.getTitle(),
# XXX hardcoded
specialise="business_process_module/slapos_ultimate_business_process",
source_project_value=item,
source_value=subscription_request.getDestinationValue(),
#source_section_value=subscription_request.getDestinationSectionValue(),
#destination_section_value=subscription_request.getDestinationSectionValue(),
#source_section_value=seller_organisation,
#source_payment_value=seller_bank_account,
price_currency_value=subscription_request.getPriceCurrencyValue(),
#payment_condition_payment_mode='test-%s' % self.generateNewId()
)
"""
sale_trade_condition.newContent(
portal_type="Trade Model Line",
reference="VAT",
resource="service_module/slapos_tax",
base_application="base_amount/invoicing/taxable",
trade_phase="slapos/tax",
price=0.2,
quantity=1.0,
membership_criterion_base_category=('price_currency',),
membership_criterion_category=('price_currency/%s' % currency.getRelativeUrl(),)
)"""
sale_trade_condition.validate()
else:
raise ValueError('Unsupported resource: %s' % resource.getRelativeUrl())
else:
raise ValueError('Unsupported resource: %s' % resource.getRelativeUrl())
# Use list setter, to ensure it crashes if item is still None # Use list setter, to ensure it crashes if item is still None
subscription_request.setAggregateValueList([item]) # subscription_request.setAggregateValueList([item])
subscription_request.SubscriptionRequest_createOpenSaleOrder() subscription_request.SubscriptionRequest_createOpenSaleOrder()
subscription_request.validate() subscription_request.validate()
......
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