Commit 6362259e authored by Romain Courteaud's avatar Romain Courteaud

slapos_cloud: Computer Network creation requires a project reference

parent f77ba5b7
......@@ -8,20 +8,32 @@ kwargs = state_change.kwargs
try:
computer_network_title = kwargs['network_title']
except KeyError:
raise TypeError, "Person_requestNetwork takes exactly 1 argument"
raise TypeError, "Person_requestNetwork takes exactly 2 arguments. Missing network_title."
tag = "%s_%s_NetworkInProgress" % (person.getUid(),
try:
project_reference = kwargs['project_reference']
except KeyError:
raise TypeError, "Person_requestNetwork takes exactly 2 arguments. Missing project_reference."
tag = "%s_%s_NetworkInProgress" % (person.getUid(),
computer_network_title)
if (portal.portal_activities.countMessageWithTag(tag) > 0):
# The software instance is already under creation but can not be fetched from catalog
# As it is not possible to fetch informations, it is better to raise an error
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))
computer_network_portal_type = "Computer Network"
computer_network_list = portal.portal_catalog.portal_catalog(
portal_type=computer_network_portal_type,
title=computer_network_title,
validation_state="validated",
follow_up__uid=project_list[0].getUid(),
#validation_state="validated",
limit=2)
if len(computer_network_list) == 2:
......@@ -35,6 +47,7 @@ else:
portal_type=computer_network_portal_type,
title=computer_network_title,
source_administration=person.getRelativeUrl(),
follow_up_value=project_list[0],
activate_kw={'tag': tag}
)
context.REQUEST.set("computer_network_relative_url", computer_network.getRelativeUrl())
......
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