Commit edd1d89b authored by Romain Courteaud's avatar Romain Courteaud

slapos_cloud: ensure created Support Request is linked to a Project

parent c1ab32e0
...@@ -9,10 +9,11 @@ try: ...@@ -9,10 +9,11 @@ try:
support_request_title = kwargs['support_request_title'] support_request_title = kwargs['support_request_title']
resource = kwargs['support_request_resource'] resource = kwargs['support_request_resource']
description = kwargs['support_request_description'] description = kwargs['support_request_description']
project_reference = kwargs['project_reference']
# Aggregate can be None, so it isn't included on the kwargs # Aggregate can be None, so it isn't included on the kwargs
aggregate = kwargs.get("support_request_aggregate", None) aggregate = kwargs.get("support_request_aggregate", None)
except KeyError: except KeyError:
raise TypeError, "Person_requestSupportRequest takes exactly 4 arguments" raise TypeError, "Person_requestSupportRequest takes exactly 5 arguments"
tag = "%s_%s_SupportRequestInProgress" % (person.getUid(), tag = "%s_%s_SupportRequestInProgress" % (person.getUid(),
support_request_title) support_request_title)
...@@ -21,6 +22,12 @@ if (portal.portal_activities.countMessageWithTag(tag) > 0): ...@@ -21,6 +22,12 @@ if (portal.portal_activities.countMessageWithTag(tag) > 0):
# As it is not possible to fetch informations, it is better to raise an error # As it is not possible to fetch informations, it is better to raise an error
raise NotImplementedError(tag) raise NotImplementedError(tag)
# Ensure project is correctly set
project_list = portal.portal_catalog.portal_catalog(portal_type='Project', reference=project_reference,
validation_state='validated', limit=2)
if len(project_list) != 1:
raise NotImplementedError("%i projects '%s'" % (len(project_list), project_reference))
support_request_portal_type = "Support Request" support_request_portal_type = "Support Request"
module = portal.getDefaultModule(portal_type=support_request_portal_type) module = portal.getDefaultModule(portal_type=support_request_portal_type)
...@@ -30,6 +37,7 @@ support_request = module.newContent( ...@@ -30,6 +37,7 @@ support_request = module.newContent(
description=description, description=description,
resource=resource, resource=resource,
destination_decision_value=person, destination_decision_value=person,
destination_project_value=project_list[0],
aggregate=aggregate, aggregate=aggregate,
specialise="sale_trade_condition_module/slapos_ticket_trade_condition", specialise="sale_trade_condition_module/slapos_ticket_trade_condition",
activate_kw={'tag': tag} activate_kw={'tag': tag}
......
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