Commit 291e99cb authored by Rafael Monnerat's avatar Rafael Monnerat

Extending Internal API using *_slap_interface_workflow

This MR aims to introduce and extend the internal API with the support for manage:

   - Project
   - Organisation
   - Site (also Organisation)
   - Tokens
   - Computer Network
   
So via the introductions of workflows we included the following methods:

  - Project.approveRegistration()
  - Project.leaveProject()
  - Project.acceptInvitation()
  - Organisation.approveRegistration()
  - Organisation.leaveOrganisation()
  - Organisation.acceptInvitation()
  - Person.requestProject(project_title)
  - Person.requestOrganisation(organisation_title)
  - Person.requestSite(organisation_title)
  - Person.requestToken(request_url)
  - Person.requestNetwork(network_title)
  - ComputeNote.requestTransfer(...)
  - InstanceTree.requestTransfer(...) 
  - ComputerNetwork.approveRegistration()
  - ComputerNetwork.requestTransfer(...)
 
  
This API with minor exceptions, don't replaces the way the Hateoas/JIO website interacts with ERP5, so the original scripts are kept and just changed to call internal APIs.


See merge request nexedi/slapos.core!348
parents a580f609 82a3b8c6
...@@ -7,6 +7,10 @@ ...@@ -7,6 +7,10 @@
<type>Compute Partition</type> <type>Compute Partition</type>
<workflow>compute_partition_slap_interface_workflow</workflow> <workflow>compute_partition_slap_interface_workflow</workflow>
</chain> </chain>
<chain>
<type>Computer Network</type>
<workflow>network_slap_interface_workflow</workflow>
</chain>
<chain> <chain>
<type>Hosting Subscription</type> <type>Hosting Subscription</type>
<workflow>edit_workflow</workflow> <workflow>edit_workflow</workflow>
...@@ -15,10 +19,18 @@ ...@@ -15,10 +19,18 @@
<type>Instance Tree</type> <type>Instance Tree</type>
<workflow>edit_workflow, instance_slap_interface_workflow, instance_tree_workflow</workflow> <workflow>edit_workflow, instance_slap_interface_workflow, instance_tree_workflow</workflow>
</chain> </chain>
<chain>
<type>Organisation</type>
<workflow>organisation_slap_interface_workflow</workflow>
</chain>
<chain> <chain>
<type>Person</type> <type>Person</type>
<workflow>person_slap_interface_workflow</workflow> <workflow>person_slap_interface_workflow</workflow>
</chain> </chain>
<chain>
<type>Project</type>
<workflow>project_slap_interface_workflow</workflow>
</chain>
<chain> <chain>
<type>Slave Instance</type> <type>Slave Instance</type>
<workflow>edit_workflow, instance_slap_interface_workflow, item_workflow, slapos_cloud_interaction_workflow</workflow> <workflow>edit_workflow, instance_slap_interface_workflow, item_workflow, slapos_cloud_interaction_workflow</workflow>
......
""" """
Create an internal Packing List and attach the compute_node Create an internal Packing List and attach the compute_node
""" """
from DateTime import DateTime context.requestTransfer(
from zExceptions import Unauthorized
user = context.getPortalObject().portal_membership.getAuthenticatedMember().getUserValue()
if user is None or user.getRelativeUrl() != context.getSourceAdministration():
raise Unauthorized("Only the compute_node owner can Transfer compute_node from one location to another.")
portal_type = "Internal Packing List"
source = context.Item_getCurrentSiteValue()
source_project = context.Item_getCurrentProjectValue()
source_section = context.Item_getCurrentOwnerValue()
resource_value = context.Item_getResourceValue()
if destination_project is None and source_project is not None:
destination_project = source_project.getRelativeUrl()
if destination_section is None:
destination_section = context.getSourceAdministration()
if destination is None and source is not None:
# We do not change location of the machine
destination = source.getRelativeUrl()
if source is None and destination is None:
raise ValueError("Sorry, destination is required for the initial set.")
if source_section is None:
source_section = context.getSourceAdministration()
resource_value = context.product_module.compute_node
module = context.getDefaultModule(portal_type=portal_type)
line_portal_type = '%s Line' % portal_type
delivery = module.newContent(title="Transfer %s to %s" % (context.getTitle(), destination),
source_value=source,
source_section_value=source_section,
source_project_value=source_project,
destination=destination, destination=destination,
destination_section=destination_section, destination_project=destination_project,
source_decision=destination_section, destination_section=destination_section
destination_decision=destination_section, )
destination_project_value=destination_project,
start_date=DateTime(),
stop_date=DateTime(),
portal_type=portal_type)
delivery_line = delivery.newContent(
portal_type=line_portal_type,
title=context.getReference(),
quantity_unit=context.getQuantityUnit(),
resource_value=resource_value)
delivery_line.edit(
price=0.0,
quantity=1.0,
aggregate_value=context)
delivery.confirm()
delivery.stop()
delivery.deliver()
...@@ -52,15 +52,6 @@ ...@@ -52,15 +52,6 @@
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>destination=None, destination_project=None, destination_section=None</string> </value> <value> <string>destination=None, destination_project=None, destination_section=None</string> </value>
</item> </item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>ComputeNode_createMovement</string> </value> <value> <string>ComputeNode_createMovement</string> </value>
......
""" """
Create an internal Packing List and attach the compute_node Create an internal Packing List and attach the compute_node
""" """
from DateTime import DateTime context.requestTransfer(
from zExceptions import Unauthorized
user = context.getPortalObject().portal_membership.getAuthenticatedMember().getUserValue()
if user is None or user.getRelativeUrl() != context.getSourceAdministration():
raise Unauthorized("Only the Computer Network owner can transfer it from one location to another.")
portal_type = "Internal Packing List"
source_project = context.Item_getCurrentProjectValue()
source_section = context.Item_getCurrentOwnerValue()
if destination_project is None and source_project is not None:
destination_project = source_project.getRelativeUrl()
if source_section is None:
source_section = context.getSourceAdministrationValue()
if destination_section is None:
destination_section = source_section.getRelativeUrl()
source = context.getSourceAdministration()
destination = context.getSourceAdministration()
resource_value = context.product_module.compute_node
module = context.getDefaultModule(portal_type=portal_type)
line_portal_type = '%s Line' % portal_type
delivery = module.newContent(title="Transfer %s to %s" % (context.getTitle(), destination_project),
source=source,
source_section_value=source_section,
source_project_value=source_project,
destination=destination,
destination_section=destination_section,
source_decision=destination_section,
destination_decision=destination_section,
destination_project=destination_project, destination_project=destination_project,
start_date=DateTime(), destination_section=destination_section
stop_date=DateTime(), )
portal_type=portal_type)
delivery_line = delivery.newContent(
portal_type=line_portal_type,
title=context.getReference(),
quantity_unit=resource_value.getQuantityUnit(),
resource_value=resource_value)
delivery_line.edit(
price=0.0,
quantity=1.0,
aggregate=context.getRelativeUrl())
delivery.confirm()
delivery.stop()
delivery.deliver()
portal = context.getPortalObject()
reference = "NET-%s" % portal.portal_ids.generateNewId(
id_group='slap_network_reference',
id_generator='uid')
context.edit(reference=reference)
""" """
Create an internal Packing List and attach the compute_node Create an internal Packing List and attach the compute_node
""" """
from DateTime import DateTime context.requestTransfer(
from zExceptions import Unauthorized
user = context.getPortalObject().portal_membership.getAuthenticatedMember().getUserValue()
if user is None or user.getRelativeUrl() != context.getDestinationSection():
raise Unauthorized("Only the Instance Tree owner can transfer it from one location to another.")
portal_type = "Internal Packing List"
source = context.Item_getCurrentSiteValue()
source_project = context.Item_getCurrentProjectValue()
source_section = context.Item_getCurrentOwnerValue()
resource_value = context.Item_getResourceValue()
if destination_project is None and source_project is not None:
destination_project = source_project.getRelativeUrl()
destination_section = context.getDestinationSection()
if source_section is None:
source_section = context.getDestinationSectionValue()
if destination is None and source is not None:
destination = source.getRelativeUrl()
resource_value = context.product_module.compute_node
module = context.getDefaultModule(portal_type=portal_type)
line_portal_type = '%s Line' % portal_type
delivery = module.newContent(title="Transfer %s to %s" % (context.getTitle(), destination_project),
source_value=source,
source_section_value=source_section,
source_project_value=source_project,
destination=destination, destination=destination,
destination_section=destination_section, destination_project=destination_project
source_decision=destination_section, )
destination_decision=destination_section,
destination_project_value=destination_project,
start_date=DateTime(),
stop_date=DateTime(),
portal_type=portal_type)
delivery_line = delivery.newContent(
portal_type=line_portal_type,
title=context.getReference(),
quantity_unit=context.getQuantityUnit(),
resource_value=resource_value)
delivery_line.edit(
price=0.0,
quantity=1.0,
aggregate_value=context)
delivery.confirm()
delivery.stop()
delivery.deliver()
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
import transaction
from time import sleep
from zExceptions import Unauthorized
from unittest import expectedFailure
from Products.ERP5Type.Errors import UnsupportedWorkflowMethod
class TestSlapOSCoreComputeNodeSlapInterfaceWorkflow(SlapOSTestCaseMixin):
def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
# Clone compute_node document
self.compute_node = self.portal.compute_node_module.template_compute_node\
.Base_createCloneDocument(batch_mode=1)
new_id = self.generateNewId()
self.compute_node.edit(
title="compute node %s" % (new_id, ),
reference="TESTCOMP-%s" % (new_id, )
)
self.compute_node.validate()
self.tic()
def beforeTearDown(self):
SlapOSTestCaseMixin.beforeTearDown(self)
self.portal.REQUEST['compute_node_key'] = None
self.portal.REQUEST['compute_node_certificate'] = None
def test_generateCertificate(self):
self.login(self.compute_node.getUserId())
self.compute_node.generateCertificate()
compute_node_key = self.portal.REQUEST.get('compute_node_key')
compute_node_certificate = self.portal.REQUEST.get('compute_node_certificate')
self.assertNotEqual(None, compute_node_key)
self.assertNotEqual(None, compute_node_certificate)
self.assertNotEqual(None, self.compute_node.getDestinationReference())
serial = '0x%x' % int(self.compute_node.getDestinationReference(), 16)
self.assertTrue(serial in compute_node_certificate)
self.assertTrue(self.compute_node.getReference() in compute_node_certificate.decode('string_escape'))
def test_generateCertificate_twice(self):
self.login(self.compute_node.getUserId())
self.compute_node.generateCertificate()
compute_node_key = self.portal.REQUEST.get('compute_node_key')
compute_node_certificate = self.portal.REQUEST.get('compute_node_certificate')
self.assertNotEqual(None, compute_node_key)
self.assertNotEqual(None, compute_node_certificate)
self.assertNotEqual(None, self.compute_node.getDestinationReference())
serial = '0x%x' % int(self.compute_node.getDestinationReference(), 16)
self.assertTrue(serial in compute_node_certificate)
self.assertTrue(self.compute_node.getReference() in compute_node_certificate.decode('string_escape'))
self.assertRaises(ValueError, self.compute_node.generateCertificate)
self.assertEqual(None, self.portal.REQUEST.get('compute_node_key'))
self.assertEqual(None, self.portal.REQUEST.get('compute_node_certificate'))
def test_approveComputeNodeRegistration(self):
self.person_user = self.makePerson()
self.login(self.person_user.getUserId())
compute_node = self.portal.compute_node_module.newContent(portal_type='Compute Node',
title="Compute Node %s for %s" % (self.new_id, self.person_user.getReference()),
reference="TESTCOMP-%s" % self.new_id)
compute_node.requestComputeNodeRegistration()
compute_node.approveComputeNodeRegistration()
self.assertEqual('open/personal', compute_node.getAllocationScope())
self.assertEqual(self.person_user.getRelativeUrl(),
compute_node.getSourceAdministration())
self.assertEqual('validated', compute_node.getValidationState())
def _countInstanceBang(self, instance, comment):
return len([q for q in instance.workflow_history[
'instance_slap_interface_workflow'] if q['action'] == 'bang' and \
q['comment'] == comment])
def _countComputeNodeeBang(self, compute_node, comment):
return len([q for q in compute_node.workflow_history[
'compute_node_slap_interface_workflow'] if q['action'] == \
'report_compute_node_bang' and q['comment'] == comment])
def test_reportComputeNodeBang(self):
self._makeComplexComputeNode()
self.login(self.compute_node.getUserId())
comment = 'Bang from compute_node'
started_instance = self.compute_node.partition1.getAggregateRelatedValue(
portal_type='Software Instance')
stopped_instance = self.compute_node.partition2.getAggregateRelatedValue(
portal_type='Software Instance')
destroyed_instance1 = self.compute_node.partition3.getAggregateRelatedValue(
portal_type='Software Instance')
destroyed_instance2 = self.compute_node.partition4.getAggregateRelatedValue(
portal_type='Software Instance')
# test sanity check -- do not trust _makeComplexComputeNode
self.assertEqual('start_requested', started_instance.getSlapState())
self.assertEqual('stop_requested', stopped_instance.getSlapState())
self.assertEqual('destroy_requested', destroyed_instance1.getSlapState())
self.assertEqual('destroy_requested', destroyed_instance2.getSlapState())
# store counts before bang
compute_node_bang_count = self._countComputeNodeeBang(self.compute_node, comment)
started_instance_bang_count = self._countInstanceBang(started_instance,
comment)
stopped_instance_bang_count = self._countInstanceBang(stopped_instance,
comment)
destroyed_instance1_bang_count = self._countInstanceBang(
destroyed_instance1, comment)
destroyed_instance2_bang_count = self._countInstanceBang(
destroyed_instance2, comment)
self.compute_node.reportComputeNodeBang(comment=comment)
self.tic()
self.assertEqual(1+compute_node_bang_count,
self._countComputeNodeeBang(self.compute_node, comment))
self.assertEqual(1+started_instance_bang_count,
self._countInstanceBang(started_instance, comment))
self.assertEqual(1+stopped_instance_bang_count,
self._countInstanceBang(stopped_instance, comment))
self.assertEqual(destroyed_instance1_bang_count,
self._countInstanceBang(destroyed_instance1, comment))
self.assertEqual(destroyed_instance2_bang_count,
self._countInstanceBang(destroyed_instance2, comment))
def test_requestSoftwareRelease_software_release_url_required(self):
self.person_user = self.makePerson()
self.compute_node.edit(source_administration=self.person_user.getRelativeUrl())
self.tic()
self.login(self.person_user.getUserId())
self.assertRaises(TypeError, self.compute_node.requestSoftwareRelease,
state='available')
transaction.abort()
def test_requestSoftwareRelease_state_required(self):
self.person_user = self.makePerson()
self.compute_node.edit(source_administration=self.person_user.getRelativeUrl())
self.tic()
self.login(self.person_user.getUserId())
url = self.generateNewSoftwareReleaseUrl()
self.assertRaises(TypeError, self.compute_node.requestSoftwareRelease,
software_release_url=url)
transaction.abort()
def test_requestSoftwareRelease_available(self):
self.person_user = self.makePerson()
self.compute_node.edit(source_administration=self.person_user.getRelativeUrl())
self.tic()
self.login(self.person_user.getUserId())
url = self.generateNewSoftwareReleaseUrl()
self.compute_node.requestSoftwareRelease(software_release_url=url,
state='available')
self.tic()
self.login()
software_installation = self.compute_node.getAggregateRelatedValue(
portal_type='Software Installation')
self.assertEqual('start_requested', software_installation.getSlapState())
self.assertEqual(url, software_installation.getUrlString())
self.assertEqual('validated', software_installation.getValidationState())
def test_requestSoftwareRelease_destroyed(self):
self.person_user = self.makePerson()
self.compute_node.edit(source_administration=self.person_user.getRelativeUrl())
self.tic()
self.login(self.person_user.getUserId())
url = self.generateNewSoftwareReleaseUrl()
self.compute_node.requestSoftwareRelease(software_release_url=url,
state='destroyed')
self.tic()
self.login()
software_installation = self.compute_node.getAggregateRelatedValue(
portal_type='Software Installation')
self.assertEqual(None, software_installation)
def test_requestSoftwareRelease_available_destroyed(self):
self.person_user = self.makePerson()
self.compute_node.edit(source_administration=self.person_user.getRelativeUrl())
self.tic()
self.login(self.person_user.getUserId())
url = self.generateNewSoftwareReleaseUrl()
self.compute_node.requestSoftwareRelease(software_release_url=url,
state='available')
self.tic()
self.login()
software_installation = self.compute_node.getAggregateRelatedValue(
portal_type='Software Installation')
self.assertEqual('start_requested', software_installation.getSlapState())
self.assertEqual(url, software_installation.getUrlString())
self.assertEqual('validated', software_installation.getValidationState())
self.login(self.person_user.getUserId())
self.compute_node.requestSoftwareRelease(software_release_url=url,
state='destroyed')
self.tic()
self.login()
software_installation = self.compute_node.getAggregateRelatedValue(
portal_type='Software Installation')
self.assertEqual('destroy_requested', software_installation.getSlapState())
self.assertEqual(url, software_installation.getUrlString())
self.assertEqual('validated', software_installation.getValidationState())
def test_requestSoftwareRelease_not_indexed(self):
self.person_user = self.makePerson()
self.compute_node.edit(source_administration=self.person_user.getRelativeUrl())
self.tic()
self.login(self.person_user.getUserId())
url = self.generateNewSoftwareReleaseUrl()
self.compute_node.requestSoftwareRelease(software_release_url=url,
state='available')
transaction.commit()
self.assertRaises(NotImplementedError,
self.compute_node.requestSoftwareRelease, software_release_url=url,
state='available')
transaction.abort()
@expectedFailure
def test_requestSoftwareRelease_same_transaction(self):
self.person_user = self.makePerson()
self.compute_node.edit(source_administration=self.person_user.getRelativeUrl())
self.tic()
self.login(self.person_user.getUserId())
url = self.generateNewSoftwareReleaseUrl()
self.compute_node.requestSoftwareRelease(software_release_url=url,
state='available')
self.assertRaises(NotImplementedError,
self.compute_node.requestSoftwareRelease, software_release_url=url,
state='available')
transaction.abort()
def test_revokeCertificate(self):
self.login(self.compute_node.getUserId())
self.compute_node.generateCertificate()
compute_node_key = self.portal.REQUEST.get('compute_node_key')
compute_node_certificate = self.portal.REQUEST.get('compute_node_certificate')
self.assertNotEqual(None, compute_node_key)
self.assertNotEqual(None, compute_node_certificate)
self.assertNotEqual(None, self.compute_node.getDestinationReference())
serial = '0x%x' % int(self.compute_node.getDestinationReference(), 16)
self.assertTrue(serial in compute_node_certificate)
self.assertTrue(self.compute_node.getReference() in compute_node_certificate.decode('string_escape'))
self.compute_node.revokeCertificate()
self.assertEqual(None, self.portal.REQUEST.get('compute_node_key'))
self.assertEqual(None, self.portal.REQUEST.get('compute_node_certificate'))
self.assertEqual(None, self.compute_node.getDestinationReference())
def test_revokeCertificateNoCertificate(self):
self.login(self.compute_node.getUserId())
self.assertRaises(ValueError, self.compute_node.revokeCertificate)
self.assertEqual(None, self.portal.REQUEST.get('compute_node_key'))
self.assertEqual(None, self.portal.REQUEST.get('compute_node_certificate'))
self.assertEqual(None, self.compute_node.getDestinationReference())
def test_revokeCertificate_twice(self):
self.login(self.compute_node.getUserId())
self.compute_node.generateCertificate()
compute_node_key = self.portal.REQUEST.get('compute_node_key')
compute_node_certificate = self.portal.REQUEST.get('compute_node_certificate')
self.assertNotEqual(None, compute_node_key)
self.assertNotEqual(None, compute_node_certificate)
self.assertNotEqual(None, self.compute_node.getDestinationReference())
serial = '0x%x' % int(self.compute_node.getDestinationReference(), 16)
self.assertTrue(serial in compute_node_certificate)
self.assertTrue(self.compute_node.getReference() in compute_node_certificate.decode('string_escape'))
self.compute_node.revokeCertificate()
self.assertEqual(None, self.portal.REQUEST.get('compute_node_key'))
self.assertEqual(None, self.portal.REQUEST.get('compute_node_certificate'))
self.assertEqual(None, self.compute_node.getDestinationReference())
self.assertRaises(ValueError, self.compute_node.revokeCertificate)
self.assertEqual(None, self.portal.REQUEST.get('compute_node_key'))
self.assertEqual(None, self.portal.REQUEST.get('compute_node_certificate'))
self.assertEqual(None, self.compute_node.getDestinationReference())
class TestSlapOSCoreComputeNodeSlapInterfaceWorkflowSupply(SlapOSTestCaseMixin):
def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
portal = self.getPortalObject()
# Clone compute_node document
compute_node = portal.compute_node_module.template_compute_node\
.Base_createCloneDocument(batch_mode=1)
# Clone person document
person_user = self.makePerson(new_id=self.new_id, index=0)
compute_node.edit(
title="Compute Node %s for %s" % (self.new_id, person_user.getReference()),
reference="TESTCOMP-%s" % self.new_id,
source_administration=person_user.getRelativeUrl()
)
compute_node.validate()
self.compute_node = compute_node
self.tic()
# Login as new user
self.login(person_user.getUserId())
new_person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.assertEqual(person_user.getRelativeUrl(), new_person.getRelativeUrl())
def beforeTearDown(self):
if 'software_installation_url' in self.compute_node.REQUEST:
self.compute_node.REQUEST['software_installation_url'] = None
def test_supply_requiredParameter(self):
software_release = self.generateNewSoftwareReleaseUrl()
self.assertRaises(TypeError, self.compute_node.requestSoftwareRelease)
self.assertRaises(TypeError, self.compute_node.requestSoftwareRelease,
state="available")
self.assertRaises(TypeError, self.compute_node.requestSoftwareRelease,
software_release_url=software_release)
self.assertRaises(ValueError, self.compute_node.requestSoftwareRelease,
state="mana", software_release_url=software_release)
def test_supply_available(self):
software_release = self.generateNewSoftwareReleaseUrl()
self.compute_node.requestSoftwareRelease(state="available",
software_release_url=software_release)
software_installation_url = self.compute_node.REQUEST.get(
'software_installation_url')
self.assertNotEqual(None, software_installation_url)
software_installation = self.compute_node.restrictedTraverse(
software_installation_url)
self.assertEqual(software_release, software_installation.getUrlString())
def test_supply_destroyed(self):
software_release = self.generateNewSoftwareReleaseUrl()
self.compute_node.requestSoftwareRelease(state="destroyed",
software_release_url=software_release)
software_installation_url = self.compute_node.REQUEST.get(
'software_installation_url')
self.assertEqual(None, software_installation_url)
def test_supply_available_nonIndexed(self):
software_release = self.generateNewSoftwareReleaseUrl()
self.compute_node.requestSoftwareRelease(state="available",
software_release_url=software_release)
software_installation_url = self.compute_node.REQUEST.get(
'software_installation_url')
self.assertNotEqual(None, software_installation_url)
software_installation = self.compute_node.restrictedTraverse(
software_installation_url)
self.assertEqual(software_release, software_installation.getUrlString())
transaction.commit()
self.assertRaises(NotImplementedError,
self.compute_node.requestSoftwareRelease, state="available",
software_release_url=software_release)
def test_supply_available_destroyed_nonIndexed(self):
software_release = self.generateNewSoftwareReleaseUrl()
self.compute_node.requestSoftwareRelease(state="available",
software_release_url=software_release)
software_installation_url = self.compute_node.REQUEST.get(
'software_installation_url')
self.assertNotEqual(None, software_installation_url)
software_installation = self.compute_node.restrictedTraverse(
software_installation_url)
self.assertEqual(software_release, software_installation.getUrlString())
transaction.commit()
self.assertRaises(NotImplementedError,
self.compute_node.requestSoftwareRelease, state="destroyed",
software_release_url=software_release)
def test_supply_available_createdSoftwareInstallation(self):
previous_id = self.getPortalObject().portal_ids\
.generateNewId(id_group='slap_software_installation_reference',
id_generator='uid')
software_release = self.generateNewSoftwareReleaseUrl()
self.compute_node.requestSoftwareRelease(state="available",
software_release_url=software_release)
software_installation_url = self.compute_node.REQUEST.get(
'software_installation_url')
self.assertNotEqual(None, software_installation_url)
software_installation = self.compute_node.restrictedTraverse(
software_installation_url)
self.assertEqual(software_release, software_installation.getUrlString())
self.assertEqual('Software Installation',
software_installation.getPortalType())
self.assertEqual('validated', software_installation.getValidationState())
self.assertEqual('start_requested', software_installation.getSlapState())
self.assertEqual('SOFTINSTALL-%s' % (previous_id+1),
software_installation.getReference())
def test_multiple_supply_available_createdSoftwareInstallation(self):
previous_id = self.getPortalObject().portal_ids\
.generateNewId(id_group='slap_software_installation_reference',
id_generator='uid')
software_release = self.generateNewSoftwareReleaseUrl()
self.compute_node.requestSoftwareRelease(state="available",
software_release_url=software_release)
software_installation_url = self.compute_node.REQUEST.get(
'software_installation_url')
self.assertNotEqual(None, software_installation_url)
software_installation = self.compute_node.restrictedTraverse(
software_installation_url)
self.assertEqual(software_release, software_installation.getUrlString())
self.assertEqual('Software Installation',
software_installation.getPortalType())
self.assertEqual('validated', software_installation.getValidationState())
self.assertEqual('start_requested', software_installation.getSlapState())
self.assertEqual('SOFTINSTALL-%s' % (previous_id+1),
software_installation.getReference())
self.tic()
self.compute_node.requestSoftwareRelease(state="available",
software_release_url=software_release)
software_installation_url2 = self.compute_node.REQUEST.get(
'software_installation_url')
self.assertEqual(software_installation_url, software_installation_url2)
def test_supply_available_destroyed(self):
previous_id = self.getPortalObject().portal_ids\
.generateNewId(id_group='slap_software_installation_reference',
id_generator='uid')
software_release = self.generateNewSoftwareReleaseUrl()
self.compute_node.requestSoftwareRelease(state="available",
software_release_url=software_release)
software_installation_url = self.compute_node.REQUEST.get(
'software_installation_url')
self.assertNotEqual(None, software_installation_url)
software_installation = self.compute_node.restrictedTraverse(
software_installation_url)
self.assertEqual(software_release, software_installation.getUrlString())
self.assertEqual('Software Installation',
software_installation.getPortalType())
self.assertEqual('validated', software_installation.getValidationState())
self.assertEqual('start_requested', software_installation.getSlapState())
self.assertEqual('SOFTINSTALL-%s' % (previous_id+1),
software_installation.getReference())
self.tic()
self.compute_node.requestSoftwareRelease(state="destroyed",
software_release_url=software_release)
software_installation_url2 = self.compute_node.REQUEST.get(
'software_installation_url')
self.assertEqual(software_installation_url, software_installation_url2)
software_installation = self.compute_node.restrictedTraverse(
software_installation_url2)
self.assertEqual('Software Installation',
software_installation.getPortalType())
self.assertEqual('validated', software_installation.getValidationState())
self.assertEqual('destroy_requested', software_installation.getSlapState())
self.assertEqual('SOFTINSTALL-%s' % (previous_id+1),
software_installation.getReference())
def test_supply_available_destroyed_available(self):
previous_id = self.getPortalObject().portal_ids\
.generateNewId(id_group='slap_software_installation_reference',
id_generator='uid')
software_release = self.generateNewSoftwareReleaseUrl()
self.compute_node.requestSoftwareRelease(state="available",
software_release_url=software_release)
software_installation_url = self.compute_node.REQUEST.get(
'software_installation_url')
self.assertNotEqual(None, software_installation_url)
software_installation = self.compute_node.restrictedTraverse(
software_installation_url)
self.assertEqual(software_release, software_installation.getUrlString())
self.assertEqual('Software Installation',
software_installation.getPortalType())
self.assertEqual('validated', software_installation.getValidationState())
self.assertEqual('start_requested', software_installation.getSlapState())
self.assertEqual('SOFTINSTALL-%s' % (previous_id+1),
software_installation.getReference())
self.tic()
self.compute_node.requestSoftwareRelease(state="destroyed",
software_release_url=software_release)
software_installation_url2 = self.compute_node.REQUEST.get(
'software_installation_url')
self.assertEqual(software_installation_url, software_installation_url2)
software_installation = self.compute_node.restrictedTraverse(
software_installation_url2)
self.assertEqual('Software Installation',
software_installation.getPortalType())
self.assertEqual('validated', software_installation.getValidationState())
self.assertEqual('destroy_requested', software_installation.getSlapState())
self.assertEqual('SOFTINSTALL-%s' % (previous_id+1),
software_installation.getReference())
self.tic()
# XXX: This scenario shall be discussed...
self.assertRaises(UnsupportedWorkflowMethod,
self.compute_node.requestSoftwareRelease, state="available",
software_release_url=software_release)
def test_supply_available_destroyed_finalised_available(self):
previous_id = self.getPortalObject().portal_ids\
.generateNewId(id_group='slap_software_installation_reference',
id_generator='uid')
software_release = self.generateNewSoftwareReleaseUrl()
self.compute_node.requestSoftwareRelease(state="available",
software_release_url=software_release)
software_installation_url = self.compute_node.REQUEST.get(
'software_installation_url')
self.assertNotEqual(None, software_installation_url)
software_installation = self.compute_node.restrictedTraverse(
software_installation_url)
self.assertEqual(software_release, software_installation.getUrlString())
self.assertEqual('Software Installation',
software_installation.getPortalType())
self.assertEqual('validated', software_installation.getValidationState())
self.assertEqual('start_requested', software_installation.getSlapState())
self.assertEqual('SOFTINSTALL-%s' % (previous_id+1),
software_installation.getReference())
self.tic()
self.compute_node.requestSoftwareRelease(state="destroyed",
software_release_url=software_release)
software_installation_url2 = self.compute_node.REQUEST.get(
'software_installation_url')
self.assertEqual(software_installation_url, software_installation_url2)
software_installation = self.compute_node.restrictedTraverse(
software_installation_url2)
self.assertEqual('Software Installation',
software_installation.getPortalType())
self.assertEqual('validated', software_installation.getValidationState())
self.assertEqual('destroy_requested', software_installation.getSlapState())
self.assertEqual('SOFTINSTALL-%s' % (previous_id+1),
software_installation.getReference())
software_installation.invalidate()
self.tic()
self.compute_node.requestSoftwareRelease(state="available",
software_release_url=software_release)
software_installation_url3 = self.compute_node.REQUEST.get(
'software_installation_url')
self.assertNotEqual(software_installation_url, software_installation_url3)
software_installation = self.compute_node.restrictedTraverse(
software_installation_url3)
self.assertEqual('Software Installation',
software_installation.getPortalType())
self.assertEqual('validated', software_installation.getValidationState())
self.assertEqual('start_requested', software_installation.getSlapState())
self.assertEqual('SOFTINSTALL-%s' % (previous_id+2),
software_installation.getReference())
class TestSlapOSCoreComputeNodeSlapInterfaceWorkflowTransfer(SlapOSTestCaseMixin):
def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
portal = self.getPortalObject()
# Clone compute_node document
compute_node = portal.compute_node_module.template_compute_node\
.Base_createCloneDocument(batch_mode=1)
# Clone person document
person_user = self.makePerson(new_id=self.new_id, index=0)
compute_node.edit(
title="Compute Node %s for %s" % (self.new_id, person_user.getReference()),
reference="TESTCOMP-%s" % self.new_id,
source_administration=person_user.getRelativeUrl()
)
compute_node.validate()
self.compute_node = compute_node
self.tic()
# Login as new user
self.login(person_user.getUserId())
new_person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.assertEqual(person_user.getRelativeUrl(), new_person.getRelativeUrl())
def _makeProject(self):
project = self.portal.project_module.newContent()
project.edit(reference="TESTPROJ-%s" % project.getId())
project.validate()
self.tic()
return project
def _makeOrganisation(self):
organisation = self.portal.organisation_module.newContent()
organisation.edit(reference="TESTSITE-%s" % organisation.getId())
organisation.validate()
self.tic()
return organisation
def test_Computer_requestTransfer_Unauthorized(self):
source_administrator = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
site = self._makeOrganisation()
self.login()
self.assertRaises(Unauthorized, self.compute_node.requestTransfer,
destination=site.getRelativeUrl(),
destination_section=None,
destination_project=None)
self.login(source_administrator.getUserId())
self.assertRaises(ValueError, self.compute_node.requestTransfer,
destination=None,
destination_section=None,
destination_project=None)
self.login()
other_user = self.makePerson(user=1)
self.assertEqual(1 , len(other_user.objectValues(portal_type="ERP5 Login")))
self.compute_node.setSourceAdministrationValue(source_administrator)
self.tic()
self.assertRaises(Unauthorized, self.compute_node.requestTransfer,
destination=None,
destination_section=None,
destination_project=None)
self.login(other_user.getUserId())
self.assertRaises(Unauthorized, self.compute_node.requestTransfer,
destination=None,
destination_section=None,
destination_project=None)
self.login(source_administrator.getUserId())
self.assertEqual(self.compute_node.requestTransfer(
destination=site.getRelativeUrl(),
destination_section=None,
destination_project=None), None)
def test_Computer_requestTransfer_project(self):
source_administrator = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.compute_node.setSourceAdministrationValue(source_administrator)
self.login()
project = self._makeProject()
other_project = self._makeProject()
site = self._makeOrganisation()
self.tic()
self.login(source_administrator.getUserId())
self.assertEqual(self.compute_node.Item_getCurrentProjectValue(), None)
self.assertEqual(self.compute_node.Item_getCurrentOwnerValue(), None)
self.assertEqual(self.compute_node.Item_getCurrentSiteValue(), None)
# Place in a project
self.assertEqual(self.compute_node.requestTransfer(
destination=site.getRelativeUrl(),
destination_section=None,
destination_project=project.getRelativeUrl()), None)
self.tic()
self.assertEqual(self.compute_node.Item_getCurrentProjectValue(), project)
self.assertEqual(self.compute_node.Item_getCurrentOwnerValue(), source_administrator)
self.assertEqual(self.compute_node.Item_getCurrentSiteValue(), site)
self.assertEqual(1,
len(self.compute_node.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
self.login(source_administrator.getUserId())
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep(1)
# We don't remove from Project if destination project is not provided
self.assertEqual(self.compute_node.requestTransfer(
destination=None,
destination_section=None,
destination_project=None), None)
self.tic()
self.assertEqual(self.compute_node.Item_getCurrentProjectValue(), project)
self.assertEqual(self.compute_node.Item_getCurrentOwnerValue(), source_administrator)
self.assertEqual(2,
len(self.compute_node.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep(1)
# Place in another project
self.assertEqual(self.compute_node.requestTransfer(
destination=None,
destination_section=None,
destination_project=other_project.getRelativeUrl()), None)
self.tic()
self.assertEqual(self.compute_node.Item_getCurrentProjectValue(), other_project)
self.assertEqual(self.compute_node.Item_getCurrentOwnerValue(), source_administrator)
self.assertEqual(self.compute_node.Item_getCurrentSiteValue(), site)
self.assertEqual(3,
len(self.compute_node.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
self.login(source_administrator.getUserId())
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep(1)
# We don't remove from Project if destination project is not provided
self.assertEqual(self.compute_node.requestTransfer(
destination=None,
destination_section=None,
destination_project=None), None)
self.tic()
self.assertEqual(self.compute_node.Item_getCurrentProjectValue(), other_project)
self.assertEqual(self.compute_node.Item_getCurrentOwnerValue(), source_administrator)
self.assertEqual(self.compute_node.Item_getCurrentSiteValue(), site)
self.assertEqual(4,
len(self.compute_node.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
def test_Computer_requestTransfer_owner(self):
source_administrator = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.compute_node.setSourceAdministrationValue(source_administrator)
self.login()
organisation = self._makeOrganisation()
other_organisation = self._makeOrganisation()
site = self._makeOrganisation()
self.tic()
self.login(source_administrator.getUserId())
self.assertEqual(self.compute_node.Item_getCurrentProjectValue(), None)
self.assertEqual(self.compute_node.Item_getCurrentOwnerValue(), None)
self.assertEqual(self.compute_node.requestTransfer(
destination=site.getRelativeUrl(),
destination_project=None,
destination_section=organisation.getRelativeUrl()), None)
self.tic()
self.assertEqual(self.compute_node.Item_getCurrentProjectValue(), None)
self.assertEqual(self.compute_node.Item_getCurrentOwnerValue(), organisation)
self.assertEqual(self.compute_node.Item_getCurrentSiteValue(), site)
self.assertEqual(1,
len(self.compute_node.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep(1)
self.login(source_administrator.getUserId())
self.assertEqual(self.compute_node.requestTransfer(
destination=None,
destination_section=None,
destination_project=None), None)
self.tic()
self.assertEqual(self.compute_node.Item_getCurrentProjectValue(), None)
self.assertEqual(self.compute_node.Item_getCurrentOwnerValue(), source_administrator)
self.assertEqual(self.compute_node.Item_getCurrentSiteValue(), site)
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep(1)
# Place in another project
self.assertEqual(self.compute_node.requestTransfer(
destination=None,
destination_project=None,
destination_section=other_organisation.getRelativeUrl()), None)
self.tic()
self.assertEqual(3,
len(self.compute_node.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
self.assertEqual(self.compute_node.Item_getCurrentProjectValue(), None)
self.assertEqual(self.compute_node.Item_getCurrentOwnerValue(), other_organisation)
self.assertEqual(self.compute_node.Item_getCurrentSiteValue(), site)
self.assertEqual(3,
len(self.compute_node.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
self.login(source_administrator.getUserId())
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep(1)
# We don't remove from Project if destination project is not provided
self.assertEqual(self.compute_node.requestTransfer(
destination=None,
destination_section=None,
destination_project=None), None)
self.tic()
self.assertEqual(self.compute_node.Item_getCurrentProjectValue(), None)
self.assertEqual(self.compute_node.Item_getCurrentOwnerValue(), source_administrator)
self.assertEqual(self.compute_node.Item_getCurrentSiteValue(), site)
self.assertEqual(4,
len(self.compute_node.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
def test_Computer_requestTransfer_site(self):
source_administrator = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.compute_node.setSourceAdministrationValue(source_administrator)
self.login()
site = self._makeOrganisation()
other_site = self._makeOrganisation()
self.tic()
self.login(source_administrator.getUserId())
self.assertEqual(self.compute_node.Item_getCurrentProjectValue(), None)
self.assertEqual(self.compute_node.Item_getCurrentOwnerValue(), None)
self.assertEqual(self.compute_node.requestTransfer(
destination_section=None,
destination_project=None,
destination=site.getRelativeUrl()), None)
self.tic()
self.assertEqual(self.compute_node.Item_getCurrentProjectValue(), None)
self.assertEqual(self.compute_node.Item_getCurrentOwnerValue(), source_administrator)
self.assertEqual(self.compute_node.Item_getCurrentSiteValue(), site)
self.assertEqual(1,
len(self.compute_node.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep(1)
self.login(source_administrator.getUserId())
# We don't remove from Project if destination project is not provided
self.assertEqual(self.compute_node.requestTransfer(
destination=None,
destination_section=None,
destination_project=None), None)
self.tic()
self.assertEqual(self.compute_node.Item_getCurrentProjectValue(), None)
self.assertEqual(self.compute_node.Item_getCurrentOwnerValue(), source_administrator)
self.assertEqual(self.compute_node.Item_getCurrentSiteValue(), site)
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep(1)
# Place in another project
self.assertEqual(self.compute_node.requestTransfer(
destination_section=None,
destination_project=None,
destination=other_site.getRelativeUrl()), None)
self.tic()
self.assertEqual(3,
len(self.compute_node.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
self.assertEqual(self.compute_node.Item_getCurrentProjectValue(), None)
self.assertEqual(self.compute_node.Item_getCurrentOwnerValue(), source_administrator)
self.assertEqual(self.compute_node.Item_getCurrentSiteValue(), other_site)
self.assertEqual(3,
len(self.compute_node.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
self.login(source_administrator.getUserId())
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep(1)
# We don't remove from Project if destination project is not provided
self.assertEqual(self.compute_node.requestTransfer(
destination=None,
destination_section=None,
destination_project=None), None)
self.tic()
self.assertEqual(self.compute_node.Item_getCurrentProjectValue(), None)
self.assertEqual(self.compute_node.Item_getCurrentOwnerValue(), source_administrator)
self.assertEqual(self.compute_node.Item_getCurrentSiteValue(), other_site)
self.assertEqual(4,
len(self.compute_node.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testSlapOSCloudComputeNodeSlapInterfaceWorkflow</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testSlapOSCloudComputeNodeSlapInterfaceWorkflow</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
class TestSlapOSCoreComputePartitionSlapInterfaceWorkflow(SlapOSTestCaseMixin):
def afterSetUp(self):
self.login()
SlapOSTestCaseMixin.afterSetUp(self)
# Clone compute_node document
self.compute_node = self.portal.compute_node_module.template_compute_node\
.Base_createCloneDocument(batch_mode=1)
self.compute_node.edit(
title="compute node %s" % (self.new_id, ),
reference="TESTCOMP-%s" % (self.new_id, ),
allocation_scope='open/personal',
capacity_scope='open',
)
self.compute_node.validate()
login = self.compute_node.newContent(
portal_type="ERP5 Login",
reference=self.compute_node.getReference()
)
login.validate()
# install an software release
self.software_installation = self.portal.software_installation_module\
.newContent(portal_type='Software Installation',
url_string=self.generateNewSoftwareReleaseUrl(),
aggregate=self.compute_node.getRelativeUrl())
self.software_installation.validate()
self.software_installation.requestStart()
self.tic()
self.login(self.compute_node.getUserId())
def test_markFree(self):
partition = self.compute_node.newContent(portal_type='Compute Partition',
reference='PART-%s' % self.generateNewId())
partition.validate()
partition.markFree()
self.tic()
self.assertEqual(1, self.portal.portal_catalog.countResults(
parent_uid=self.compute_node.getUid(), free_for_request=1)[0][0])
def test_markFree_markBusy(self):
partition = self.compute_node.newContent(portal_type='Compute Partition',
reference='PART-%s' % self.generateNewId())
partition.validate()
partition.markFree()
self.tic()
self.assertEqual(1, self.portal.portal_catalog.countResults(
parent_uid=self.compute_node.getUid(), free_for_request=1)[0][0])
partition.markBusy()
self.tic()
self.assertEqual(0, self.portal.portal_catalog.countResults(
parent_uid=self.compute_node.getUid(), free_for_request=1)[0][0])
def test_markFree_markBusy_markFree(self):
partition = self.compute_node.newContent(portal_type='Compute Partition',
reference='PART-%s' % self.generateNewId())
partition.validate()
partition.markFree()
self.tic()
self.assertEqual(1, self.portal.portal_catalog.countResults(
parent_uid=self.compute_node.getUid(), free_for_request=1)[0][0])
partition.markBusy()
self.tic()
self.assertEqual(0, self.portal.portal_catalog.countResults(
parent_uid=self.compute_node.getUid(), free_for_request=1)[0][0])
partition.markFree()
self.tic()
self.assertEqual(1, self.portal.portal_catalog.countResults(
parent_uid=self.compute_node.getUid(), free_for_request=1)[0][0])
def test_markInactive(self):
partition = self.compute_node.newContent(portal_type='Compute Partition',
reference='PART-%s' % self.generateNewId())
partition.validate()
partition.markInactive()
self.tic()
self.assertEqual(0, self.portal.portal_catalog.countResults(
parent_uid=self.compute_node.getUid(), free_for_request=1)[0][0])
def test_markInactive_markFree(self):
partition = self.compute_node.newContent(portal_type='Compute Partition',
reference='PART-%s' % self.generateNewId())
partition.validate()
partition.markInactive()
self.tic()
self.assertEqual(0, self.portal.portal_catalog.countResults(
parent_uid=self.compute_node.getUid(), free_for_request=1)[0][0])
partition.markFree()
self.tic()
self.assertEqual(1, self.portal.portal_catalog.countResults(
parent_uid=self.compute_node.getUid(), free_for_request=1)[0][0])
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
</item> </item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>testSlapOSCloudWorkflow</string> </value> <value> <string>testSlapOSCloudComputePartitionSlapInterfaceWorkflow</string> </value>
</item> </item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>test.erp5.testSlapOSCloudWorkflow</string> </value> <value> <string>test.erp5.testSlapOSCloudComputePartitionSlapInterfaceWorkflow</string> </value>
</item> </item>
<item> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
......
# -*- coding:utf-8 -*-
##############################################################################
#
# Copyright (c) 2021 Nexedi SA and Contributors. All Rights Reserved.
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#
##############################################################################
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
from time import sleep
from zExceptions import Unauthorized
class TestComputerNetworkcreateMovement(SlapOSTestCaseMixin):
def _makeProject(self):
project = self.portal.project_module.newContent()
project.edit(reference="TESTPROJ-%s" % project.getId())
project.validate()
self.tic()
return project
def _makeComputerNetwork(self):
network = self.portal.computer_network_module.newContent()
network.edit(reference="TESTNET-%s" % network.getId())
network.validate()
self.tic()
return network
def _makeOrganisation(self):
organisation = self.portal.organisation_module.newContent()
organisation.edit(reference="TESTSITE-%s" % organisation.getId())
organisation.validate()
self.tic()
return organisation
def test_project(self):
network = self._makeComputerNetwork()
source_administrator = self.makePerson(user=1)
network.setSourceAdministrationValue(source_administrator)
project = self._makeProject()
other_project = self._makeProject()
self.tic()
self.login(source_administrator.getUserId())
self.assertEqual(network.Item_getCurrentProjectValue(), None)
self.assertEqual(network.Item_getCurrentOwnerValue(), None)
# Place in a project
self.assertEqual(network.ComputerNetwork_createMovement(
destination_project=project.getRelativeUrl()), None)
self.tic()
self.assertEqual(network.Item_getCurrentProjectValue(), project)
self.assertEqual(network.Item_getCurrentOwnerValue(), source_administrator)
self.assertEqual(1,
len(network.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
self.login(source_administrator.getUserId())
# We don't remove from Project if destination project is not provided
self.assertEqual(network.ComputerNetwork_createMovement(), None)
self.tic()
self.assertEqual(network.Item_getCurrentProjectValue(), project)
self.assertEqual(network.Item_getCurrentOwnerValue(), source_administrator)
self.assertEqual(2,
len(network.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep(1)
# Place in another project
self.assertEqual(network.ComputerNetwork_createMovement(
destination_project=other_project.getRelativeUrl()), None)
self.tic()
self.assertEqual(network.Item_getCurrentProjectValue(), other_project)
self.assertEqual(network.Item_getCurrentOwnerValue(), source_administrator)
self.assertEqual(3,
len(network.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
self.login(source_administrator.getUserId())
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep(1)
# We don't remove from Project if destination project is not provided
self.assertEqual(network.ComputerNetwork_createMovement(), None)
self.tic()
self.assertEqual(network.Item_getCurrentProjectValue(), other_project)
self.assertEqual(network.Item_getCurrentOwnerValue(), source_administrator)
self.assertEqual(4,
len(network.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
def test_owner(self):
network = self._makeComputerNetwork()
source_administrator = self.makePerson(user=1)
network.setSourceAdministrationValue(source_administrator)
organisation = self._makeOrganisation()
other_organisation = self._makeOrganisation()
self.tic()
self.login(source_administrator.getUserId())
self.assertEqual(network.Item_getCurrentProjectValue(), None)
self.assertEqual(network.Item_getCurrentOwnerValue(), None)
self.assertEqual(network.ComputerNetwork_createMovement(
destination_section=organisation.getRelativeUrl()), None)
self.tic()
self.assertEqual(network.Item_getCurrentProjectValue(), None)
self.assertEqual(network.Item_getCurrentOwnerValue(), organisation)
self.assertEqual(1,
len(network.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
self.login(source_administrator.getUserId())
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep(1)
# We don't remove from Project if destination project is not provided
self.assertEqual(network.ComputerNetwork_createMovement(), None)
self.tic()
self.assertEqual(network.Item_getCurrentProjectValue(), None)
self.assertEqual(network.Item_getCurrentOwnerValue(), organisation)
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep(1)
# Place in another project
self.assertEqual(network.ComputerNetwork_createMovement(
destination_section=other_organisation.getRelativeUrl()), None)
self.tic()
self.assertEqual(3,
len(network.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
self.assertEqual(network.Item_getCurrentProjectValue(), None)
self.assertEqual(network.Item_getCurrentOwnerValue(), other_organisation)
self.assertEqual(3,
len(network.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
self.login(source_administrator.getUserId())
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep(1)
# We don't remove from Project if destination project is not provided
self.assertEqual(network.ComputerNetwork_createMovement(), None)
self.tic()
self.assertEqual(network.Item_getCurrentProjectValue(), None)
self.assertEqual(network.Item_getCurrentOwnerValue(), other_organisation)
self.assertEqual(4,
len(network.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
def testUnauthorized(self):
network = self._makeComputerNetwork()
self.assertRaises(Unauthorized, network.ComputerNetwork_createMovement)
source_administrator = self.makePerson(user=1)
self.assertEqual(1 , len(source_administrator.objectValues( portal_type="ERP5 Login")))
self.login(source_administrator.getUserId())
self.assertRaises(Unauthorized, network.ComputerNetwork_createMovement)
self.login()
other_user = self.makePerson(user=1)
self.assertEqual(1 , len(other_user.objectValues(portal_type="ERP5 Login")))
network.setSourceAdministrationValue(source_administrator)
self.tic()
self.assertRaises(Unauthorized, network.ComputerNetwork_createMovement)
self.login(other_user.getUserId())
self.assertRaises(Unauthorized, network.ComputerNetwork_createMovement)
self.login(source_administrator.getUserId())
self.assertEqual(network.ComputerNetwork_createMovement(), None)
class TestComputeNodecreateMovement(SlapOSTestCaseMixin):
def _makeComputeNode(self, owner=None, allocation_scope='open/public'):
compute_node = self.portal.compute_node_module\
.template_compute_node.Base_createCloneDocument(batch_mode=1)
compute_node.edit(reference="TESTCOMP-%s" % compute_node.getId())
compute_node.validate()
self.tic()
return compute_node
def _makeProject(self):
project = self.portal.project_module.newContent()
project.edit(reference="TESTPROJ-%s" % project.getId())
project.validate()
self.tic()
return project
def _makeOrganisation(self):
organisation = self.portal.organisation_module.newContent()
organisation.edit(reference="TESTSITE-%s" % organisation.getId())
organisation.validate()
self.tic()
return organisation
def testUnauthorized(self):
compute_node = self._makeComputeNode()
site = self._makeOrganisation()
self.assertRaises(Unauthorized, compute_node.ComputeNode_createMovement)
source_administrator = self.makePerson(user=1)
self.assertEqual(1 , len(source_administrator.objectValues( portal_type="ERP5 Login")))
self.login(source_administrator.getUserId())
self.assertRaises(Unauthorized, compute_node.ComputeNode_createMovement)
self.login()
other_user = self.makePerson(user=1)
self.assertEqual(1 , len(other_user.objectValues(portal_type="ERP5 Login")))
compute_node.setSourceAdministrationValue(source_administrator)
self.tic()
self.assertRaises(Unauthorized, compute_node.ComputeNode_createMovement)
self.login(other_user.getUserId())
self.assertRaises(Unauthorized, compute_node.ComputeNode_createMovement)
self.login(source_administrator.getUserId())
self.assertEqual(compute_node.ComputeNode_createMovement(destination=site.getRelativeUrl()), None)
def test_project(self):
compute_node = self._makeComputeNode()
source_administrator = self.makePerson(user=1)
compute_node.setSourceAdministrationValue(source_administrator)
project = self._makeProject()
other_project = self._makeProject()
site = self._makeOrganisation()
self.tic()
self.login(source_administrator.getUserId())
self.assertEqual(compute_node.Item_getCurrentProjectValue(), None)
self.assertEqual(compute_node.Item_getCurrentOwnerValue(), None)
self.assertEqual(compute_node.Item_getCurrentSiteValue(), None)
# Place in a project
self.assertEqual(compute_node.ComputeNode_createMovement(
destination=site.getRelativeUrl(),
destination_project=project.getRelativeUrl()), None)
self.tic()
self.assertEqual(compute_node.Item_getCurrentProjectValue(), project)
self.assertEqual(compute_node.Item_getCurrentOwnerValue(), source_administrator)
self.assertEqual(compute_node.Item_getCurrentSiteValue(), site)
self.assertEqual(1,
len(compute_node.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
self.login(source_administrator.getUserId())
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep(1)
# We don't remove from Project if destination project is not provided
self.assertEqual(compute_node.ComputeNode_createMovement(), None)
self.tic()
self.assertEqual(compute_node.Item_getCurrentProjectValue(), project)
self.assertEqual(compute_node.Item_getCurrentOwnerValue(), source_administrator)
self.assertEqual(2,
len(compute_node.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep(1)
# Place in another project
self.assertEqual(compute_node.ComputeNode_createMovement(
destination_project=other_project.getRelativeUrl()), None)
self.tic()
self.assertEqual(compute_node.Item_getCurrentProjectValue(), other_project)
self.assertEqual(compute_node.Item_getCurrentOwnerValue(), source_administrator)
self.assertEqual(compute_node.Item_getCurrentSiteValue(), site)
self.assertEqual(3,
len(compute_node.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
self.login(source_administrator.getUserId())
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep(1)
# We don't remove from Project if destination project is not provided
self.assertEqual(compute_node.ComputeNode_createMovement(), None)
self.tic()
self.assertEqual(compute_node.Item_getCurrentProjectValue(), other_project)
self.assertEqual(compute_node.Item_getCurrentOwnerValue(), source_administrator)
self.assertEqual(compute_node.Item_getCurrentSiteValue(), site)
self.assertEqual(4,
len(compute_node.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
def test_owner(self):
compute_node = self._makeComputeNode()
source_administrator = self.makePerson(user=1)
compute_node.setSourceAdministrationValue(source_administrator)
organisation = self._makeOrganisation()
other_organisation = self._makeOrganisation()
site = self._makeOrganisation()
self.tic()
self.login(source_administrator.getUserId())
self.assertEqual(compute_node.Item_getCurrentProjectValue(), None)
self.assertEqual(compute_node.Item_getCurrentOwnerValue(), None)
self.assertEqual(compute_node.ComputeNode_createMovement(
destination=site.getRelativeUrl(),
destination_section=organisation.getRelativeUrl()), None)
self.tic()
self.assertEqual(compute_node.Item_getCurrentProjectValue(), None)
self.assertEqual(compute_node.Item_getCurrentOwnerValue(), organisation)
self.assertEqual(compute_node.Item_getCurrentSiteValue(), site)
self.assertEqual(1,
len(compute_node.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep(1)
self.login(source_administrator.getUserId())
self.assertEqual(compute_node.ComputeNode_createMovement(), None)
self.tic()
self.assertEqual(compute_node.Item_getCurrentProjectValue(), None)
self.assertEqual(compute_node.Item_getCurrentOwnerValue(), source_administrator)
self.assertEqual(compute_node.Item_getCurrentSiteValue(), site)
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep(1)
# Place in another project
self.assertEqual(compute_node.ComputeNode_createMovement(
destination_section=other_organisation.getRelativeUrl()), None)
self.tic()
self.assertEqual(3,
len(compute_node.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
self.assertEqual(compute_node.Item_getCurrentProjectValue(), None)
self.assertEqual(compute_node.Item_getCurrentOwnerValue(), other_organisation)
self.assertEqual(compute_node.Item_getCurrentSiteValue(), site)
self.assertEqual(3,
len(compute_node.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
self.login(source_administrator.getUserId())
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep(1)
# We don't remove from Project if destination project is not provided
self.assertEqual(compute_node.ComputeNode_createMovement(), None)
self.tic()
self.assertEqual(compute_node.Item_getCurrentProjectValue(), None)
self.assertEqual(compute_node.Item_getCurrentOwnerValue(), source_administrator)
self.assertEqual(compute_node.Item_getCurrentSiteValue(), site)
self.assertEqual(4,
len(compute_node.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
def test_site(self):
compute_node = self._makeComputeNode()
source_administrator = self.makePerson(user=1)
compute_node.setSourceAdministrationValue(source_administrator)
site = self._makeOrganisation()
other_site = self._makeOrganisation()
self.tic()
self.login(source_administrator.getUserId())
self.assertEqual(compute_node.Item_getCurrentProjectValue(), None)
self.assertEqual(compute_node.Item_getCurrentOwnerValue(), None)
self.assertEqual(compute_node.ComputeNode_createMovement(
destination=site.getRelativeUrl()), None)
self.tic()
self.assertEqual(compute_node.Item_getCurrentProjectValue(), None)
self.assertEqual(compute_node.Item_getCurrentOwnerValue(), source_administrator)
self.assertEqual(compute_node.Item_getCurrentSiteValue(), site)
self.assertEqual(1,
len(compute_node.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep(1)
self.login(source_administrator.getUserId())
# We don't remove from Project if destination project is not provided
self.assertEqual(compute_node.ComputeNode_createMovement(), None)
self.tic()
self.assertEqual(compute_node.Item_getCurrentProjectValue(), None)
self.assertEqual(compute_node.Item_getCurrentOwnerValue(), source_administrator)
self.assertEqual(compute_node.Item_getCurrentSiteValue(), site)
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep(1)
# Place in another project
self.assertEqual(compute_node.ComputeNode_createMovement(
destination=other_site.getRelativeUrl()), None)
self.tic()
self.assertEqual(3,
len(compute_node.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
self.assertEqual(compute_node.Item_getCurrentProjectValue(), None)
self.assertEqual(compute_node.Item_getCurrentOwnerValue(), source_administrator)
self.assertEqual(compute_node.Item_getCurrentSiteValue(), other_site)
self.assertEqual(3,
len(compute_node.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
self.login(source_administrator.getUserId())
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep(1)
# We don't remove from Project if destination project is not provided
self.assertEqual(compute_node.ComputeNode_createMovement(), None)
self.tic()
self.assertEqual(compute_node.Item_getCurrentProjectValue(), None)
self.assertEqual(compute_node.Item_getCurrentOwnerValue(), source_administrator)
self.assertEqual(compute_node.Item_getCurrentSiteValue(), other_site)
self.assertEqual(4,
len(compute_node.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
class TestInstanceTreecreateMovement(SlapOSTestCaseMixin):
def _makeInstanceTree(self):
instance_tree = self.portal.instance_tree_module\
.template_instance_tree.Base_createCloneDocument(batch_mode=1)
instance_tree.validate()
self.tic()
return instance_tree
def _makeProject(self):
project = self.portal.project_module.newContent()
project.edit(reference="TESTPROJ-%s" % project.getId())
project.validate()
self.tic()
return project
def _makeOrganisation(self):
organisation = self.portal.organisation_module.newContent()
organisation.edit(reference="TESTSITE-%s" % organisation.getId())
organisation.validate()
self.tic()
return organisation
def testUnauthorized(self):
instance_tree = self._makeInstanceTree()
self.assertRaises(Unauthorized, instance_tree.InstanceTree_createMovement)
destination_section = self.makePerson(user=1)
self.assertEqual(1 , len(destination_section.objectValues( portal_type="ERP5 Login")))
self.login(destination_section.getUserId())
self.assertRaises(Unauthorized, instance_tree.InstanceTree_createMovement)
self.login()
other_user = self.makePerson(user=1)
self.assertEqual(1 , len(other_user.objectValues(portal_type="ERP5 Login")))
instance_tree.setDestinationSectionValue(destination_section)
self.tic()
self.assertRaises(Unauthorized, instance_tree.InstanceTree_createMovement)
self.login(other_user.getUserId())
self.assertRaises(Unauthorized, instance_tree.InstanceTree_createMovement)
self.login(destination_section.getUserId())
self.assertEqual(instance_tree.InstanceTree_createMovement(), None)
def test_project(self):
instance_tree = self._makeInstanceTree()
destination_section = self.makePerson(user=1)
instance_tree.setDestinationSectionValue(destination_section)
project = self._makeProject()
other_project = self._makeProject()
self.tic()
self.login(destination_section.getUserId())
self.assertEqual(instance_tree.Item_getCurrentProjectValue(), None)
self.assertEqual(instance_tree.Item_getCurrentOwnerValue(), None)
self.assertEqual(instance_tree.Item_getCurrentSiteValue(), None)
# Place in a project
self.assertEqual(instance_tree.InstanceTree_createMovement(
destination_project=project.getRelativeUrl()), None)
self.tic()
self.assertEqual(instance_tree.Item_getCurrentProjectValue(), project)
self.assertEqual(instance_tree.Item_getCurrentOwnerValue(), destination_section)
self.assertEqual(instance_tree.Item_getCurrentSiteValue(), None)
self.assertEqual(1,
len(instance_tree.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep(1)
self.login(destination_section.getUserId())
# We don't remove from Project if destination project is not provided
self.assertEqual(instance_tree.InstanceTree_createMovement(), None)
self.tic()
self.assertEqual(instance_tree.Item_getCurrentProjectValue(), project)
self.assertEqual(instance_tree.Item_getCurrentOwnerValue(), destination_section)
self.assertEqual(2,
len(instance_tree.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep(1)
# Place in another project
self.assertEqual(instance_tree.InstanceTree_createMovement(
destination_project=other_project.getRelativeUrl()), None)
self.tic()
self.assertEqual(instance_tree.Item_getCurrentProjectValue(), other_project)
self.assertEqual(instance_tree.Item_getCurrentOwnerValue(), destination_section)
self.assertEqual(instance_tree.Item_getCurrentSiteValue(), None)
self.assertEqual(3,
len(instance_tree.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
self.login(destination_section.getUserId())
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep(1)
# We don't remove from Project if destination project is not provided
self.assertEqual(instance_tree.InstanceTree_createMovement(), None)
self.tic()
self.assertEqual(instance_tree.Item_getCurrentProjectValue(), other_project)
self.assertEqual(instance_tree.Item_getCurrentOwnerValue(), destination_section)
self.assertEqual(instance_tree.Item_getCurrentSiteValue(), None)
self.assertEqual(4,
len(instance_tree.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
def test_owner(self):
instance_tree = self._makeInstanceTree()
destination_section = self.makePerson(user=1)
instance_tree.setDestinationSectionValue(destination_section)
organisation = self._makeOrganisation()
other_organisation = self._makeOrganisation()
self.tic()
self.login(destination_section.getUserId())
self.assertEqual(instance_tree.Item_getCurrentProjectValue(), None)
self.assertEqual(instance_tree.Item_getCurrentOwnerValue(), None)
self.assertEqual(instance_tree.InstanceTree_createMovement(
destination=organisation.getRelativeUrl()), None)
self.tic()
self.assertEqual(instance_tree.Item_getCurrentProjectValue(), None)
self.assertEqual(instance_tree.Item_getCurrentOwnerValue(), destination_section)
self.assertEqual(instance_tree.Item_getCurrentSiteValue(), organisation)
self.assertEqual(1,
len(instance_tree.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep(1)
self.login(destination_section.getUserId())
self.assertEqual(instance_tree.InstanceTree_createMovement(), None)
self.tic()
self.assertEqual(instance_tree.Item_getCurrentProjectValue(), None)
self.assertEqual(instance_tree.Item_getCurrentOwnerValue(), destination_section)
self.assertEqual(instance_tree.Item_getCurrentSiteValue(), organisation)
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep(1)
# Place in another project
self.assertEqual(instance_tree.InstanceTree_createMovement(
destination=other_organisation.getRelativeUrl()), None)
self.tic()
self.assertEqual(3,
len(instance_tree.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
self.assertEqual(instance_tree.Item_getCurrentProjectValue(), None)
self.assertEqual(instance_tree.Item_getCurrentOwnerValue(), destination_section)
self.assertEqual(instance_tree.Item_getCurrentSiteValue(), other_organisation)
self.assertEqual(3,
len(instance_tree.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
self.login(destination_section.getUserId())
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep(1)
# We don't remove from Project if destination project is not provided
self.assertEqual(instance_tree.InstanceTree_createMovement(), None)
self.tic()
self.assertEqual(instance_tree.Item_getCurrentProjectValue(), None)
self.assertEqual(instance_tree.Item_getCurrentOwnerValue(), destination_section)
self.assertEqual(instance_tree.Item_getCurrentSiteValue(), other_organisation)
self.assertEqual(4,
len(instance_tree.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
import transaction
from unittest import expectedFailure
from time import sleep
from zExceptions import Unauthorized
class TestSlapOSCoreInstanceSlapInterfaceWorkflow(SlapOSTestCaseMixin):
"""Tests instance.requestInstance"""
def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
portal = self.getPortalObject()
new_id = self.generateNewId()
self.request_kw = dict(
software_release=self.generateNewSoftwareReleaseUrl(),
software_title=self.generateNewSoftwareTitle(),
software_type=self.generateNewSoftwareType(),
instance_xml=self.generateSafeXml(),
sla_xml=self.generateSafeXml(),
shared=False,
state="started"
)
# prepare part of tree
instance_tree = portal.instance_tree_module\
.template_instance_tree.Base_createCloneDocument(batch_mode=1)
self.software_instance = portal.software_instance_module\
.template_software_instance.Base_createCloneDocument(batch_mode=1)
instance_tree.edit(
title=self.request_kw['software_title'],
reference="TESTHS-%s" % new_id,
url_string=self.request_kw['software_release'],
source_reference=self.request_kw['software_type'],
text_content=self.request_kw['instance_xml'],
sla_xml=self.request_kw['sla_xml'],
root_slave=self.request_kw['shared'],
successor=self.software_instance.getRelativeUrl()
)
instance_tree.validate()
self.portal.portal_workflow._jumpToStateFor(instance_tree, 'start_requested')
self.software_instance.edit(
title=self.request_kw['software_title'],
reference="TESTSI-%s" % new_id,
url_string=self.request_kw['software_release'],
source_reference=self.request_kw['software_type'],
text_content=self.request_kw['instance_xml'],
sla_xml=self.request_kw['sla_xml'],
specialise=instance_tree.getRelativeUrl()
)
self.portal.portal_workflow._jumpToStateFor(self.software_instance, 'start_requested')
self.software_instance.validate()
self.tic()
# Login as new Software Instance
self.login(self.software_instance.getUserId())
def beforeTearDown(self):
transaction.abort()
if 'request_instance' in self.software_instance.REQUEST:
self.software_instance.REQUEST['request_instance'] = None
def test_request_requiredParameter(self):
good_request_kw = self.request_kw.copy()
# in order to have unique requested title
good_request_kw['software_title'] = self.generateNewSoftwareTitle()
# check that correct request does not raise
self.software_instance.requestInstance(**good_request_kw)
# substract parameters
request_kw = good_request_kw.copy()
request_kw.pop('software_release')
self.assertRaises(KeyError, self.software_instance.requestInstance,
**request_kw)
request_kw = good_request_kw.copy()
request_kw.pop('software_title')
self.assertRaises(KeyError, self.software_instance.requestInstance,
**request_kw)
request_kw = good_request_kw.copy()
request_kw.pop('software_type')
self.assertRaises(KeyError, self.software_instance.requestInstance,
**request_kw)
request_kw = good_request_kw.copy()
request_kw.pop('instance_xml')
self.assertRaises(KeyError, self.software_instance.requestInstance,
**request_kw)
request_kw = good_request_kw.copy()
request_kw.pop('sla_xml')
self.assertRaises(KeyError, self.software_instance.requestInstance,
**request_kw)
request_kw = good_request_kw.copy()
request_kw.pop('shared')
self.assertRaises(KeyError, self.software_instance.requestInstance,
**request_kw)
request_kw = good_request_kw.copy()
request_kw.pop('state')
self.assertRaises(KeyError, self.software_instance.requestInstance,
**request_kw)
def test_request_createdInstance(self):
request_kw = self.request_kw.copy()
# in order to have unique requested title
request_kw['software_title'] = self.generateNewSoftwareTitle()
# check that correct request does not raise
self.software_instance.requestInstance(**request_kw)
requested_instance = self.software_instance.REQUEST.get(
'request_instance')
self.assertNotEqual(None, requested_instance)
self.assertEqual(request_kw['software_title'],
requested_instance.getTitle())
self.assertEqual('Software Instance',
requested_instance.getPortalType())
self.assertEqual('validated',
requested_instance.getValidationState())
self.assertEqual('start_requested',
requested_instance.getSlapState())
self.assertEqual(request_kw['software_release'],
requested_instance.getUrlString())
self.assertEqual(request_kw['instance_xml'],
requested_instance.getTextContent())
self.assertEqual(request_kw['sla_xml'],
requested_instance.getSlaXml())
self.assertEqual(request_kw['software_type'],
requested_instance.getSourceReference())
def test_request_sameTitle(self):
# check that correct request does not raise
self.assertRaises(ValueError, self.software_instance.requestInstance,
**self.request_kw)
def test_request_shared_True(self):
request_kw = self.request_kw.copy()
# in order to have unique requested title
request_kw['software_title'] = self.generateNewSoftwareTitle()
request_kw['shared'] = True
# check that correct request does not raise
self.software_instance.requestInstance(**request_kw)
requested_instance = self.software_instance.REQUEST.get(
'request_instance')
self.assertNotEqual(None, requested_instance)
self.assertEqual(request_kw['software_title'],
requested_instance.getTitle())
self.assertEqual('Slave Instance',
requested_instance.getPortalType())
self.assertEqual('validated',
requested_instance.getValidationState())
self.assertEqual('start_requested',
requested_instance.getSlapState())
self.assertEqual(request_kw['software_release'],
requested_instance.getUrlString())
self.assertEqual(request_kw['instance_xml'],
requested_instance.getTextContent())
self.assertEqual(request_kw['sla_xml'],
requested_instance.getSlaXml())
self.assertEqual(request_kw['software_type'],
requested_instance.getSourceReference())
def test_request_shared_unsupported(self):
request_kw = self.request_kw.copy()
# in order to have unique requested title
request_kw['software_title'] = self.generateNewSoftwareTitle()
request_kw['shared'] = 'True'
self.assertRaises(ValueError, self.software_instance.requestInstance,
**request_kw)
def test_request_unindexed(self):
request_kw = self.request_kw.copy()
# in order to have unique requested title
request_kw['software_title'] = self.generateNewSoftwareTitle()
# check that correct request does not raise
self.software_instance.requestInstance(**request_kw)
requested_instance = self.software_instance.REQUEST.get(
'request_instance')
self.assertNotEqual(None, requested_instance)
self.assertEqual(request_kw['software_title'],
requested_instance.getTitle())
self.assertEqual('Software Instance',
requested_instance.getPortalType())
self.assertEqual('validated',
requested_instance.getValidationState())
self.assertEqual('start_requested',
requested_instance.getSlapState())
self.assertEqual(request_kw['software_release'],
requested_instance.getUrlString())
self.assertEqual(request_kw['instance_xml'],
requested_instance.getTextContent())
self.assertEqual(request_kw['sla_xml'],
requested_instance.getSlaXml())
self.assertEqual(request_kw['software_type'],
requested_instance.getSourceReference())
transaction.commit()
self.assertRaises(NotImplementedError, self.software_instance.requestInstance,
**request_kw)
def test_request_double(self):
request_kw = self.request_kw.copy()
# in order to have unique requested title
request_kw['software_title'] = self.generateNewSoftwareTitle()
# check that correct request does not raise
self.software_instance.requestInstance(**request_kw)
requested_instance = self.software_instance.REQUEST.get(
'request_instance')
self.assertNotEqual(None, requested_instance)
self.assertEqual(request_kw['software_title'],
requested_instance.getTitle())
self.assertEqual('Software Instance',
requested_instance.getPortalType())
self.assertEqual('validated',
requested_instance.getValidationState())
self.assertEqual('start_requested',
requested_instance.getSlapState())
self.assertEqual(request_kw['software_release'],
requested_instance.getUrlString())
self.assertEqual(request_kw['instance_xml'],
requested_instance.getTextContent())
self.assertEqual(request_kw['sla_xml'],
requested_instance.getSlaXml())
self.assertEqual(request_kw['software_type'],
requested_instance.getSourceReference())
self.tic()
# check that correct request does not raise
self.software_instance.requestInstance(**request_kw)
requested_instance2 = self.software_instance.REQUEST.get(
'request_instance')
self.assertNotEqual(None, requested_instance2)
self.assertEqual(requested_instance2.getRelativeUrl(),
requested_instance.getRelativeUrl())
self.assertEqual(request_kw['software_title'],
requested_instance2.getTitle())
self.assertEqual('Software Instance',
requested_instance2.getPortalType())
self.assertEqual('validated',
requested_instance2.getValidationState())
self.assertEqual('start_requested',
requested_instance2.getSlapState())
self.assertEqual(request_kw['software_release'],
requested_instance2.getUrlString())
self.assertEqual(request_kw['instance_xml'],
requested_instance2.getTextContent())
self.assertEqual(request_kw['sla_xml'],
requested_instance2.getSlaXml())
self.assertEqual(request_kw['software_type'],
requested_instance2.getSourceReference())
def test_request_duplicated(self):
request_kw = self.request_kw.copy()
# in order to have unique requested title
request_kw['software_title'] = self.generateNewSoftwareTitle()
duplicate = self.software_instance.Base_createCloneDocument(batch_mode=1)
duplicate.edit(
reference='TESTSI-%s' % self.generateNewId(),
title=request_kw['software_title'])
duplicate.validate()
self.portal.portal_workflow._jumpToStateFor(duplicate, 'start_requested')
duplicate2 = self.software_instance.Base_createCloneDocument(batch_mode=1)
duplicate2.edit(
reference='TESTSI-%s' % self.generateNewId(),
title=request_kw['software_title'])
duplicate2.validate()
self.portal.portal_workflow._jumpToStateFor(duplicate2, 'start_requested')
self.software_instance.getSpecialiseValue(
portal_type='Instance Tree').edit(
successor_list=[
duplicate.getRelativeUrl(),
duplicate2.getRelativeUrl(),
self.software_instance.getRelativeUrl()
]
)
self.tic()
self.assertRaises(ValueError, self.software_instance.requestInstance,
**request_kw)
def test_request_destroyed_state(self):
request_kw = self.request_kw.copy()
# in order to have unique requested title
request_kw['software_title'] = self.generateNewSoftwareTitle()
request_kw['state'] = 'destroyed'
# check that correct request does not raise
self.software_instance.requestInstance(**request_kw)
requested_instance = self.software_instance.REQUEST.get(
'request_instance')
# requesting with destroyed state shall not create new instance
self.assertEqual(None, requested_instance)
def test_request_two_different(self):
request_kw = self.request_kw.copy()
# in order to have unique requested title
request_kw['software_title'] = self.generateNewSoftwareTitle()
# check that correct request does not raise
self.software_instance.requestInstance(**request_kw)
requested_instance = self.software_instance.REQUEST.get(
'request_instance')
request_kw['software_title'] = self.generateNewSoftwareTitle()
self.software_instance.requestInstance(**request_kw)
requested_instance2 = self.software_instance.REQUEST.get(
'request_instance')
self.assertNotEqual(requested_instance.getRelativeUrl(),
requested_instance2.getRelativeUrl())
self.assertSameSet(
self.software_instance.getSuccessorList(),
[requested_instance.getRelativeUrl(),
requested_instance2.getRelativeUrl()])
def test_request_tree_change_indexed(self):
"""Checks tree change forced by request
For a tree like:
A
|
A
|\
B C
When B requests C tree shall change to:
A
|
A
|
B
|
C"""
request_kw = self.request_kw.copy()
request_kw['software_title'] = self.generateNewSoftwareTitle()
self.software_instance.requestInstance(**request_kw)
B_instance = self.software_instance.REQUEST.get('request_instance')
request_kw['software_title'] = self.generateNewSoftwareTitle()
self.software_instance.requestInstance(**request_kw)
C_instance = self.software_instance.REQUEST.get('request_instance')
self.assertSameSet(
self.software_instance.getSuccessorList(),
[B_instance.getRelativeUrl(), C_instance.getRelativeUrl()])
self.tic() # in order to recalculate tree
B_instance.requestInstance(**request_kw)
C1_instance = self.software_instance.REQUEST.get('request_instance')
self.assertEqual(C_instance.getRelativeUrl(), C1_instance.getRelativeUrl())
self.assertSameSet(self.software_instance.getSuccessorList(),
[B_instance.getRelativeUrl()])
self.assertSameSet(B_instance.getSuccessorList(),
[C_instance.getRelativeUrl()])
def test_request_tree_change_not_indexed(self):
"""Checks tree change forced by request
For a tree like:
A
|
A
|\
B C
When B requests C tree in next transaction, but before indexation,
the system shall disallow the operation."""
request_kw = self.request_kw.copy()
request_kw['software_title'] = self.generateNewSoftwareTitle()
self.software_instance.requestInstance(**request_kw)
B_instance = self.software_instance.REQUEST.get('request_instance')
request_kw['software_title'] = self.generateNewSoftwareTitle()
self.software_instance.requestInstance(**request_kw)
C_instance = self.software_instance.REQUEST.get('request_instance')
self.assertSameSet(
self.software_instance.getSuccessorList(),
[B_instance.getRelativeUrl(), C_instance.getRelativeUrl()])
transaction.commit()
self.assertRaises(NotImplementedError, B_instance.requestInstance,
**request_kw)
@expectedFailure
def test_request_tree_change_same_transaction(self):
"""Checks tree change forced by request
For a tree like:
A
|
A
|\
B C
When B requests C tree in the same transaction the system shall
disallow the operation."""
request_kw = self.request_kw.copy()
request_kw['software_title'] = self.generateNewSoftwareTitle()
self.software_instance.requestInstance(**request_kw)
B_instance = self.software_instance.REQUEST.get('request_instance')
request_kw['software_title'] = self.generateNewSoftwareTitle()
self.software_instance.requestInstance(**request_kw)
C_instance = self.software_instance.REQUEST.get('request_instance')
self.assertSameSet(
self.software_instance.getSuccessorList(),
[B_instance.getRelativeUrl(), C_instance.getRelativeUrl()])
self.assertRaises(NotImplementedError, B_instance.requestInstance,
**request_kw)
def test_request_started_stopped_destroyed(self):
request_kw = self.request_kw.copy()
request_kw['software_title'] = self.generateNewSoftwareTitle()
self.software_instance.requestInstance(**request_kw)
requested_instance = self.software_instance.REQUEST.get(
'request_instance')
self.assertNotEqual(None, requested_instance)
self.assertEqual(request_kw['software_title'],
requested_instance.getTitle())
self.assertEqual('Software Instance',
requested_instance.getPortalType())
self.assertEqual('validated',
requested_instance.getValidationState())
self.assertEqual('start_requested',
requested_instance.getSlapState())
self.assertEqual(request_kw['software_release'],
requested_instance.getUrlString())
self.assertEqual(request_kw['instance_xml'],
requested_instance.getTextContent())
self.assertEqual(request_kw['sla_xml'],
requested_instance.getSlaXml())
self.assertEqual(request_kw['software_type'],
requested_instance.getSourceReference())
self.tic()
request_kw['state'] = 'stopped'
self.software_instance.requestInstance(**request_kw)
requested_instance2 = self.software_instance.REQUEST.get(
'request_instance')
self.assertNotEqual(None, requested_instance2)
self.assertEqual(requested_instance.getRelativeUrl(),
requested_instance2.getRelativeUrl())
self.assertEqual(request_kw['software_title'],
requested_instance2.getTitle())
self.assertEqual('Software Instance',
requested_instance2.getPortalType())
self.assertEqual('validated',
requested_instance2.getValidationState())
self.assertEqual('stop_requested',
requested_instance2.getSlapState())
self.assertEqual(request_kw['software_release'],
requested_instance2.getUrlString())
self.assertEqual(request_kw['instance_xml'],
requested_instance2.getTextContent())
self.assertEqual(request_kw['sla_xml'],
requested_instance2.getSlaXml())
self.assertEqual(request_kw['software_type'],
requested_instance2.getSourceReference())
self.tic()
request_kw['state'] = 'destroyed'
self.software_instance.requestInstance(**request_kw)
requested_instance3 = self.software_instance.REQUEST.get(
'request_instance')
self.assertEqual(None, requested_instance3)
# in case of destruction instance is not returned, so fetch it
# directly form document
requested_instance3 = self.software_instance.getSuccessorValue(
portal_type='Software Instance')
self.assertEqual(request_kw['software_title'],
requested_instance3.getTitle())
self.assertEqual('Software Instance',
requested_instance3.getPortalType())
self.assertEqual('validated',
requested_instance3.getValidationState())
self.assertEqual('destroy_requested',
requested_instance3.getSlapState())
self.assertEqual(request_kw['software_release'],
requested_instance3.getUrlString())
self.assertEqual(request_kw['instance_xml'],
requested_instance3.getTextContent())
self.assertEqual(request_kw['sla_xml'],
requested_instance3.getSlaXml())
self.assertEqual(request_kw['software_type'],
requested_instance3.getSourceReference())
def _countBang(self, document):
return len([q for q in document.workflow_history[
'instance_slap_interface_workflow'] if q['action'] == 'bang'])
def test_request_started_no_bang(self):
request_kw = self.request_kw.copy()
request_kw['software_title'] = self.generateNewSoftwareTitle()
self.software_instance.requestInstance(**request_kw)
requested_instance = self.software_instance.REQUEST.get(
'request_instance')
self.tic()
bang_amount = self._countBang(requested_instance)
self.software_instance.requestInstance(**request_kw)
requested_instance2 = self.software_instance.REQUEST.get(
'request_instance')
transaction.commit()
self.assertEqual(requested_instance.getRelativeUrl(),
requested_instance2.getRelativeUrl())
self.assertEqual(bang_amount, self._countBang(requested_instance))
def test_request_stopped_bang(self):
request_kw = self.request_kw.copy()
request_kw['software_title'] = self.generateNewSoftwareTitle()
self.software_instance.requestInstance(**request_kw)
requested_instance = self.software_instance.REQUEST.get(
'request_instance')
self.tic()
bang_amount = self._countBang(requested_instance)
request_kw['state'] = 'stopped'
self.software_instance.requestInstance(**request_kw)
transaction.commit()
requested_instance2 = self.software_instance.REQUEST.get(
'request_instance')
self.assertEqual(requested_instance.getRelativeUrl(),
requested_instance2.getRelativeUrl())
self.assertEqual(bang_amount+1, self._countBang(requested_instance))
def test_request_destroyed_bang(self):
request_kw = self.request_kw.copy()
request_kw['software_title'] = self.generateNewSoftwareTitle()
self.software_instance.requestInstance(**request_kw)
requested_instance = self.software_instance.REQUEST.get(
'request_instance')
self.tic()
bang_amount = self._countBang(requested_instance)
request_kw['state'] = 'destroyed'
self.software_instance.requestInstance(**request_kw)
transaction.commit()
requested_instance2 = self.software_instance.getSuccessorValue(
portal_type='Software Instance')
self.assertEqual(requested_instance.getRelativeUrl(),
requested_instance2.getRelativeUrl())
self.assertEqual(bang_amount+1, self._countBang(requested_instance))
def test_request_tree_change_indexed_shared(self):
"""Checks tree change forced by request
For a tree like:
A
|
A
|\
B C
When B requests C tree shall change to:
A
|
A
|
B
|
C"""
request_kw = self.request_kw.copy()
request_kw['software_title'] = self.generateNewSoftwareTitle()
request_kw['shared'] = True
self.software_instance.requestInstance(**request_kw)
B_instance = self.software_instance.REQUEST.get('request_instance')
request_kw['software_title'] = self.generateNewSoftwareTitle()
self.software_instance.requestInstance(**request_kw)
C_instance = self.software_instance.REQUEST.get('request_instance')
self.assertSameSet(
self.software_instance.getSuccessorList(),
[B_instance.getRelativeUrl(), C_instance.getRelativeUrl()])
self.tic() # in order to recalculate tree
B_instance.requestInstance(**request_kw)
C1_instance = self.software_instance.REQUEST.get('request_instance')
self.assertEqual(C_instance.getRelativeUrl(), C1_instance.getRelativeUrl())
self.assertSameSet(self.software_instance.getSuccessorList(),
[B_instance.getRelativeUrl()])
self.assertSameSet(B_instance.getSuccessorList(),
[C_instance.getRelativeUrl()])
def test_request_tree_change_not_indexed_shared(self):
"""Checks tree change forced by request
For a tree like:
A
|
A
|\
B C
When B requests C tree in next transaction, but before indexation,
the system shall disallow the operation."""
request_kw = self.request_kw.copy()
request_kw['software_title'] = self.generateNewSoftwareTitle()
request_kw['shared'] = True
self.software_instance.requestInstance(**request_kw)
B_instance = self.software_instance.REQUEST.get('request_instance')
request_kw['software_title'] = self.generateNewSoftwareTitle()
self.software_instance.requestInstance(**request_kw)
C_instance = self.software_instance.REQUEST.get('request_instance')
self.assertSameSet(
self.software_instance.getSuccessorList(),
[B_instance.getRelativeUrl(), C_instance.getRelativeUrl()])
transaction.commit()
self.assertRaises(NotImplementedError, B_instance.requestInstance,
**request_kw)
@expectedFailure
def test_request_tree_change_same_transaction_shared(self):
"""Checks tree change forced by request
For a tree like:
A
|
A
|\
B C
When B requests C tree in the same transaction the system shall
disallow the operation."""
request_kw = self.request_kw.copy()
request_kw['software_title'] = self.generateNewSoftwareTitle()
request_kw['shared'] = True
self.software_instance.requestInstance(**request_kw)
B_instance = self.software_instance.REQUEST.get('request_instance')
request_kw['software_title'] = self.generateNewSoftwareTitle()
self.software_instance.requestInstance(**request_kw)
C_instance = self.software_instance.REQUEST.get('request_instance')
self.assertSameSet(
self.software_instance.getSuccessorList(),
[B_instance.getRelativeUrl(), C_instance.getRelativeUrl()])
self.assertRaises(NotImplementedError, B_instance.requestInstance,
**request_kw)
def test_request_software_release_bang(self):
request_kw = self.request_kw.copy()
request_kw['software_title'] = self.generateNewSoftwareTitle()
self.software_instance.requestInstance(**request_kw)
requested_instance = self.software_instance.REQUEST.get(
'request_instance')
self.tic()
bang_amount = self._countBang(requested_instance)
request_kw['software_release'] = self.generateNewSoftwareReleaseUrl()
self.software_instance.requestInstance(**request_kw)
requested_instance2 = self.software_instance.getSuccessorValue(
portal_type='Software Instance')
transaction.commit()
self.assertEqual(requested_instance.getRelativeUrl(),
requested_instance2.getRelativeUrl())
self.assertEqual(request_kw['software_release'],
requested_instance2.getUrlString())
self.assertEqual(bang_amount+1, self._countBang(requested_instance))
def test_request_software_type_bang(self):
request_kw = self.request_kw.copy()
request_kw['software_title'] = self.generateNewSoftwareTitle()
self.software_instance.requestInstance(**request_kw)
requested_instance = self.software_instance.REQUEST.get(
'request_instance')
self.tic()
bang_amount = self._countBang(requested_instance)
request_kw['software_type'] = self.generateNewSoftwareReleaseUrl()
self.software_instance.requestInstance(**request_kw)
requested_instance2 = self.software_instance.getSuccessorValue(
portal_type='Software Instance')
transaction.commit()
self.assertEqual(requested_instance.getRelativeUrl(),
requested_instance2.getRelativeUrl())
self.assertEqual(request_kw['software_type'],
requested_instance2.getSourceReference())
self.assertEqual(bang_amount+1, self._countBang(requested_instance))
def test_request_instance_xml_bang(self):
request_kw = self.request_kw.copy()
request_kw['software_title'] = self.generateNewSoftwareTitle()
self.software_instance.requestInstance(**request_kw)
requested_instance = self.software_instance.REQUEST.get(
'request_instance')
self.tic()
bang_amount = self._countBang(requested_instance)
request_kw['instance_xml'] = self.generateSafeXml()
self.software_instance.requestInstance(**request_kw)
requested_instance2 = self.software_instance.getSuccessorValue(
portal_type='Software Instance')
transaction.commit()
self.assertEqual(requested_instance.getRelativeUrl(),
requested_instance2.getRelativeUrl())
self.assertEqual(request_kw['instance_xml'],
requested_instance2.getTextContent())
self.assertEqual(bang_amount+1, self._countBang(requested_instance))
def test_request_sla_xml_bang(self):
request_kw = self.request_kw.copy()
request_kw['software_title'] = self.generateNewSoftwareTitle()
self.software_instance.requestInstance(**request_kw)
requested_instance = self.software_instance.REQUEST.get(
'request_instance')
self.tic()
bang_amount = self._countBang(requested_instance)
request_kw['sla_xml'] = self.generateSafeXml()
self.software_instance.requestInstance(**request_kw)
requested_instance2 = self.software_instance.getSuccessorValue(
portal_type='Software Instance')
transaction.commit()
self.assertEqual(requested_instance.getRelativeUrl(),
requested_instance2.getRelativeUrl())
self.assertEqual(request_kw['sla_xml'],
requested_instance2.getSlaXml())
self.assertEqual(bang_amount+1, self._countBang(requested_instance))
def test_update_connection_bang_requester(self):
request_kw = self.request_kw.copy()
request_kw['software_title'] = self.generateNewSoftwareTitle()
self.software_instance.requestInstance(**request_kw)
requested_instance = self.software_instance.REQUEST.get(
'request_instance')
self.tic()
bang_amount = self._countBang(self.software_instance)
connection_xml = self.generateSafeXml()
requested_instance.updateConnection(connection_xml=connection_xml)
transaction.commit()
self.assertEqual(bang_amount+1, self._countBang(self.software_instance))
class TestSlapOSCoreInstanceSlapInterfaceWorkflowTransfer(SlapOSTestCaseMixin):
"""Tests instance.requestTransfer"""
def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
portal = self.getPortalObject()
new_id = self.generateNewId()
self.request_kw = dict(
software_release=self.generateNewSoftwareReleaseUrl(),
software_title=self.generateNewSoftwareTitle(),
software_type=self.generateNewSoftwareType(),
instance_xml=self.generateSafeXml(),
sla_xml=self.generateSafeXml(),
shared=False,
state="started"
)
# prepare part of tree
self.instance_tree = portal.instance_tree_module\
.template_instance_tree.Base_createCloneDocument(batch_mode=1)
self.software_instance = portal.software_instance_module\
.template_software_instance.Base_createCloneDocument(batch_mode=1)
self.instance_tree.edit(
title=self.request_kw['software_title'],
reference="TESTHS-%s" % new_id,
url_string=self.request_kw['software_release'],
source_reference=self.request_kw['software_type'],
text_content=self.request_kw['instance_xml'],
sla_xml=self.request_kw['sla_xml'],
root_slave=self.request_kw['shared'],
successor=self.software_instance.getRelativeUrl()
)
self.instance_tree.validate()
self.portal.portal_workflow._jumpToStateFor(self.instance_tree, 'start_requested')
self.software_instance.edit(
title=self.request_kw['software_title'],
reference="TESTSI-%s" % new_id,
url_string=self.request_kw['software_release'],
source_reference=self.request_kw['software_type'],
text_content=self.request_kw['instance_xml'],
sla_xml=self.request_kw['sla_xml'],
specialise=self.instance_tree.getRelativeUrl()
)
self.portal.portal_workflow._jumpToStateFor(self.software_instance, 'start_requested')
self.software_instance.validate()
self.tic()
person_user = self.makePerson()
self.tic()
# Login as new user
self.login(person_user.getUserId())
new_person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.assertEqual(person_user.getRelativeUrl(), new_person.getRelativeUrl())
def beforeTearDown(self):
transaction.abort()
if 'request_instance' in self.software_instance.REQUEST:
self.software_instance.REQUEST['request_instance'] = None
def _makeProject(self):
project = self.portal.project_module.newContent()
project.edit(reference="TESTPROJ-%s" % project.getId())
project.validate()
self.tic()
return project
def _makeOrganisation(self):
organisation = self.portal.organisation_module.newContent()
organisation.edit(reference="TESTSITE-%s" % organisation.getId())
organisation.validate()
self.tic()
return organisation
def test_RequesterInstance_requestTransfer_Unauthorized(self):
destination_section = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.login()
self.assertRaises(Unauthorized, self.instance_tree.requestTransfer,
destination=None,
destination_project=None)
self.login(destination_section.getUserId())
self.assertRaises(Unauthorized, self.instance_tree.requestTransfer,
destination=None,
destination_project=None)
self.login()
other_user = self.makePerson(user=1)
self.assertEqual(1 , len(other_user.objectValues(portal_type="ERP5 Login")))
self.instance_tree.setDestinationSectionValue(destination_section)
self.tic()
self.assertRaises(Unauthorized, self.instance_tree.requestTransfer,
destination=None,
destination_project=None)
self.login(other_user.getUserId())
self.assertRaises(Unauthorized, self.instance_tree.requestTransfer,
destination=None,
destination_project=None)
self.login(destination_section.getUserId())
self.assertEqual(self.instance_tree.requestTransfer(
destination=None,
destination_project=None), None)
def test_RequesterInstance_requestTransfer_project(self):
destination_section = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.instance_tree.setDestinationSectionValue(destination_section)
self.login()
project = self._makeProject()
other_project = self._makeProject()
self.tic()
self.login(destination_section.getUserId())
self.assertEqual(self.instance_tree.Item_getCurrentProjectValue(), None)
self.assertEqual(self.instance_tree.Item_getCurrentOwnerValue(), None)
self.assertEqual(self.instance_tree.Item_getCurrentSiteValue(), None)
# Place in a project
self.assertEqual(self.instance_tree.requestTransfer(
destination=None,
destination_project=project.getRelativeUrl()), None)
self.tic()
self.assertEqual(
self.instance_tree.Item_getCurrentProjectValue(), project)
self.assertEqual(
self.instance_tree.Item_getCurrentOwnerValue(), destination_section)
self.assertEqual(
self.instance_tree.Item_getCurrentSiteValue(), None)
self.assertEqual(1,
len(self.instance_tree.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep(1)
self.login(destination_section.getUserId())
# We don't remove from Project if destination project is not provided
self.assertEqual(self.instance_tree.requestTransfer(
destination=None,
destination_project=None), None)
self.tic()
self.assertEqual(self.instance_tree.Item_getCurrentProjectValue(), project)
self.assertEqual(self.instance_tree.Item_getCurrentOwnerValue(), destination_section)
self.assertEqual(2,
len(self.instance_tree.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep(1)
# Place in another project
self.assertEqual(self.instance_tree.requestTransfer(
destination=None,
destination_project=other_project.getRelativeUrl()), None)
self.tic()
self.assertEqual(self.instance_tree.Item_getCurrentProjectValue(), other_project)
self.assertEqual(self.instance_tree.Item_getCurrentOwnerValue(), destination_section)
self.assertEqual(self.instance_tree.Item_getCurrentSiteValue(), None)
self.assertEqual(3,
len(self.instance_tree.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
self.login(destination_section.getUserId())
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep(1)
# We don't remove from Project if destination project is not provided
self.assertEqual(self.instance_tree.requestTransfer(
destination_project=None,
destination=None), None)
self.tic()
self.assertEqual(self.instance_tree.Item_getCurrentProjectValue(), other_project)
self.assertEqual(self.instance_tree.Item_getCurrentOwnerValue(), destination_section)
self.assertEqual(self.instance_tree.Item_getCurrentSiteValue(), None)
self.assertEqual(4,
len(self.instance_tree.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
def test_RequesterInstance_requestTransfer_owner(self):
destination_section = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.instance_tree.setDestinationSectionValue(destination_section)
self.login()
organisation = self._makeOrganisation()
other_organisation = self._makeOrganisation()
self.tic()
self.login(destination_section.getUserId())
self.assertEqual(self.instance_tree.Item_getCurrentProjectValue(), None)
self.assertEqual(self.instance_tree.Item_getCurrentOwnerValue(), None)
self.assertEqual(self.instance_tree.requestTransfer(
destination=organisation.getRelativeUrl(),
destination_project=None), None)
self.tic()
self.assertEqual(self.instance_tree.Item_getCurrentProjectValue(), None)
self.assertEqual(self.instance_tree.Item_getCurrentOwnerValue(), destination_section)
self.assertEqual(self.instance_tree.Item_getCurrentSiteValue(), organisation)
self.assertEqual(1,
len(self.instance_tree.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep(1)
self.login(destination_section.getUserId())
self.assertEqual(self.instance_tree.requestTransfer(
destination_project=None,
destination=None), None)
self.tic()
self.assertEqual(self.instance_tree.Item_getCurrentProjectValue(), None)
self.assertEqual(self.instance_tree.Item_getCurrentOwnerValue(), destination_section)
self.assertEqual(self.instance_tree.Item_getCurrentSiteValue(), organisation)
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep(1)
# Place in another project
self.assertEqual(self.instance_tree.requestTransfer(
destination_project=None,
destination=other_organisation.getRelativeUrl()), None)
self.tic()
self.assertEqual(3,
len(self.instance_tree.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
self.assertEqual(self.instance_tree.Item_getCurrentProjectValue(), None)
self.assertEqual(self.instance_tree.Item_getCurrentOwnerValue(), destination_section)
self.assertEqual(self.instance_tree.Item_getCurrentSiteValue(), other_organisation)
self.assertEqual(3,
len(self.instance_tree.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
self.login(destination_section.getUserId())
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep(1)
# We don't remove from Project if destination project is not provided
self.assertEqual(self.instance_tree.requestTransfer(
destination_project=None,
destination=None), None)
self.tic()
self.assertEqual(self.instance_tree.Item_getCurrentProjectValue(), None)
self.assertEqual(self.instance_tree.Item_getCurrentOwnerValue(), destination_section)
self.assertEqual(self.instance_tree.Item_getCurrentSiteValue(), other_organisation)
self.assertEqual(4,
len(self.instance_tree.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testSlapOSCloudInstanceSlapInterfaceWorkflow</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testSlapOSCloudInstanceSlapInterfaceWorkflow</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
class TestSlapOSCoreSlapOSCloudInteractionWorkflow(SlapOSTestCaseMixin):
def test_ComputeNode_setSubjectList(self):
self.person_user = self.makePerson()
self.login(self.person_user.getUserId())
new_id = self.generateNewId()
compute_node = self.portal.compute_node_module.newContent(
portal_type='Compute Node',
title="Compute Node %s for %s" % (new_id, self.person_user.getReference()),
reference="TESTCOMP-%s" % new_id)
self.tic()
assert compute_node.getDestinationSectionValue() is None
compute_node.edit(subject_list=[self.person_user.getDefaultEmailText()])
self.tic()
assert compute_node.getDestinationSection() == \
self.person_user.getRelativeUrl()
def check_Instance_validate(self, portal_type):
self.person_user = self.makePerson()
self.login(self.person_user.getUserId())
# Instance Tree required for security.
hs = self.portal.instance_tree_module.newContent(
portal_type='Instance Tree',
title="HS %s for %s" % (self.new_id, self.person_user.getReference()),
reference="TESTHS-%s" % self.new_id,
destination_reference="TESTHS-%s" % self.new_id,
destination_section=self.person_user.getRelativeUrl()
)
instance = self.portal.software_instance_module.newContent(
portal_type=portal_type,
title="Instance %s for %s" % (self.new_id, self.person_user.getReference()),
reference="TESTINST-%s" % self.new_id,
specialise_value=hs)
if portal_type == "Software Instance":
self._addERP5Login(instance)
self.tic()
def verify_activeSense_call(self):
if self.getRelativeUrl() == 'portal_alarms/slapos_allocate_instance':
instance.portal_workflow.doActionFor(instance, action='edit_action',
comment='activeSense triggered')
else:
return self.activeSense_call()
from Products.ERP5Type.Document.Alarm import Alarm #pylint: disable=import-error
Alarm.activeSense_call = Alarm.activeSense
Alarm.activeSense = verify_activeSense_call
try:
instance.validate()
self.tic()
finally:
Alarm.activeSense = Alarm.activeSense_call
self.assertEqual(
'activeSense triggered',
instance.workflow_history['edit_workflow'][-1]['comment'])
def test_SoftwareInstance_validate(self):
return self.check_Instance_validate("Software Instance")
def test_SlaveInstance_validate(self):
return self.check_Instance_validate("Slave Instance")
def test_SlaveInstance_requestDestroy(self):
self.person_user = self.makePerson()
self.login(self.person_user.getUserId())
# Instance Tree required for security.
hs = self.portal.instance_tree_module.newContent(
portal_type='Instance Tree',
title="HS %s for %s" % (self.new_id, self.person_user.getReference()),
reference="TESTHS-%s" % self.new_id,
destination_reference="TESTHS-%s" % self.new_id,
destination_section=self.person_user.getRelativeUrl()
)
instance = self.portal.software_instance_module.newContent(
portal_type='Slave Instance',
title="Instance %s for %s" % (self.new_id, self.person_user.getReference()),
reference="TESTINST-%s" % self.new_id,
destination_reference="TESTINST-%s" % self.new_id,
destination_section=self.person_user.getRelativeUrl(),
specialise_value=hs
)
request_kw = dict(
software_release='http://example.org',
software_type='http://example.org',
instance_xml=self.generateSafeXml(),
sla_xml=self.generateSafeXml(),
shared=True,
)
instance.requestStop(**request_kw)
self.assertEqual(instance.getValidationState(), 'draft')
instance.validate()
self.assertEqual(instance.getValidationState(), 'validated')
instance.requestDestroy(**request_kw)
self.assertEqual(instance.getValidationState(), 'invalidated')
def check_SoftwareInstallation_changeState(self, method_id):
self.person_user = self.makePerson()
self.login(self.person_user.getUserId())
compute_node = self.portal.compute_node_module.newContent(
portal_type='Compute Node',
title="Compute Node %s for %s" % (self.new_id, self.person_user.getReference()),
reference="TESTCOMP-%s" % self.new_id)
self._addERP5Login(compute_node)
installation = self.portal.software_installation_module.newContent(
portal_type='Software Installation',
title="Installation %s for %s" % (self.new_id, self.person_user.getReference()),
aggregate_value=compute_node,
)
self.tic()
def verify_reindexObject_call(self, *args, **kw):
if self.getRelativeUrl() == compute_node.getRelativeUrl():
compute_node.portal_workflow.doActionFor(compute_node, action='edit_action',
comment='reindexObject triggered on %s' % method_id)
else:
return self.reindexObject_call(*args, **kw)
from Products.ERP5Type.Base import Base
Base.reindexObject_call = Base._reindexObject
Base._reindexObject = verify_reindexObject_call
try:
getattr(installation, method_id)()
self.tic()
finally:
Base._reindexObject = Base.reindexObject_call
self.assertEqual(
'reindexObject triggered on %s' % method_id,
compute_node.workflow_history['edit_workflow'][-1]['comment'])
def test_SoftwareInstallation_changeState_onStart(self):
return self.check_SoftwareInstallation_changeState('requestStart')
def test_SoftwareInstallation_changeState_onDestroy(self):
return self.check_SoftwareInstallation_changeState('requestDestroy')
def check_SoftwareInstance_changeState(self, method_id):
self.person_user = self.makePerson()
self.login(self.person_user.getUserId())
new_id = self.generateNewId()
compute_node = self.portal.compute_node_module.newContent(
portal_type='Compute Node',
title="Compute Node %s for %s" % (new_id, self.person_user.getReference()),
reference="TESTCOMP-%s" % new_id)
self._addERP5Login(compute_node)
partition = compute_node.newContent(
portal_type='Compute Partition',
title="Partition Compute Node %s for %s" % (new_id,
self.person_user.getReference()),
reference="TESTPART-%s" % new_id)
instance = self.portal.software_instance_module.newContent(
portal_type="Software Instance",
title="Instance %s for %s" % (new_id, self.person_user.getReference()),
reference="TESTINST-%s" % new_id,
aggregate_value=partition,
destination_reference="TESTINST-%s" % new_id,
ssl_certificate="foo",
ssl_key="bar",
)
request_kw = dict(
software_release='http://example.org',
software_type='http://example.org',
instance_xml=self.generateSafeXml(),
sla_xml=self.generateSafeXml(),
shared=False,
)
if method_id == 'requestDestroy':
instance.requestStop(**request_kw)
self.tic()
def verify_reindexObject_call(self, *args, **kw):
if self.getRelativeUrl() == partition.getRelativeUrl():
partition.portal_workflow.doActionFor(partition, action='edit_action',
comment='reindexObject triggered on %s' % method_id)
else:
return self.reindexObject_call(*args, **kw)
# Replace activeSense by a dummy method
from Products.ERP5Type.Base import Base
Base.reindexObject_call = Base._reindexObject
Base._reindexObject = verify_reindexObject_call
try:
getattr(instance, method_id)(**request_kw)
self.tic()
finally:
Base._reindexObject = Base.reindexObject_call
self.assertEqual(
'reindexObject triggered on %s' % method_id,
partition.workflow_history['edit_workflow'][-1]['comment'])
def test_SoftwareInstance_changeState_onStart(self):
return self.check_SoftwareInstance_changeState("requestStart")
def test_SoftwareInstance_changeState_onStop(self):
return self.check_SoftwareInstance_changeState("requestStop")
def test_SoftwareInstance_changeState_onDestroy(self):
return self.check_SoftwareInstance_changeState("requestDestroy")
def check_change_instance_parameter(self, portal_type, method_id):
self.person_user = self.makePerson()
self.login(self.person_user.getUserId())
instance = self.portal.software_instance_module.newContent(
portal_type=portal_type,
title="Instance %s for %s" % (self.new_id, self.person_user.getReference()),
reference="TESTINST-%s" % self.new_id,
destination_reference="TESTINST-%s" % self.new_id,
ssl_certificate="foo",
ssl_key="bar",
)
self.tic()
self.assertEqual(None,
instance.workflow_history['instance_slap_interface_workflow'][-1]['action'])
instance.edit(**{method_id: self.generateSafeXml()})
self.tic()
self.assertEqual('bang',
instance.workflow_history['instance_slap_interface_workflow'][-1]['action'])
def test_change_instance_parameter_onInstanceUrlString(self):
return self.check_change_instance_parameter("Software Instance",
'url_string')
def test_change_instance_parameter_onInstanceTextContent(self):
return self.check_change_instance_parameter("Software Instance",
'text_content')
def test_change_instance_parameter_onInstanceSourceReference(self):
return self.check_change_instance_parameter("Software Instance",
'source_reference')
def test_change_instance_parameter_onInstanceSlaXML(self):
return self.check_change_instance_parameter("Software Instance",
'sla_xml')
def test_change_instance_parameter_onSlaveUrlString(self):
return self.check_change_instance_parameter("Slave Instance",
'url_string')
def test_change_instance_parameter_onSlaveTextContent(self):
return self.check_change_instance_parameter("Slave Instance",
'text_content')
def test_change_instance_parameter_onSlaveSourceReference(self):
return self.check_change_instance_parameter("Slave Instance",
'source_reference')
def test_change_instance_parameter_onSlaveSlaXML(self):
return self.check_change_instance_parameter("Slave Instance",
'sla_xml')
def test_SoftwareInstance_setSuccessorList(self):
portal_type = "Software Instance"
self.person_user = self.makePerson()
self.login(self.person_user.getUserId())
new_id = self.generateNewId()
instance3 = self.portal.software_instance_module.newContent(
portal_type=portal_type,
title="Instance %s for %s" % (new_id, self.person_user.getReference()),
reference="TESTINST-%s" % new_id,
destination_reference="TESTINST-%s" % new_id,
ssl_certificate="foo",
ssl_key="bar",
)
new_id = self.generateNewId()
instance2 = self.portal.software_instance_module.newContent(
portal_type=portal_type,
title="Instance %s for %s" % (new_id, self.person_user.getReference()),
reference="TESTINST-%s" % new_id,
destination_reference="TESTINST-%s" % new_id,
ssl_certificate="foo",
ssl_key="bar",
successor_value=instance3,
)
new_id = self.generateNewId()
instance1 = self.portal.software_instance_module.newContent(
portal_type=portal_type,
title="Instance %s for %s" % (new_id, self.person_user.getReference()),
reference="TESTINST-%s" % new_id,
destination_reference="TESTINST-%s" % new_id,
ssl_certificate="foo",
ssl_key="bar",
successor_value=instance2,
)
self.tic()
def verify_reindexObject_call(self, *args, **kw):
if self.getRelativeUrl() in (instance2.getRelativeUrl(),
instance3.getRelativeUrl()):
self.portal_workflow.doActionFor(instance1, action='edit_action',
comment='reindexObject triggered')
else:
return self.reindexObject_call(*args, **kw)
# Replace activeSense by a dummy method
from Products.ERP5Type.Base import Base
Base.reindexObject_call = Base._reindexObject
Base._reindexObject = verify_reindexObject_call
try:
instance1.edit(successor_value=instance3)
self.tic()
finally:
Base._reindexObject = Base.reindexObject_call
self.assertEqual(
'reindexObject triggered',
instance1.workflow_history['edit_workflow'][-1]['comment'])
self.assertEqual(
'reindexObject triggered',
instance1.workflow_history['edit_workflow'][-2]['comment'])
self.assertEqual(
None,
instance1.workflow_history['edit_workflow'][-3]['comment'])
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
</item> </item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>testSlapOSCloudCreateMovementSkins</string> </value> <value> <string>testSlapOSCloudInteractionWorkflow</string> </value>
</item> </item>
<item> <item>
<key> <string>default_source_reference</string> </key> <key> <string>default_source_reference</string> </key>
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>test.erp5.testSlapOSCloudCreateMovementSkins</string> </value> <value> <string>test.erp5.testSlapOSCloudInteractionWorkflow</string> </value>
</item> </item>
<item> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
......
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
from time import sleep
from zExceptions import Unauthorized
import transaction
class TestSlapOSCoreNetworkSlapInterfaceWorkflow(SlapOSTestCaseMixin):
def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
portal = self.getPortalObject()
person_user = self.makePerson()
self.tic()
# Login as new user
self.login(person_user.getUserId())
new_person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.assertEqual(person_user.getRelativeUrl(), new_person.getRelativeUrl())
self.network = portal.computer_network_module.newContent(
portal_type="Computer Network"
)
self.tic()
self.assertEqual(
self.network.getReference(), None)
def beforeTearDown(self):
transaction.abort()
def test_network_approveRegistration_with_reference(self):
reference = "TEST-%s" % self.generateNewId()
self.network.setReference(reference)
self.network.approveRegistration()
self.assertEqual(self.network.getReference(), reference)
def test_organisation_approveRegistration_already_validated(self):
# Login as admin since user cannot re-approve a validated organisation
self.login()
self.network.setReference(None)
self.network.validate()
# Don't raise if network is validated
self.assertEqual(self.network.approveRegistration(), None)
def _makeProject(self):
project = self.portal.project_module.newContent()
project.edit(reference="TESTPROJ-%s" % project.getId())
project.validate()
self.tic()
return project
def _makeOrganisation(self):
organisation = self.portal.organisation_module.newContent()
organisation.edit(reference="TESTSITE-%s" % organisation.getId())
organisation.validate()
self.tic()
return organisation
def test_ComputerNetwork_requestTransfer_project(self):
source_administrator = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.network.setSourceAdministrationValue(source_administrator)
self.login()
self.network.approveRegistration()
project = self._makeProject()
other_project = self._makeProject()
self.tic()
self.login(source_administrator.getUserId())
self.assertEqual(self.network.Item_getCurrentProjectValue(), None)
self.assertEqual(self.network.Item_getCurrentOwnerValue(), None)
# Place in a project
self.network.requestTransfer(
destination_section=None,
destination_project=project.getRelativeUrl())
self.tic()
self.assertEqual(self.network.Item_getCurrentProjectValue(), project)
self.assertEqual(self.network.Item_getCurrentOwnerValue(), source_administrator)
self.assertEqual(1,
len(self.network.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
self.login(source_administrator.getUserId())
# We don't remove from Project if destination project is not provided
self.network.requestTransfer(
destination_project=None,
destination_section=None
)
self.tic()
self.assertEqual(self.network.Item_getCurrentProjectValue(), project)
self.assertEqual(self.network.Item_getCurrentOwnerValue(), source_administrator)
self.assertEqual(2,
len(self.network.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep(1)
# Place in another project
self.network.requestTransfer(
destination_section=None,
destination_project=other_project.getRelativeUrl())
self.tic()
self.assertEqual(self.network.Item_getCurrentProjectValue(), other_project)
self.assertEqual(self.network.Item_getCurrentOwnerValue(), source_administrator)
self.assertEqual(3,
len(self.network.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
self.login(source_administrator.getUserId())
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep(1)
# We don't remove from Project if destination project is not provided
self.network.requestTransfer(
destination_project=None,
destination_section=None
)
self.tic()
self.assertEqual(self.network.Item_getCurrentProjectValue(), other_project)
self.assertEqual(self.network.Item_getCurrentOwnerValue(), source_administrator)
self.assertEqual(4,
len(self.network.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
def test_ComputerNetwork_requestTransfer_owner(self):
source_administrator = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.network.setSourceAdministrationValue(source_administrator)
self.login()
self.network.approveRegistration()
organisation = self._makeOrganisation()
other_organisation = self._makeOrganisation()
self.tic()
self.login(source_administrator.getUserId())
self.assertEqual(self.network.Item_getCurrentProjectValue(), None)
self.assertEqual(self.network.Item_getCurrentOwnerValue(), None)
self.network.requestTransfer(
destination_project=None,
destination_section=organisation.getRelativeUrl())
self.tic()
self.assertEqual(self.network.Item_getCurrentProjectValue(), None)
self.assertEqual(self.network.Item_getCurrentOwnerValue(), organisation)
self.assertEqual(1,
len(self.network.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
self.login(source_administrator.getUserId())
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep(1)
# We don't remove from Project if destination project is not provided
self.network.requestTransfer(
destination_project=None,
destination_section=None)
self.tic()
self.assertEqual(self.network.Item_getCurrentProjectValue(), None)
self.assertEqual(self.network.Item_getCurrentOwnerValue(), organisation)
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep(1)
# Place in another project
self.network.requestTransfer(
destination_project=None,
destination_section=other_organisation.getRelativeUrl())
self.tic()
self.assertEqual(3,
len(self.network.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
self.assertEqual(self.network.Item_getCurrentProjectValue(), None)
self.assertEqual(self.network.Item_getCurrentOwnerValue(), other_organisation)
self.assertEqual(3,
len(self.network.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
self.login(source_administrator.getUserId())
# Ensure that we don't have 2 new Internal Packing lists in the same second
sleep(1)
# We don't remove from Project if destination project is not provided
self.network.requestTransfer(
destination_project=None,
destination_section=None
)
self.tic()
self.assertEqual(self.network.Item_getCurrentProjectValue(), None)
self.assertEqual(self.network.Item_getCurrentOwnerValue(), other_organisation)
self.assertEqual(4,
len(self.network.getAggregateRelatedList(portal_type="Internal Packing List Line"))
)
def test_ComputerNetwork_requestTransfer_Unauthorized(self):
self.network.approveRegistration()
self.login()
self.assertRaises(Unauthorized, self.network.requestTransfer)
source_administrator = self.makePerson(user=1)
self.assertEqual(1 , len(source_administrator.objectValues( portal_type="ERP5 Login")))
self.login(source_administrator.getUserId())
self.assertRaises(Unauthorized, self.network.requestTransfer)
self.login()
other_user = self.makePerson(user=1)
self.assertEqual(1 , len(other_user.objectValues(portal_type="ERP5 Login")))
self.network.setSourceAdministrationValue(source_administrator)
self.tic()
self.assertRaises(Unauthorized, self.network.requestTransfer)
self.login(other_user.getUserId())
self.assertRaises(Unauthorized, self.network.requestTransfer)
self.login(source_administrator.getUserId())
self.network.requestTransfer(
destination_project=None,
destination_section=None
)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testSlapOSCloudNetworkSlapInterfaceWorkflow</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testSlapOSCloudNetworkSlapInterfaceWorkflow</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value>
<list>
<persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent>
</list>
</value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="Message" module="Products.ERP5Type.Message"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default</string> </key>
<value> <string>ID is invalid, should be \'${id_prefix}.VERSION.REFERENCE\'</string> </value>
</item>
<item>
<key> <string>domain</string> </key>
<value> <string>erp5_ui</string> </value>
</item>
<item>
<key> <string>mapping</string> </key>
<value>
<dictionary>
<item>
<key> <string>id_prefix</string> </key>
<value> <string>test</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>message</string> </key>
<value> <string>ID is invalid, should be \'${id_prefix}.VERSION.REFERENCE\'</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
from zExceptions import Unauthorized
import transaction
class TestSlapOSCoreOrganisationSlapInterfaceWorkflow(SlapOSTestCaseMixin):
def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
portal = self.getPortalObject()
person_user = self.makePerson()
self.tic()
# Login as new user
self.login(person_user.getUserId())
new_person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.assertEqual(person_user.getRelativeUrl(), new_person.getRelativeUrl())
self.organisation = portal.organisation_module.newContent(
portal_type="Organisation"
)
self.tic()
def beforeTearDown(self):
transaction.abort()
def test_organisation_approveRegistration_with_reference(self):
reference = "TEST-%s" % self.generateNewId()
self.organisation.setReference(reference)
self.organisation.approveRegistration()
self.assertEqual(self.organisation.getReference(), reference)
def test_organisation_approveRegistration_already_validated(self):
# Login as admin since user cannot re-approve a validated organisation
self.login()
self.organisation.setReference(None)
self.organisation.validate()
# Don't raise if organisation is validated
self.assertEqual(self.organisation.approveRegistration(), None)
def test_organisation_approveRegistration_site(self, role="host", expected_prefix="SITE-"):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.organisation.edit(role=role)
self.organisation.approveRegistration()
self.tic()
self.logout()
self.login(person.getUserId())
self.assertEqual(self.organisation.getValidationState(),
'validated')
self.assertTrue(self.organisation.getReference().startswith(expected_prefix),
"Reference don't start with %s : %s " % (
expected_prefix, self.organisation.getReference()))
assignment_list = [i for i in person.objectValues(portal_type="Assignment")
if i.getDestinationValue() == self.organisation]
self.assertEqual(len(assignment_list), 1)
self.assertEqual(assignment_list[0].getValidationState(), 'open')
self.assertIn("Assigment for Organisation ", assignment_list[0].getTitle())
def test_organisation_approveRegistration_organisation(self):
self.test_organisation_approveRegistration_site(role="client", expected_prefix="O-")
def test_organisation_leaveOrganisation_no_user(self):
self.login()
self.assertRaises(Unauthorized, self.organisation.leaveOrganisation)
def test_organisation_leaveOrganisation_after_join(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
# Just make things fast, by using the API tested above
self.organisation.approveRegistration()
self.tic()
self.logout()
self.login(person.getUserId())
assignment_list = [i for i in person.objectValues(portal_type="Assignment")
if i.getDestinationValue() == self.organisation]
self.assertEqual(len(assignment_list), 1)
self.assertEqual(assignment_list[0].getValidationState(), 'open')
self.organisation.leaveOrganisation()
self.tic()
self.login()
assignment_list = [i for i in person.objectValues(portal_type="Assignment")
if i.getDestinationValue() == self.organisation]
self.assertEqual(len(assignment_list), 1)
self.assertEqual(assignment_list[0].getValidationState(), 'closed')
def test_organisation_acceptInvitation_no_invitation_token(self):
self.assertRaises(TypeError, self.organisation.acceptInvitation)
def test_organisation_acceptInvitation_no_token_dont_exist(self):
self.assertRaises(ValueError, self.organisation.acceptInvitation,
invitation_token="DONOTEXIST")
def test_organisation_acceptInvitation(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.login()
token = self.portal.invitation_token_module.newContent(
portal_type="Invitation Token"
)
token_id = token.getId()
# User is None
self.assertRaises(ValueError, self.organisation.acceptInvitation,
invitation_token=token_id)
# Not validated yet
self.login(person.getUserId())
self.assertRaises(ValueError, self.organisation.acceptInvitation,
invitation_token=token_id)
self.login()
token.validate()
token.setSourceValue(person)
self.login(person.getUserId())
# Not used by the owner
self.assertRaises(ValueError, self.organisation.acceptInvitation,
invitation_token=token_id)
self.login()
token.setSourceValue(None)
self.login(person.getUserId())
self.organisation.acceptInvitation(invitation_token=token_id)
self.tic()
self.login()
assignment_list = [i for i in person.objectValues(portal_type="Assignment")
if i.getDestinationValue() == self.organisation]
self.assertEqual(len(assignment_list), 1)
self.assertEqual(assignment_list[0].getValidationState(), 'open')
self.assertEqual(token.getValidationState(), "invalidated")
def test_organisation_acceptInvitation_already_member(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.organisation.approveRegistration()
self.tic()
self.login()
assignment_list = [i for i in person.objectValues(portal_type="Assignment")
if i.getDestinationValue() == self.organisation]
self.assertEqual(len(assignment_list), 1)
self.assertEqual(assignment_list[0].getValidationState(), 'open')
token = self.portal.invitation_token_module.newContent(
portal_type="Invitation Token"
)
token_id = token.getId()
# User is None
self.assertRaises(ValueError, self.organisation.acceptInvitation,
invitation_token=token_id)
# Not validated yet
self.login(person.getUserId())
self.assertRaises(ValueError, self.organisation.acceptInvitation,
invitation_token=token_id)
self.login()
token.validate()
token.setSourceValue(person)
self.login(person.getUserId())
# Not used by the owner
self.assertRaises(ValueError, self.organisation.acceptInvitation,
invitation_token=token_id)
self.login()
token.setSourceValue(None)
self.login(person.getUserId())
self.organisation.acceptInvitation(invitation_token=token_id)
self.tic()
self.login()
assignment_list = [i for i in person.objectValues(portal_type="Assignment")
if i.getDestinationValue() == self.organisation]
self.assertEqual(len(assignment_list), 1)
self.assertEqual(assignment_list[0].getValidationState(), 'open')
self.assertEqual(token.getValidationState(), "invalidated")
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testSlapOSCloudOrganisationSlapInterfaceWorkflow</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testSlapOSCloudOrganisationSlapInterfaceWorkflow</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
import transaction
from unittest import expectedFailure
from AccessControl.SecurityManagement import getSecurityManager, \
setSecurityManager
class TestSlapOSCorePersonRequest(SlapOSTestCaseMixin):
def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
person_user = self.makePerson()
self.tic()
# Login as new user
self.login(person_user.getUserId())
new_person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.assertEqual(person_user.getRelativeUrl(), new_person.getRelativeUrl())
def beforeTearDown(self):
pass
def test_Person_requestSoftwareInstance_requiredParameter(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
software_release = self.generateNewSoftwareReleaseUrl()
software_title = "test"
software_type = "test"
instance_xml = """<?xml version="1.0" encoding="utf-8"?>
<instance>
</instance>
"""
sla_xml = "test"
shared = True
state = "started"
self.assertRaises(TypeError, person.requestSoftwareInstance)
# software_release is mandatory
self.assertRaises(TypeError, person.requestSoftwareInstance,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
state=state,
)
# software_title is mandatory
self.assertRaises(TypeError, person.requestSoftwareInstance,
software_release=software_release,
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
state=state,
)
# software_type is mandatory
self.assertRaises(TypeError, person.requestSoftwareInstance,
software_release=software_release,
software_title=software_title,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
state=state,
)
# instance_xml is mandatory
self.assertRaises(TypeError, person.requestSoftwareInstance,
software_release=software_release,
software_title=software_title,
software_type=software_type,
sla_xml=sla_xml,
shared=shared,
state=state,
)
# instance_xml is mandatory
self.assertRaises(TypeError, person.requestSoftwareInstance,
software_release=software_release,
software_title=software_title,
software_type=software_type,
sla_xml=sla_xml,
shared=shared,
state=state,
)
# sla_xml is mandatory
self.assertRaises(TypeError, person.requestSoftwareInstance,
software_release=software_release,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
shared=shared,
state=state,
)
# shared is mandatory
self.assertRaises(TypeError, person.requestSoftwareInstance,
software_release=software_release,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
state=state,
)
# state is mandatory
self.assertRaises(TypeError, person.requestSoftwareInstance,
software_release=software_release,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
)
def test_Person_requestSoftwareInstance_acceptedState(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
software_release = self.generateNewSoftwareReleaseUrl()
software_title = "test"
software_type = "test"
instance_xml = """<?xml version="1.0" encoding="utf-8"?>
<instance>
</instance>
"""
sla_xml = "test"
shared = True
# Only started, stopped, destroyed
self.assertRaises(ValueError, person.requestSoftwareInstance,
software_release=software_release,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
state="foo",
)
person.requestSoftwareInstance(
software_release=software_release,
software_title="started",
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
state="started",
)
instance_tree = person.REQUEST.get('request_instance_tree')
self.assertEqual("start_requested", instance_tree.getSlapState())
person.requestSoftwareInstance(
software_release=software_release,
software_title="stopped",
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
state="stopped",
)
instance_tree = person.REQUEST.get('request_instance_tree')
self.assertEqual("stop_requested", instance_tree.getSlapState())
person.requestSoftwareInstance(
software_release=software_release,
software_title="destroyed",
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
state="destroyed",
)
instance_tree = person.REQUEST.get('request_instance_tree')
self.assertEqual(None, instance_tree)
def test_Person_requestSoftwareInstance_returnInstanceTreeUrl(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
software_release = self.generateNewSoftwareReleaseUrl()
software_title = "test"
software_type = "test"
instance_xml = """<?xml version="1.0" encoding="utf-8"?>
<instance>
</instance>
"""
sla_xml = "test"
shared = True
state = "started"
person.requestSoftwareInstance(
software_release=software_release,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
state=state,
)
instance_tree = person.REQUEST.get('request_instance_tree')
self.assertEqual("Instance Tree",
instance_tree.getPortalType())
def test_Person_requestSoftwareInstance_createInstanceTree(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
software_release = self.generateNewSoftwareReleaseUrl()
software_title = "test"
software_type = "test"
instance_xml = """<?xml version="1.0" encoding="utf-8"?>
<instance>
</instance>
"""
sla_xml = "test"
shared = True
state = "started"
previous_id = self.getPortalObject().portal_ids\
.generateNewId(id_group='slap_hosting_subscription_reference',
id_generator='uid')
person.requestSoftwareInstance(
software_release=software_release,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
state=state,
)
instance_tree = person.REQUEST.get('request_instance_tree')
self.assertEqual(software_release,
instance_tree.getUrlString())
self.assertEqual(software_title, instance_tree.getTitle())
self.assertEqual(software_type, instance_tree.getSourceReference())
self.assertEqual(instance_xml, instance_tree.getTextContent())
self.assertEqual(sla_xml, instance_tree.getSlaXml())
self.assertEqual(shared, instance_tree.getRootSlave())
self.assertEqual("start_requested", instance_tree.getSlapState())
self.assertEqual("HOSTSUBS-%s" % (previous_id+1),
instance_tree.getReference())
self.assertEqual("validated", instance_tree.getValidationState())
def test_Person_requestSoftwareInstance_InstanceTreeNotReindexed(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
software_release = self.generateNewSoftwareReleaseUrl()
software_title = "test"
software_type = "test"
instance_xml = """<?xml version="1.0" encoding="utf-8"?>
<instance>
</instance>
"""
sla_xml = "test"
shared = True
state = "started"
person.requestSoftwareInstance(
software_release=software_release,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
state=state,
)
transaction.commit()
self.assertRaises(NotImplementedError, person.requestSoftwareInstance,
software_release=software_release,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
state=state,
)
@expectedFailure
def test_Person_requestSoftwareInstance_updateInstanceTree(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
software_release = self.generateNewSoftwareReleaseUrl()
software_title = "test"
software_type = "test"
instance_xml = """<?xml version="1.0" encoding="utf-8"?>
<instance>
</instance>
"""
sla_xml = "test"
shared = True
state = "started"
person.requestSoftwareInstance(
software_release=software_release,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
state=state,
)
instance_tree = person.REQUEST.get('request_instance_tree')
instance_tree_reference = instance_tree.getReference()
transaction.commit()
self.tic()
software_release2 = self.generateNewSoftwareReleaseUrl()
software_type2 = "test2"
instance_xml2 = """<?xml version='1.0' encoding='utf-8'?>
<instance>
</instance>"""
sla_xml2 = """<?xml version='1.0' encoding='utf-8'?>
<instance>
</instance>"""
shared2 = False
state2 = "stopped"
person.requestSoftwareInstance(
software_release=software_release2,
software_title=software_title,
software_type=software_type2,
instance_xml=instance_xml2,
sla_xml=sla_xml2,
shared=shared2,
state=state2,
)
instance_tree2 = person.REQUEST.get('request_instance_tree')
self.assertEqual(instance_tree.getRelativeUrl(),
instance_tree2.getRelativeUrl())
self.assertEqual(instance_tree_reference,
instance_tree2.getReference())
self.assertEqual(software_release2,
instance_tree.getUrlString())
self.assertEqual(software_title, instance_tree.getTitle())
self.assertEqual(software_type2, instance_tree.getSourceReference())
self.assertEqual(instance_xml2, instance_tree.getTextContent())
self.assertEqual(sla_xml2, instance_tree.getSlaXml())
self.assertEqual(shared2, instance_tree.getRootSlave())
self.assertEqual("stop_requested", instance_tree.getSlapState())
self.assertEqual("validated", instance_tree.getValidationState())
def test_Person_requestSoftwareInstance_duplicatedInstanceTree(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
software_release = self.generateNewSoftwareReleaseUrl()
software_title = "test"
software_type = "test"
instance_xml = """<?xml version="1.0" encoding="utf-8"?>
<instance>
</instance>
"""
sla_xml = "test"
shared = True
state = "started"
person.requestSoftwareInstance(
software_release=software_release,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
state=state,
)
instance_tree = person.REQUEST.get('request_instance_tree')
transaction.commit()
instance_tree2 = instance_tree.Base_createCloneDocument(
batch_mode=1)
instance_tree2.validate()
transaction.commit()
self.tic()
self.assertRaises(NotImplementedError, person.requestSoftwareInstance,
software_release=software_release,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
state=state,
)
def test_Person_requestSoftwareInstance_InstanceTreeNewTitle(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
software_release = self.generateNewSoftwareReleaseUrl()
software_title = "test"
software_type = "test"
instance_xml = """<?xml version='1.0' encoding='utf-8'?>
<instance>
</instance>"""
sla_xml = """<?xml version='1.0' encoding='utf-8'?>
<instance>
</instance>"""
shared = True
state = "started"
person.requestSoftwareInstance(
software_release=software_release,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
state=state,
)
instance_tree = person.REQUEST.get('request_instance_tree')
transaction.commit()
software_release2 = self.generateNewSoftwareReleaseUrl()
software_title2 = "test2"
software_type2 = "test2"
instance_xml2 = """<?xml version='1.0' encoding='utf-8'?>
<instance>
</instance>"""
sla_xml2 = """<?xml version='1.0' encoding='utf-8'?>
<instance>
</instance>"""
shared2 = False
state2 = "stopped"
person.requestSoftwareInstance(
software_release=software_release2,
software_title=software_title2,
software_type=software_type2,
instance_xml=instance_xml2,
sla_xml=sla_xml2,
shared=shared2,
state=state2,
)
instance_tree2 = person.REQUEST.get('request_instance_tree')
self.assertNotEqual(instance_tree.getRelativeUrl(),
instance_tree2.getRelativeUrl())
self.assertNotEqual(instance_tree.getReference(),
instance_tree2.getReference())
self.assertEqual(software_release2,
instance_tree2.getUrlString())
self.assertEqual(software_title2, instance_tree2.getTitle())
self.assertEqual(software_type2, instance_tree2.getSourceReference())
self.assertEqual(instance_xml2, instance_tree2.getTextContent())
self.assertEqual(sla_xml2, instance_tree2.getSlaXml())
self.assertEqual(shared2, instance_tree2.getRootSlave())
self.assertEqual("stop_requested", instance_tree2.getSlapState())
self.assertEqual("validated", instance_tree2.getValidationState())
def test_Person_requestSoftwareInstance_deletedInstanceTree(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
software_release = self.generateNewSoftwareReleaseUrl()
software_title = "test"
software_type = "test"
instance_xml = """<?xml version="1.0" encoding="utf-8"?>
<instance>
</instance>
"""
sla_xml = "test"
shared = True
person.requestSoftwareInstance(
software_release=software_release,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
state="stopped",
)
instance_tree = person.REQUEST.get('request_instance_tree')
transaction.commit()
self.tic()
person.requestSoftwareInstance(
software_release=software_release,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
state="destroyed",
)
instance_tree2 = person.REQUEST.get('request_instance_tree')
self.assertEqual(None, instance_tree2)
self.assertEqual("destroy_requested", instance_tree.getSlapState())
def test_Person_requestSoftwareInstance_noConflictWithDeletedInstanceTree(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
software_release = self.generateNewSoftwareReleaseUrl()
software_title = "test"
software_type = "test"
instance_xml = """<?xml version="1.0" encoding="utf-8"?>
<instance>
</instance>
"""
sla_xml = "test"
shared = True
person.requestSoftwareInstance(
software_release=software_release,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
state="stopped",
)
instance_tree = person.REQUEST.get('request_instance_tree')
transaction.commit()
self.tic()
person.requestSoftwareInstance(
software_release=software_release,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
state="destroyed",
)
self.assertEqual("destroy_requested", instance_tree.getSlapState())
transaction.commit()
self.tic()
person.requestSoftwareInstance(
software_release=software_release,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
state="started",
)
instance_tree2 = person.REQUEST.get('request_instance_tree')
self.assertEqual("start_requested", instance_tree2.getSlapState())
self.assertNotEqual(instance_tree.getRelativeUrl(),
instance_tree2.getRelativeUrl())
class TestSlapOSCorePersonRequestComputeNode(SlapOSTestCaseMixin):
def generateNewComputeNodeTitle(self):
return 'My Comp %s' % self.generateNewId()
def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
person_user = self.makePerson()
self.tic()
# Login as new user
self.login(person_user.getUserId())
new_person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.assertEqual(person_user.getRelativeUrl(), new_person.getRelativeUrl())
def beforeTearDown(self):
pass
def test_request_requiredParameter(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
# compute_node_title is mandatory
self.assertRaises(TypeError, person.requestComputeNode)
# if provided does not raise
compute_node_title = self.generateNewComputeNodeTitle()
person.requestComputeNode(compute_node_title=compute_node_title)
def test_request(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
compute_node_title = self.generateNewComputeNodeTitle()
person.requestComputeNode(compute_node_title=compute_node_title)
# check what is returned via request
compute_node_url = person.REQUEST.get('compute_node')
compute_node_absolute_url = person.REQUEST.get('compute_node_url')
compute_node_reference = person.REQUEST.get('compute_node_reference')
self.assertNotEqual(None, compute_node_url)
self.assertNotEqual(None, compute_node_absolute_url)
self.assertNotEqual(None, compute_node_reference)
def test_request_createdComputeNode(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
previous_id = self.getPortalObject().portal_ids\
.generateNewId(id_group='slap_computer_reference',
id_generator='uid')
compute_node_title = self.generateNewComputeNodeTitle()
person.requestComputeNode(compute_node_title=compute_node_title)
# check what is returned via request
compute_node_url = person.REQUEST.get('compute_node')
compute_node_absolute_url = person.REQUEST.get('compute_node_url')
compute_node_reference = person.REQUEST.get('compute_node_reference')
self.assertNotEqual(None, compute_node_url)
self.assertNotEqual(None, compute_node_absolute_url)
self.assertNotEqual(None, compute_node_reference)
# check that title is ok
compute_node = person.restrictedTraverse(compute_node_url)
self.assertEqual(compute_node_title, compute_node.getTitle())
# check that data are sane
self.assertEqual(compute_node_absolute_url, compute_node.absolute_url())
self.assertEqual(compute_node_reference, compute_node.getReference())
self.assertEqual('COMP-%s' % (previous_id + 1), compute_node.getReference())
self.assertEqual('validated', compute_node.getValidationState())
self.assertEqual('open/personal', compute_node.getAllocationScope())
self.assertEqual('open', compute_node.getCapacityScope())
def test_request_notReindexedCompute(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
compute_node_title = self.generateNewComputeNodeTitle()
person.requestComputeNode(compute_node_title=compute_node_title)
transaction.commit()
self.assertRaises(NotImplementedError, person.requestComputeNode,
compute_node_title=compute_node_title)
def test_multiple_request_createdComputeNode(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
previous_id = self.getPortalObject().portal_ids\
.generateNewId(id_group='slap_computer_reference',
id_generator='uid')
compute_node_title = self.generateNewComputeNodeTitle()
compute_node_title2 = self.generateNewComputeNodeTitle()
person.requestComputeNode(compute_node_title=compute_node_title)
# check what is returned via request
compute_node_url = person.REQUEST.get('compute_node')
compute_node_absolute_url = person.REQUEST.get('compute_node_url')
compute_node_reference = person.REQUEST.get('compute_node_reference')
self.assertNotEqual(None, compute_node_url)
self.assertNotEqual(None, compute_node_absolute_url)
self.assertNotEqual(None, compute_node_reference)
# check that title is ok
compute_node = person.restrictedTraverse(compute_node_url)
self.assertEqual(compute_node_title, compute_node.getTitle())
# check that data are sane
self.assertEqual(compute_node_absolute_url, compute_node.absolute_url())
self.assertEqual(compute_node_reference, compute_node.getReference())
self.assertEqual('COMP-%s' % (previous_id + 1), compute_node.getReference())
self.assertEqual('validated', compute_node.getValidationState())
self.assertEqual('open/personal', compute_node.getAllocationScope())
self.assertEqual('open', compute_node.getCapacityScope())
self.tic()
# request again the same compute_node
person.requestComputeNode(compute_node_title=compute_node_title)
# check what is returned via request
compute_node_url = person.REQUEST.get('compute_node')
compute_node_absolute_url = person.REQUEST.get('compute_node_url')
compute_node_reference = person.REQUEST.get('compute_node_reference')
self.assertNotEqual(None, compute_node_url)
self.assertNotEqual(None, compute_node_absolute_url)
self.assertNotEqual(None, compute_node_reference)
# check that title is ok
compute_node = person.restrictedTraverse(compute_node_url)
self.assertEqual(compute_node_title, compute_node.getTitle())
# check that data are sane
self.assertEqual(compute_node_absolute_url, compute_node.absolute_url())
self.assertEqual(compute_node_reference, compute_node.getReference())
self.assertEqual('COMP-%s' % (previous_id + 1), compute_node.getReference())
self.assertEqual('validated', compute_node.getValidationState())
self.assertEqual('open/personal', compute_node.getAllocationScope())
self.assertEqual('open', compute_node.getCapacityScope())
# and now another one
person.requestComputeNode(compute_node_title=compute_node_title2)
# check what is returned via request
compute_node_url2 = person.REQUEST.get('compute_node')
compute_node_absolute_url2 = person.REQUEST.get('compute_node_url')
compute_node_reference2 = person.REQUEST.get('compute_node_reference')
self.assertNotEqual(None, compute_node_url2)
self.assertNotEqual(None, compute_node_absolute_url2)
self.assertNotEqual(None, compute_node_reference2)
# check that compute_nodes are really different objects
self.assertNotEqual(compute_node_url2, compute_node_url)
# check that title is ok
compute_node2 = person.restrictedTraverse(compute_node_url2)
self.assertEqual(compute_node_title2, compute_node2.getTitle())
# check that data are sane
self.assertEqual(compute_node_absolute_url2, compute_node2.absolute_url())
self.assertEqual(compute_node_reference2, compute_node2.getReference())
self.assertEqual('COMP-%s' % (previous_id + 2), compute_node2.getReference())
self.assertEqual('validated', compute_node2.getValidationState())
self.assertEqual('open/personal', compute_node2.getAllocationScope())
self.assertEqual('open', compute_node2.getCapacityScope())
def test_request_duplicatedComputeNode(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
compute_node_title = self.generateNewComputeNodeTitle()
person.requestComputeNode(compute_node_title=compute_node_title)
# check what is returned via request
compute_node_url = person.REQUEST.get('compute_node')
compute_node_absolute_url = person.REQUEST.get('compute_node_url')
compute_node_reference = person.REQUEST.get('compute_node_reference')
self.assertNotEqual(None, compute_node_url)
self.assertNotEqual(None, compute_node_absolute_url)
self.assertNotEqual(None, compute_node_reference)
# check that title is ok
compute_node = person.restrictedTraverse(compute_node_url)
sm = getSecurityManager()
try:
self.login()
compute_node2 = compute_node.Base_createCloneDocument(batch_mode=1)
compute_node2.validate()
finally:
setSecurityManager(sm)
self.tic()
self.assertRaises(NotImplementedError, person.requestComputeNode,
compute_node_title=compute_node_title)
class TestSlapOSCorePersonRequestProject(SlapOSTestCaseMixin):
def generateNewProjectTitle(self):
return 'My Project %s' % self.generateNewId()
def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
person_user = self.makePerson()
self.tic()
# Login as new user
self.login(person_user.getUserId())
new_person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.assertEqual(person_user.getRelativeUrl(), new_person.getRelativeUrl())
def beforeTearDown(self):
pass
def test_Person_requestProject_title_is_mandatoty(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.assertRaises(TypeError, person.requestProject)
def test_Person_requestProject(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
project_title = self.generateNewProjectTitle()
person.requestProject(project_title=project_title)
self.tic()
self.login()
# check what is returned via request
project_relative_url = person.REQUEST.get('project_relative_url')
project_reference = person.REQUEST.get('project_reference')
self.assertNotEqual(None, project_relative_url)
self.assertNotEqual(None, project_reference)
project = person.restrictedTraverse(project_relative_url)
self.assertEqual(project.getTitle(), project_title)
self.assertEqual(project.getValidationState(), "validated")
self.assertEqual(project.getDestinationDecision(), person.getRelativeUrl())
def test_Person_requestProject_duplicated(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
project_title = self.generateNewProjectTitle()
person.requestProject(project_title=project_title)
self.tic()
self.login()
# check what is returned via request
project_relative_url = person.REQUEST.get('project_relative_url')
project_reference = person.REQUEST.get('project_reference')
self.assertNotEqual(None, project_relative_url)
self.assertNotEqual(None, project_reference)
project = person.restrictedTraverse(project_relative_url)
self.assertEqual(project.getTitle(), project_title)
self.assertEqual(project.getValidationState(), "validated")
self.assertEqual(project.getDestinationDecision(), person.getRelativeUrl())
project2 = project.Base_createCloneDocument(batch_mode=1)
project2.validate()
self.tic()
self.login(person.getUserId())
self.assertRaises(NotImplementedError, person.requestProject,
project_title=project_title)
def test_Person_requestProject_request_again(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
project_title = self.generateNewProjectTitle()
person.requestProject(project_title=project_title)
# check what is returned via request
project_relative_url = person.REQUEST.get('project_relative_url')
project_reference = person.REQUEST.get('project_reference')
self.assertNotEqual(None, project_relative_url)
self.assertNotEqual(None, project_reference)
self.tic()
self.login()
# check what is returned via request
person.REQUEST.set('project_relative_url', None)
person.REQUEST.set('project_reference', None)
self.login(person.getUserId())
person.requestProject(project_title=project_title)
# check what is returned via request
same_project_relative_url = person.REQUEST.get('project_relative_url')
same_project_reference = person.REQUEST.get('project_reference')
self.assertEqual(same_project_relative_url, project_relative_url)
self.assertEqual(same_project_reference, project_reference)
class TestSlapOSCorePersonRequestOrganisation(SlapOSTestCaseMixin):
def generateNewOrganisationTitle(self):
return 'My Organisation %s' % self.generateNewId()
def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
person_user = self.makePerson()
self.tic()
# Login as new user
self.login(person_user.getUserId())
new_person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.assertEqual(person_user.getRelativeUrl(), new_person.getRelativeUrl())
def beforeTearDown(self):
pass
def test_Person_requestOrganisation_title_is_mandatoty(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.assertRaises(TypeError, person.requestOrganisation)
def test_Person_requestOrganisation(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
organisation_title = self.generateNewOrganisationTitle()
person.requestOrganisation(organisation_title=organisation_title)
self.tic()
self.login()
# check what is returned via request
organisation_relative_url = person.REQUEST.get('organisation_relative_url')
self.assertNotEqual(None, organisation_relative_url)
organisation = person.restrictedTraverse(organisation_relative_url)
self.assertEqual(organisation.getTitle(), organisation_title)
self.assertEqual(organisation.getValidationState(), "validated")
self.assertEqual(organisation.getRoleId(), "client")
self.assertIn("O-", organisation.getReference())
def test_Person_requestOrganisation_duplicated(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
organisation_title = self.generateNewOrganisationTitle()
person.requestOrganisation(organisation_title=organisation_title)
self.tic()
self.login()
# check what is returned via request
organisation_relative_url = person.REQUEST.get('organisation_relative_url')
self.assertNotEqual(None, organisation_relative_url)
organisation = person.restrictedTraverse(organisation_relative_url)
self.assertEqual(organisation.getTitle(), organisation_title)
self.assertEqual(organisation.getValidationState(), "validated")
self.assertEqual(organisation.getRoleId(), "client")
self.assertIn("O-", organisation.getReference())
organisation2 = organisation.Base_createCloneDocument(batch_mode=1)
organisation2.validate()
self.tic()
self.login(person.getUserId())
self.assertRaises(NotImplementedError, person.requestOrganisation,
organisation_title=organisation_title)
def test_Person_requestOrganisation_request_again(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
organisation_title = self.generateNewOrganisationTitle()
person.requestOrganisation(organisation_title=organisation_title)
# check what is returned via request
organisation_relative_url = person.REQUEST.get('organisation_relative_url')
self.assertNotEqual(None, organisation_relative_url)
self.tic()
self.login()
# check what is returned via request
person.REQUEST.set('organisation_relative_url', None)
self.login(person.getUserId())
person.requestOrganisation(organisation_title=organisation_title)
# check what is returned via request
same_organisation_relative_url = person.REQUEST.get('organisation_relative_url')
self.assertEqual(same_organisation_relative_url, organisation_relative_url)
def test_Person_requestOrganisation_dont_conflict_with_site(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
organisation_title = self.generateNewOrganisationTitle()
person.requestOrganisation(organisation_title=organisation_title)
self.tic()
self.login()
# check what is returned via request
organisation_relative_url = person.REQUEST.get('organisation_relative_url')
self.assertNotEqual(None, organisation_relative_url)
organisation = person.restrictedTraverse(organisation_relative_url)
self.assertEqual(organisation.getTitle(), organisation_title)
self.assertEqual(organisation.getValidationState(), "validated")
self.assertEqual(organisation.getRoleId(), "client")
self.assertIn("O-", organisation.getReference())
organisation2 = organisation.Base_createCloneDocument(batch_mode=1)
organisation2.edit(role="host")
organisation2.validate()
person.REQUEST.set('organisation_relative_url', None)
self.tic()
self.login(person.getUserId())
person.requestOrganisation(organisation_title=organisation_title)
self.tic()
self.login()
# check what is returned via request
same_organisation_relative_url = person.REQUEST.get('organisation_relative_url')
self.assertEqual(same_organisation_relative_url, organisation_relative_url)
class TestSlapOSCorePersonRequestSite(SlapOSTestCaseMixin):
def generateNewOrganisationTitle(self):
return 'My Site %s' % self.generateNewId()
def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
person_user = self.makePerson()
self.tic()
# Login as new user
self.login(person_user.getUserId())
new_person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.assertEqual(person_user.getRelativeUrl(), new_person.getRelativeUrl())
def beforeTearDown(self):
pass
def test_Person_requestSite_title_is_mandatoty(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.assertRaises(TypeError, person.requestSite)
def test_Person_requestSite(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
organisation_title = self.generateNewOrganisationTitle()
person.requestSite(organisation_title=organisation_title)
self.tic()
self.login()
# check what is returned via request
organisation_relative_url = person.REQUEST.get('organisation_relative_url')
self.assertNotEqual(None, organisation_relative_url)
organisation = person.restrictedTraverse(organisation_relative_url)
self.assertEqual(organisation.getTitle(), organisation_title)
self.assertEqual(organisation.getValidationState(), "validated")
self.assertEqual(organisation.getRoleId(), "host")
self.assertIn("SITE-", organisation.getReference())
def test_Person_requestSite_duplicated(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
organisation_title = self.generateNewOrganisationTitle()
person.requestSite(organisation_title=organisation_title)
self.tic()
self.login()
# check what is returned via request
organisation_relative_url = person.REQUEST.get('organisation_relative_url')
self.assertNotEqual(None, organisation_relative_url)
organisation = person.restrictedTraverse(organisation_relative_url)
self.assertEqual(organisation.getTitle(), organisation_title)
self.assertEqual(organisation.getValidationState(), "validated")
self.assertEqual(organisation.getRoleId(), "host")
self.assertIn("SITE-", organisation.getReference())
organisation2 = organisation.Base_createCloneDocument(batch_mode=1)
organisation2.validate()
self.tic()
self.login(person.getUserId())
self.assertRaises(NotImplementedError, person.requestSite,
organisation_title=organisation_title)
def test_Person_requestSite_request_again(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
organisation_title = self.generateNewOrganisationTitle()
person.requestSite(organisation_title=organisation_title)
# check what is returned via request
organisation_relative_url = person.REQUEST.get('organisation_relative_url')
self.assertNotEqual(None, organisation_relative_url)
self.tic()
self.login()
# check what is returned via request
person.REQUEST.set('organisation_relative_url', None)
self.login(person.getUserId())
person.requestSite(organisation_title=organisation_title)
# check what is returned via request
same_organisation_relative_url = person.REQUEST.get('organisation_relative_url')
self.assertEqual(same_organisation_relative_url, organisation_relative_url)
def test_Person_requestSite_dont_conflict_with_site(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
organisation_title = self.generateNewOrganisationTitle()
person.requestSite(organisation_title=organisation_title)
self.tic()
self.login()
# check what is returned via request
organisation_relative_url = person.REQUEST.get('organisation_relative_url')
self.assertNotEqual(None, organisation_relative_url)
organisation = person.restrictedTraverse(organisation_relative_url)
self.assertEqual(organisation.getTitle(), organisation_title)
self.assertEqual(organisation.getValidationState(), "validated")
self.assertEqual(organisation.getRoleId(), "host")
self.assertIn("SITE-", organisation.getReference())
organisation2 = organisation.Base_createCloneDocument(batch_mode=1)
organisation2.edit(role="client")
organisation2.validate()
person.REQUEST.set('organisation_relative_url', None)
self.tic()
self.login(person.getUserId())
person.requestSite(organisation_title=organisation_title)
self.tic()
self.login()
# check what is returned via request
same_organisation_relative_url = person.REQUEST.get('organisation_relative_url')
self.assertEqual(same_organisation_relative_url, organisation_relative_url)
class TestSlapOSCorePersonRequestNetwork(SlapOSTestCaseMixin):
def generateNewNetworkTitle(self):
return 'My Network %s' % self.generateNewId()
def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
person_user = self.makePerson()
self.tic()
# Login as new user
self.login(person_user.getUserId())
new_person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.assertEqual(person_user.getRelativeUrl(), new_person.getRelativeUrl())
def beforeTearDown(self):
pass
def test_Person_requestNetwork_title_is_mandatoty(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.assertRaises(TypeError, person.requestNetwork)
def test_Person_requestNetwork(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
network_title = self.generateNewNetworkTitle()
person.requestNetwork(network_title=network_title)
self.tic()
self.login()
# check what is returned via request
network_relative_url = person.REQUEST.get('computer_network_relative_url')
self.assertNotEqual(None, network_relative_url)
network = person.restrictedTraverse(network_relative_url)
self.assertEqual(network.getSourceAdministration(),
person.getRelativeUrl())
self.assertEqual(network.getTitle(), network_title)
self.assertEqual(network.getValidationState(), "validated")
self.assertIn("NET-", network.getReference())
def test_Person_requestNetwork_duplicated(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
network_title = self.generateNewNetworkTitle()
person.requestNetwork(network_title=network_title)
self.tic()
self.login()
# check what is returned via request
network_relative_url = person.REQUEST.get('computer_network_relative_url')
self.assertNotEqual(None, network_relative_url)
network = person.restrictedTraverse(network_relative_url)
self.assertEqual(network.getSourceAdministration(),
person.getRelativeUrl())
self.assertEqual(network.getTitle(), network_title)
self.assertEqual(network.getValidationState(), "validated")
self.assertIn("NET-", network.getReference())
network2 = network.Base_createCloneDocument(batch_mode=1)
network2.validate()
self.tic()
self.login(person.getUserId())
self.assertRaises(NotImplementedError, person.requestNetwork,
network_title=network_title)
def test_Person_requestNetwork_request_again(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
network_title = self.generateNewNetworkTitle()
person.requestNetwork(network_title=network_title)
# check what is returned via request
network_relative_url = person.REQUEST.get('computer_network_relative_url')
self.assertNotEqual(None, network_relative_url)
self.tic()
self.login()
# check what is returned via request
person.REQUEST.set('computer_network_relative_url', None)
self.login(person.getUserId())
person.requestNetwork(network_title=network_title)
# check what is returned via request
same_network_relative_url = person.REQUEST.get('computer_network_relative_url')
self.assertEqual(same_network_relative_url, network_relative_url)
class TestSlapOSCorePersonRequestToken(SlapOSTestCaseMixin):
def generateNewTokenUrl(self):
return 'https://%s.no.where/%s' % (
self.generateNewId(),
self.generateNewId())
def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
person_user = self.makePerson()
self.tic()
# Login as new user
self.login(person_user.getUserId())
new_person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.assertEqual(person_user.getRelativeUrl(), new_person.getRelativeUrl())
def beforeTearDown(self):
pass
def test_Person_requestToken_requested_url_is_mandatory(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.assertRaises(TypeError, person.requestToken)
def test_Person_requestToken(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
request_url = self.generateNewTokenUrl()
person.requestToken(request_url=request_url)
self.tic()
self.login()
# check what is returned via request
token_id = person.REQUEST.get('token')
self.assertNotEqual(None, token_id)
token = self.portal.access_token_module[token_id]
self.assertEqual(token.getAgent(),
person.getRelativeUrl())
self.assertEqual(token.getUrlString(), request_url)
self.assertEqual(token.getValidationState(), "validated")
self.assertEqual(
token.getPortalType(), "One Time Restricted Access Token")
self.assertEqual(token.getUrlMethod(), "POST")
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testSlapOSCloudPersonSlapInterfaceWorkflow</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testSlapOSCloudPersonSlapInterfaceWorkflow</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
from zExceptions import Unauthorized
import transaction
class TestSlapOSCoreProjectSlapInterfaceWorkflow(SlapOSTestCaseMixin):
def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
portal = self.getPortalObject()
person_user = self.makePerson()
self.tic()
# Login as new user
self.login(person_user.getUserId())
new_person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.assertEqual(person_user.getRelativeUrl(), new_person.getRelativeUrl())
self.project = portal.project_module.newContent(
portal_type="Project"
)
# Value set by the init
self.assertTrue(self.project.getReference().startswith("PROJ-"),
"Reference don't start with PROJ- : %s" % self.project.getReference())
self.tic()
def beforeTearDown(self):
transaction.abort()
def test_project_approveRegistration_no_reference(self):
self.project.setReference(None)
self.assertRaises(ValueError, self.project.approveRegistration)
def test_project_approveRegistration_already_validated(self):
# Login as admin since user cannot re-approve a validated project
self.login()
self.project.setReference(None)
self.project.validate()
# Don't raise if project is validated
self.assertEqual(self.project.approveRegistration(), None)
def test_project_approveRegistration(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.project.approveRegistration()
self.tic()
self.logout()
self.login(person.getUserId())
self.assertEqual(self.project.getValidationState(),
'validated')
self.assertNotEqual(self.project.getStartDate(),
None)
assignment_list = [i for i in person.objectValues(portal_type="Assignment")
if i.getDestinationProjectValue() == self.project]
self.assertEqual(len(assignment_list), 1)
self.assertEqual(assignment_list[0].getValidationState(), 'open')
self.assertIn("Assigment for Project ", assignment_list[0].getTitle())
def test_project_leaveProject_no_user(self):
self.login()
self.assertRaises(Unauthorized, self.project.leaveProject)
def test_project_leaveProject_owner(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.project.edit(destination_decision=person.getRelativeUrl())
self.tic()
self.project.leaveProject()
self.assertEqual(self.project.getDestinationDecision(),
None)
def test_project_leaveProject_after_join(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
# Just make things fast, by using the API tested above
self.project.approveRegistration()
self.tic()
self.logout()
self.login(person.getUserId())
assignment_list = [i for i in person.objectValues(portal_type="Assignment")
if i.getDestinationProjectValue() == self.project]
self.assertEqual(len(assignment_list), 1)
self.assertEqual(assignment_list[0].getValidationState(), 'open')
self.project.leaveProject()
self.tic()
self.login()
assignment_list = [i for i in person.objectValues(portal_type="Assignment")
if i.getDestinationProjectValue() == self.project]
self.assertEqual(len(assignment_list), 1)
self.assertEqual(assignment_list[0].getValidationState(), 'closed')
def test_project_acceptInvitation_no_invitation_token(self):
self.assertRaises(TypeError, self.project.acceptInvitation)
def test_project_acceptInvitation_no_token_dont_exist(self):
self.assertRaises(ValueError, self.project.acceptInvitation,
invitation_token="DONOTEXIST")
def test_project_acceptInvitation(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.login()
token = self.portal.invitation_token_module.newContent(
portal_type="Invitation Token"
)
token_id = token.getId()
# User is None
self.assertRaises(ValueError, self.project.acceptInvitation,
invitation_token=token_id)
# Not validated yet
self.login(person.getUserId())
self.assertRaises(ValueError, self.project.acceptInvitation,
invitation_token=token_id)
self.login()
token.validate()
token.setSourceValue(person)
self.login(person.getUserId())
# Not used by the owner
self.assertRaises(ValueError, self.project.acceptInvitation,
invitation_token=token_id)
self.login()
token.setSourceValue(None)
self.login(person.getUserId())
self.project.acceptInvitation(invitation_token=token_id)
self.tic()
self.login()
assignment_list = [i for i in person.objectValues(portal_type="Assignment")
if i.getDestinationProjectValue() == self.project]
self.assertEqual(len(assignment_list), 1)
self.assertEqual(assignment_list[0].getValidationState(), 'open')
self.assertEqual(token.getValidationState(), "invalidated")
def test_project_acceptInvitation_already_member(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.project.approveRegistration()
self.tic()
self.login()
assignment_list = [i for i in person.objectValues(portal_type="Assignment")
if i.getDestinationProjectValue() == self.project]
self.assertEqual(len(assignment_list), 1)
self.assertEqual(assignment_list[0].getValidationState(), 'open')
token = self.portal.invitation_token_module.newContent(
portal_type="Invitation Token"
)
token_id = token.getId()
# User is None
self.assertRaises(ValueError, self.project.acceptInvitation,
invitation_token=token_id)
# Not validated yet
self.login(person.getUserId())
self.assertRaises(ValueError, self.project.acceptInvitation,
invitation_token=token_id)
self.login()
token.validate()
token.setSourceValue(person)
self.login(person.getUserId())
# Not used by the owner
self.assertRaises(ValueError, self.project.acceptInvitation,
invitation_token=token_id)
self.login()
token.setSourceValue(None)
self.login(person.getUserId())
self.project.acceptInvitation(invitation_token=token_id)
self.tic()
self.login()
assignment_list = [i for i in person.objectValues(portal_type="Assignment")
if i.getDestinationProjectValue() == self.project]
self.assertEqual(len(assignment_list), 1)
self.assertEqual(assignment_list[0].getValidationState(), 'open')
self.assertEqual(token.getValidationState(), "invalidated")
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testSlapOSCloudProjectSlapInterfaceWorkflow</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testSlapOSCloudProjectSlapInterfaceWorkflow</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
This source diff could not be displayed because it is too large. You can view the blob instead.
compute_node = state_change['object']
portal = compute_node.getPortalObject()
from zExceptions import Unauthorized
from DateTime import DateTime
# Get required arguments
kwargs = state_change.kwargs
# Required args
# Raise TypeError if all parameters are not provided
try:
# destination=None, destination_project=None, destination_section=None
destination = kwargs['destination']
destination_project = kwargs["destination_project"]
destination_section = kwargs["destination_section"]
except KeyError:
raise TypeError("ComputeNode_requestTransfer takes exactly 3 arguments")
user = portal.portal_membership.getAuthenticatedMember().getUserValue()
if user is None or user.getRelativeUrl() != compute_node.getSourceAdministration():
raise Unauthorized("Only the compute_node owner can Transfer compute_node from one location to another.")
tag = "%s_%s_%s_%s_inProgress" % (compute_node.getUid(), destination, destination_project, destination_section)
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)
movement_portal_type = "Internal Packing List"
source = compute_node.Item_getCurrentSiteValue()
source_project = compute_node.Item_getCurrentProjectValue()
source_section = compute_node.Item_getCurrentOwnerValue()
resource_value = compute_node.Item_getResourceValue()
if destination_project is None and source_project is not None:
destination_project = source_project.getRelativeUrl()
if destination_section is None:
destination_section = compute_node.getSourceAdministration()
if destination is None and source is not None:
# We do not change location of the machine
destination = source.getRelativeUrl()
if source is None and destination is None:
raise ValueError("Sorry, destination is required for the initial set.")
if source_section is None:
source_section = compute_node.getSourceAdministration()
resource_value = portal.product_module.compute_node
module = portal.getDefaultModule(portal_type=movement_portal_type)
line_portal_type = '%s Line' % movement_portal_type
delivery = module.newContent(title="Transfer %s to %s" % (compute_node.getTitle(), destination),
source_value=source,
source_section_value=source_section,
source_project_value=source_project,
destination=destination,
destination_section=destination_section,
source_decision=destination_section,
destination_decision=destination_section,
destination_project_value=destination_project,
start_date=DateTime(),
stop_date=DateTime(),
portal_type=movement_portal_type)
delivery_line = delivery.newContent(
portal_type=line_portal_type,
title=compute_node.getReference(),
quantity_unit=compute_node.getQuantityUnit(),
resource_value=resource_value)
delivery_line.edit(
price=0.0,
quantity=1.0,
aggregate_value=compute_node)
delivery.confirm()
delivery.stop()
delivery.deliver()
delivery.reindexObject(activate_kw=dict(tag=tag))
delivery_line.reindexObject(activate_kw=dict(tag=tag))
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<ZopeData> <ZopeData>
<record id="1" aka="AAAAAAAAAAE="> <record id="1" aka="AAAAAAAAAAE=">
<pickle> <pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/> <global name="Workflow Script" module="erp5.portal_type"/>
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
...@@ -50,41 +50,35 @@ ...@@ -50,41 +50,35 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>**kw</string> </value> <value> <string>state_change</string> </value>
</item> </item>
<item> <item>
<key> <string>_proxy_roles</string> </key> <key> <string>_proxy_roles</string> </key>
<value> <value>
<tuple> <tuple>
<string>Manager</string>
<string>Owner</string> <string>Owner</string>
</tuple> </tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>guard</string> </key> <key> <string>description</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> <none/>
</value> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>ComputerNetwork_init</string> </value> <value> <string>script_ComputeNode_requestTransfer</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Script</string> </value>
</item> </item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Guard" module="Products.DCWorkflow.Guard"/>
</pickle>
<pickle>
<dictionary>
<item> <item>
<key> <string>roles</string> </key> <key> <string>title</string> </key>
<value> <value>
<tuple> <none/>
<string>Owner</string>
</tuple>
</value> </value>
</item> </item>
</dictionary> </dictionary>
......
...@@ -21,10 +21,17 @@ ...@@ -21,10 +21,17 @@
<string>destination/portal_workflow/compute_node_slap_interface_workflow/transition_report_compute_node_bang</string> <string>destination/portal_workflow/compute_node_slap_interface_workflow/transition_report_compute_node_bang</string>
<string>destination/portal_workflow/compute_node_slap_interface_workflow/transition_request_compute_node_registration</string> <string>destination/portal_workflow/compute_node_slap_interface_workflow/transition_request_compute_node_registration</string>
<string>destination/portal_workflow/compute_node_slap_interface_workflow/transition_request_software_release</string> <string>destination/portal_workflow/compute_node_slap_interface_workflow/transition_request_software_release</string>
<string>destination/portal_workflow/compute_node_slap_interface_workflow/transition_request_transfer</string>
<string>destination/portal_workflow/compute_node_slap_interface_workflow/transition_revoke_certificate</string> <string>destination/portal_workflow/compute_node_slap_interface_workflow/transition_revoke_certificate</string>
</tuple> </tuple>
</value> </value>
</item> </item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
<value> <value>
......
...@@ -2,61 +2,60 @@ ...@@ -2,61 +2,60 @@
<ZopeData> <ZopeData>
<record id="1" aka="AAAAAAAAAAE="> <record id="1" aka="AAAAAAAAAAE=">
<pickle> <pickle>
<global name="Interaction Workflow Interaction" module="erp5.portal_type"/> <global name="Workflow Transition" module="erp5.portal_type"/>
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item> <item>
<key> <string>categories</string> </key> <key> <string>action</string> </key>
<value> <value>
<tuple> <none/>
<string>before_commit_script/portal_workflow/slapos_erp5_interaction_workflow/script_Organisation_validateAndAssign</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>description</string> </key> <key> <string>action_name</string> </key>
<value> <value>
<none/> <none/>
</value> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>categories</string> </key>
<value> <string>interaction_Site_validate</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Interaction Workflow Interaction</string> </value>
</item>
<item>
<key> <string>portal_type_filter</string> </key>
<value> <value>
<tuple> <tuple>
<string>Organisation</string> <string>action_type/workflow</string>
<string>after_script/portal_workflow/compute_node_slap_interface_workflow/script_ComputeNode_requestTransfer</string>
</tuple> </tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>portal_type_group_filter</string> </key> <key> <string>description</string> </key>
<value> <value>
<tuple/> <none/>
</value> </value>
</item> </item>
<item> <item>
<key> <string>temporary_document_disallowed</string> </key> <key> <string>guard_permission</string> </key>
<value> <int>0</int> </value> <value>
<tuple/>
</value>
</item> </item>
<item> <item>
<key> <string>trigger_method_id</string> </key> <key> <string>icon</string> </key>
<value> <value>
<tuple> <none/>
<string>_setRole*</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>trigger_once_per_transaction</string> </key> <key> <string>id</string> </key>
<value> <int>1</int> </value> <value> <string>transition_request_transfer</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Transition</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Request Transfer</string> </value>
</item> </item>
<item> <item>
<key> <string>trigger_type</string> </key> <key> <string>trigger_type</string> </key>
......
requester_instance = state_change['object']
portal = requester_instance.getPortalObject()
from zExceptions import Unauthorized
from DateTime import DateTime
assert requester_instance.getPortalType() == 'Instance Tree'
# Get required arguments
kwargs = state_change.kwargs
# Required args
# Raise TypeError if all parameters are not provided
try:
# destination=None, destination_project=None
destination = kwargs['destination']
destination_project = kwargs["destination_project"]
except KeyError:
raise TypeError("InstanceTree_requestTransfer takes exactly 2 arguments")
user = portal.portal_membership.getAuthenticatedMember().getUserValue()
if user is None or user.getRelativeUrl() != requester_instance.getDestinationSection():
raise Unauthorized("Only the Instance Tree owner can transfer it from one location to another.")
tag = "%s_%s_%s_inProgress" % (requester_instance.getUid(), destination, destination_project)
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)
movement_portal_type = "Internal Packing List"
source = requester_instance.Item_getCurrentSiteValue()
source_project = requester_instance.Item_getCurrentProjectValue()
source_section = requester_instance.Item_getCurrentOwnerValue()
resource_value = requester_instance.Item_getResourceValue()
if destination_project is None and source_project is not None:
destination_project = source_project.getRelativeUrl()
destination_section = requester_instance.getDestinationSection()
if source_section is None:
source_section = requester_instance.getDestinationSectionValue()
if destination is None and source is not None:
destination = source.getRelativeUrl()
resource_value = requester_instance.product_module.compute_node
module = portal.getDefaultModule(portal_type=movement_portal_type)
line_portal_type = '%s Line' % movement_portal_type
delivery = module.newContent(title="Transfer %s to %s" % (requester_instance.getTitle(), destination_project),
source_value=source,
source_section_value=source_section,
source_project_value=source_project,
destination=destination,
destination_section=destination_section,
source_decision=destination_section,
destination_decision=destination_section,
destination_project_value=destination_project,
start_date=DateTime(),
stop_date=DateTime(),
portal_type=movement_portal_type)
delivery_line = delivery.newContent(
portal_type=line_portal_type,
title=requester_instance.getReference(),
quantity_unit=requester_instance.getQuantityUnit(),
resource_value=resource_value)
delivery_line.edit(
price=0.0,
quantity=1.0,
aggregate_value=requester_instance)
delivery.confirm()
delivery.stop()
delivery.deliver()
delivery.reindexObject(activate_kw=dict(tag=tag))
delivery_line.reindexObject(activate_kw=dict(tag=tag))
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>script_RequesterInstance_requestTransfer</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Script</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<none/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -19,11 +19,18 @@ ...@@ -19,11 +19,18 @@
<string>destination/portal_workflow/instance_slap_interface_workflow/transition_bang</string> <string>destination/portal_workflow/instance_slap_interface_workflow/transition_bang</string>
<string>destination/portal_workflow/instance_slap_interface_workflow/transition_report_compute_partition_error</string> <string>destination/portal_workflow/instance_slap_interface_workflow/transition_report_compute_partition_error</string>
<string>destination/portal_workflow/instance_slap_interface_workflow/transition_request_instance</string> <string>destination/portal_workflow/instance_slap_interface_workflow/transition_request_instance</string>
<string>destination/portal_workflow/instance_slap_interface_workflow/transition_request_transfer</string>
<string>destination/portal_workflow/instance_slap_interface_workflow/transition_unallocate_partition</string> <string>destination/portal_workflow/instance_slap_interface_workflow/transition_unallocate_partition</string>
<string>destination/portal_workflow/instance_slap_interface_workflow/transition_update_connection</string> <string>destination/portal_workflow/instance_slap_interface_workflow/transition_update_connection</string>
</tuple> </tuple>
</value> </value>
</item> </item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
<value> <value>
......
...@@ -19,9 +19,16 @@ ...@@ -19,9 +19,16 @@
<string>destination/portal_workflow/instance_slap_interface_workflow/transition_bang</string> <string>destination/portal_workflow/instance_slap_interface_workflow/transition_bang</string>
<string>destination/portal_workflow/instance_slap_interface_workflow/transition_request_start</string> <string>destination/portal_workflow/instance_slap_interface_workflow/transition_request_start</string>
<string>destination/portal_workflow/instance_slap_interface_workflow/transition_request_stop</string> <string>destination/portal_workflow/instance_slap_interface_workflow/transition_request_stop</string>
<string>destination/portal_workflow/instance_slap_interface_workflow/transition_request_transfer</string>
</tuple> </tuple>
</value> </value>
</item> </item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
<value> <value>
......
...@@ -24,10 +24,17 @@ ...@@ -24,10 +24,17 @@
<string>destination/portal_workflow/instance_slap_interface_workflow/transition_request_instance</string> <string>destination/portal_workflow/instance_slap_interface_workflow/transition_request_instance</string>
<string>destination/portal_workflow/instance_slap_interface_workflow/transition_request_start</string> <string>destination/portal_workflow/instance_slap_interface_workflow/transition_request_start</string>
<string>destination/portal_workflow/instance_slap_interface_workflow/transition_request_stop</string> <string>destination/portal_workflow/instance_slap_interface_workflow/transition_request_stop</string>
<string>destination/portal_workflow/instance_slap_interface_workflow/transition_request_transfer</string>
<string>destination/portal_workflow/instance_slap_interface_workflow/transition_update_connection</string> <string>destination/portal_workflow/instance_slap_interface_workflow/transition_update_connection</string>
</tuple> </tuple>
</value> </value>
</item> </item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
<value> <value>
......
...@@ -24,10 +24,17 @@ ...@@ -24,10 +24,17 @@
<string>destination/portal_workflow/instance_slap_interface_workflow/transition_request_instance</string> <string>destination/portal_workflow/instance_slap_interface_workflow/transition_request_instance</string>
<string>destination/portal_workflow/instance_slap_interface_workflow/transition_request_start</string> <string>destination/portal_workflow/instance_slap_interface_workflow/transition_request_start</string>
<string>destination/portal_workflow/instance_slap_interface_workflow/transition_request_stop</string> <string>destination/portal_workflow/instance_slap_interface_workflow/transition_request_stop</string>
<string>destination/portal_workflow/instance_slap_interface_workflow/transition_request_transfer</string>
<string>destination/portal_workflow/instance_slap_interface_workflow/transition_update_connection</string> <string>destination/portal_workflow/instance_slap_interface_workflow/transition_update_connection</string>
</tuple> </tuple>
</value> </value>
</item> </item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
<value> <value>
......
...@@ -2,61 +2,61 @@ ...@@ -2,61 +2,61 @@
<ZopeData> <ZopeData>
<record id="1" aka="AAAAAAAAAAE="> <record id="1" aka="AAAAAAAAAAE=">
<pickle> <pickle>
<global name="Interaction Workflow Interaction" module="erp5.portal_type"/> <global name="Workflow Transition" module="erp5.portal_type"/>
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item> <item>
<key> <string>categories</string> </key> <key> <string>action</string> </key>
<value> <value>
<tuple> <none/>
<string>before_commit_script/portal_workflow/slapos_erp5_interaction_workflow/script_Project_validateAndAssign</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>description</string> </key> <key> <string>action_name</string> </key>
<value> <value>
<none/> <none/>
</value> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>categories</string> </key>
<value> <string>interaction_Project_setDestinationDecision</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Interaction Workflow Interaction</string> </value>
</item>
<item>
<key> <string>portal_type_filter</string> </key>
<value> <value>
<tuple> <tuple>
<string>Project</string> <string>action_type/workflow</string>
<string>before_script/portal_workflow/instance_slap_interface_workflow/script_Instance_checkConsistency</string>
<string>after_script/portal_workflow/instance_slap_interface_workflow/script_RequesterInstance_requestTransfer</string>
</tuple> </tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>portal_type_group_filter</string> </key> <key> <string>description</string> </key>
<value> <value>
<tuple/> <none/>
</value> </value>
</item> </item>
<item> <item>
<key> <string>temporary_document_disallowed</string> </key> <key> <string>guard_permission</string> </key>
<value> <int>0</int> </value> <value>
<tuple/>
</value>
</item> </item>
<item> <item>
<key> <string>trigger_method_id</string> </key> <key> <string>icon</string> </key>
<value> <value>
<tuple> <none/>
<string>_setDestinationDecision*</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>trigger_once_per_transaction</string> </key> <key> <string>id</string> </key>
<value> <int>0</int> </value> <value> <string>transition_request_transfer</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Transition</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Request Transfer</string> </value>
</item> </item>
<item> <item>
<key> <string>trigger_type</string> </key> <key> <string>trigger_type</string> </key>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>source/portal_workflow/network_slap_interface_workflow/state_draft</string>
</tuple>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>person_slap_interface_workflow</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>network_slap_interface_workflow</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>manager_bypass</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow</string> </value>
</item>
<item>
<key> <string>state_variable</string> </key>
<value> <string>slap_state</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Network Slap Interface Workflow</string> </value>
</item>
<item>
<key> <string>workflow_managed_permission</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Length" module="BTrees.Length"/>
</pickle>
<pickle> <int>0</int> </pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
</ZopeData>
computer_network = state_change["object"]
from DateTime import DateTime
portal = computer_network.getPortalObject()
if computer_network.getReference() in [None, ""]:
reference = "NET-%s" % portal.portal_ids.generateNewId(
id_group='slap_network_reference',
id_generator='uid')
computer_network.setReference(reference)
if computer_network.getValidationState() != "draft":
return
computer_network.validate()
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>script_ComputerNetwork_approveRegistration</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Script</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>ComputerNetwork_approveRegistration</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>script_ComputerNetwork_checkConsistency</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Script</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<none/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
computer_network = state_change["object"]
from DateTime import DateTime
from zExceptions import Unauthorized
portal = computer_network.getPortalObject()
# Get required arguments
kwargs = state_change.kwargs
user = portal.portal_membership.getAuthenticatedMember().getUserValue()
if user is None or user.getRelativeUrl() != computer_network.getSourceAdministration():
raise Unauthorized("Only the Computer Network owner can transfer it from one location to another.")
# Required args
# Raise TypeError if all parameters are not provided
try:
# destination_project=None, destination_section=None
destination_section = kwargs['destination_section']
destination_project = kwargs["destination_project"]
except KeyError:
raise TypeError("ComputerNetwork_requestTransfer takes exactly 2 arguments")
tag = "%s_%s_%s_inProgress" % (computer_network.getUid(), destination_section, destination_project)
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)
movement_portal_type = "Internal Packing List"
source_project = computer_network.Item_getCurrentProjectValue()
source_section = computer_network.Item_getCurrentOwnerValue()
source = computer_network.getSourceAdministration()
destination = computer_network.getSourceAdministration()
resource_value = portal.product_module.compute_node
if destination_project is None and source_project is not None:
destination_project = source_project.getRelativeUrl()
if source_section is None:
source_section = computer_network.getSourceAdministrationValue()
if destination_section is None:
destination_section = source_section.getRelativeUrl()
module = portal.getDefaultModule(portal_type=movement_portal_type)
line_portal_type = '%s Line' % movement_portal_type
delivery = module.newContent(title="Transfer %s to %s" % (computer_network.getTitle(), destination_project),
source=source,
source_section_value=source_section,
source_project_value=source_project,
destination=destination,
destination_section=destination_section,
source_decision=destination_section,
destination_decision=destination_section,
destination_project=destination_project,
start_date=DateTime(),
stop_date=DateTime(),
portal_type=movement_portal_type)
delivery_line = delivery.newContent(
portal_type=line_portal_type,
title=computer_network.getReference(),
quantity_unit=resource_value.getQuantityUnit(),
resource_value=resource_value)
delivery_line.edit(
price=0.0,
quantity=1.0,
aggregate=computer_network.getRelativeUrl())
delivery.confirm()
delivery.stop()
delivery.deliver()
delivery.reindexObject(activate_kw=dict(tag=tag))
delivery_line.reindexObject(activate_kw=dict(tag=tag))
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>script_ComputerNetwork_requestTransfer</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Script</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>ComputerNetwork_requestTransfer</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow State" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>acquire_permission</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>destination/portal_workflow/network_slap_interface_workflow/transition_approve_registration</string>
<string>destination/portal_workflow/network_slap_interface_workflow/transition_request_transfer</string>
</tuple>
</value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>state_draft</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow State</string> </value>
</item>
<item>
<key> <string>state_permission_role_list_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>state_type</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Draft</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -2,61 +2,61 @@ ...@@ -2,61 +2,61 @@
<ZopeData> <ZopeData>
<record id="1" aka="AAAAAAAAAAE="> <record id="1" aka="AAAAAAAAAAE=">
<pickle> <pickle>
<global name="Interaction Workflow Interaction" module="erp5.portal_type"/> <global name="Workflow Transition" module="erp5.portal_type"/>
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item> <item>
<key> <string>categories</string> </key> <key> <string>action</string> </key>
<value> <value>
<tuple> <none/>
<string>before_commit_script/portal_workflow/slapos_erp5_interaction_workflow/script_ComputerNetwork_validate</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>description</string> </key> <key> <string>action_name</string> </key>
<value> <value>
<none/> <none/>
</value> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>categories</string> </key>
<value> <string>interaction_ComputerNetwork_setRefence</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Interaction Workflow Interaction</string> </value>
</item>
<item>
<key> <string>portal_type_filter</string> </key>
<value> <value>
<tuple> <tuple>
<string>Computer Network</string> <string>action_type/workflow</string>
<string>before_script/portal_workflow/network_slap_interface_workflow/script_ComputerNetwork_checkConsistency</string>
<string>after_script/portal_workflow/network_slap_interface_workflow/script_ComputerNetwork_approveRegistration</string>
</tuple> </tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>portal_type_group_filter</string> </key> <key> <string>description</string> </key>
<value> <value>
<tuple/> <none/>
</value> </value>
</item> </item>
<item> <item>
<key> <string>temporary_document_disallowed</string> </key> <key> <string>guard_permission</string> </key>
<value> <int>0</int> </value> <value>
<tuple/>
</value>
</item> </item>
<item> <item>
<key> <string>trigger_method_id</string> </key> <key> <string>icon</string> </key>
<value> <value>
<tuple> <none/>
<string>_setReference*</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>trigger_once_per_transaction</string> </key> <key> <string>id</string> </key>
<value> <int>0</int> </value> <value> <string>transition_approve_registration</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Transition</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Approve Registration</string> </value>
</item> </item>
<item> <item>
<key> <string>trigger_type</string> </key> <key> <string>trigger_type</string> </key>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Transition" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>action_name</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/workflow</string>
<string>before_script/portal_workflow/network_slap_interface_workflow/script_ComputerNetwork_checkConsistency</string>
<string>after_script/portal_workflow/network_slap_interface_workflow/script_ComputerNetwork_requestTransfer</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>guard_permission</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>transition_request_transfer</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Transition</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Request Transfer</string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Variable" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>automatic_update</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>The last transition</string> </value>
</item>
<item>
<key> <string>for_catalog</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>variable_action</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Variable</string> </value>
</item>
<item>
<key> <string>status_included</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>variable_default_expression</string> </key>
<value> <string>transition/getReference|nothing</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Variable" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>automatic_update</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>The name of the user who performed the last transition</string> </value>
</item>
<item>
<key> <string>for_catalog</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>variable_actor</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Variable</string> </value>
</item>
<item>
<key> <string>status_included</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>variable_default_expression</string> </key>
<value> <string>user/getUserName</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Variable" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>automatic_update</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Comments about the last transition</string> </value>
</item>
<item>
<key> <string>for_catalog</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>variable_comment</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Variable</string> </value>
</item>
<item>
<key> <string>status_included</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>variable_default_expression</string> </key>
<value> <string>python:state_change.kwargs.get(\'comment\', \'\')</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Variable" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>automatic_update</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Error message if validation failed</string> </value>
</item>
<item>
<key> <string>for_catalog</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>variable_error_message</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Variable</string> </value>
</item>
<item>
<key> <string>status_included</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<none/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Variable" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>automatic_update</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Provides access to workflow history</string> </value>
</item>
<item>
<key> <string>for_catalog</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>variable_history</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Variable</string> </value>
</item>
<item>
<key> <string>status_included</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>variable_default_expression</string> </key>
<value> <string>state_change/getHistory</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Variable" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>automatic_update</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>portal type (use as filter for worklists)</string> </value>
</item>
<item>
<key> <string>for_catalog</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>variable_portal_type</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Variable</string> </value>
</item>
<item>
<key> <string>status_included</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<none/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Variable" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>automatic_update</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Time of the last transition</string> </value>
</item>
<item>
<key> <string>for_catalog</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>variable_time</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Variable</string> </value>
</item>
<item>
<key> <string>status_included</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>variable_default_expression</string> </key>
<value> <string>state_change/getDateTime</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>source/portal_workflow/organisation_slap_interface_workflow/state_draft</string>
</tuple>
</value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>person_slap_interface_workflow</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>organisation_slap_interface_workflow</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>manager_bypass</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow</string> </value>
</item>
<item>
<key> <string>state_variable</string> </key>
<value> <string>slap_state</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Organisation Slap Interface Workflow</string> </value>
</item>
<item>
<key> <string>workflow_managed_permission</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Length" module="BTrees.Length"/>
</pickle>
<pickle> <int>0</int> </pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
</ZopeData>
organisation = state_change['object']
portal = organisation.getPortalObject()
person = portal.portal_membership.getAuthenticatedMember().getUserValue()
# Get required arguments
kwargs = state_change.kwargs
# Required args
# Raise TypeError if all parameters are not provided
try:
token_id = kwargs['invitation_token']
except KeyError:
raise TypeError("Organisation_acceptInvitation takes exactly 1 argument")
try:
invitation_token = portal.invitation_token_module[token_id]
except KeyError:
raise ValueError("The Invitation Token can't be found, please review the URL.")
if person is None:
message_str = "Please login before access the invitation link."
raise ValueError(message_str)
if invitation_token.getPortalType() != "Invitation Token":
message_str = "The Invitation Token can't be found, please review the URL."
raise ValueError(message_str)
if invitation_token.getValidationState() != "validated":
message_str = "The Invitation Token was already used and it cannot be reused, please ask a new one."
raise ValueError(message_str)
if invitation_token.getSourceValue() == person:
message_str = "Invitation Token cannot be used by the same user that generated the token!"
raise ValueError(message_str)
for assignment in person.objectValues(portal_type="Assignment"):
if assignment.getSubordination() == organisation.getRelativeUrl() and \
assignment.getValidationState() == "open":
invitation_token.invalidate(comment="User already has assignment to the Person")
break
if invitation_token.getValidationState() == "validated":
person.newContent(
title="Assigment for Organisation (%s) %s" % (organisation.getRole(), organisation.getTitle()),
portal_type="Assignment",
subordination_value=organisation,
destination_value=organisation).open()
invitation_token.invalidate()
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>script_Organisation_acceptInvitation</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Script</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Organisation_acceptInvitation</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
organisation = state_change["object"] organisation = state_change["object"]
portal = context.getPortalObject() portal = context.getPortalObject()
if organisation.getValidationState() != "draft":
return
role = organisation.getRole() role = organisation.getRole()
if role not in ["host", "client"]:
return
if role == "host": if role == "host":
reference_prefix = "SITE" reference_prefix = "SITE"
else: else:
...@@ -20,11 +14,22 @@ if organisation.getReference() in [None, ""]: ...@@ -20,11 +14,22 @@ if organisation.getReference() in [None, ""]:
organisation.setReference(reference) organisation.setReference(reference)
if organisation.getValidationState() != "draft":
return
organisation.validate() organisation.validate()
user_id = organisation.Base_getOwnerId() # Get the user id of the context owner.
person = context.getPortalObject().portal_catalog.getResultValue(user_id=user_id) local_role_list = organisation.get_local_roles()
for group, role_list in local_role_list:
if 'Owner' in role_list:
user_id = group
break
person = portal.portal_catalog.getResultValue(user_id=user_id)
if person is None: if person is None:
# Value was created by super user, so there isn't a point on continue
return return
for assignment in person.objectValues(portal_type="Assignment"): for assignment in person.objectValues(portal_type="Assignment"):
...@@ -34,7 +39,7 @@ for assignment in person.objectValues(portal_type="Assignment"): ...@@ -34,7 +39,7 @@ for assignment in person.objectValues(portal_type="Assignment"):
return return
person.newContent( person.newContent(
title="Assigment for Site %s" % organisation.getTitle(), title="Assigment for Organisation (%s) %s" % (organisation.getRole(), organisation.getTitle()),
portal_type="Assignment", portal_type="Assignment",
subordination_value=organisation, subordination_value=organisation,
destination_value=organisation).open() destination_value=organisation).open()
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>script_Organisation_approveRegistration</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Script</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Organisation_approveRegistration</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>script_Organisation_checkConsistency</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Script</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<none/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from zExceptions import Unauthorized
organisation = state_change['object']
portal = organisation.getPortalObject()
person = portal.portal_membership.getAuthenticatedMember().getUserValue()
if person is None:
raise Unauthorized
for assignment in person.objectValues(portal_type="Assignment"):
if assignment.getDestination() == organisation.getRelativeUrl():
assignment.close()
break
...@@ -60,9 +60,15 @@ ...@@ -60,9 +60,15 @@
</tuple> </tuple>
</value> </value>
</item> </item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>script_Organisation_validateAndAssign</string> </value> <value> <string>script_Organisation_leaveOrganisation</string> </value>
</item> </item>
<item> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow State" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>acquire_permission</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>destination/portal_workflow/organisation_slap_interface_workflow/transition_accept_invitation</string>
<string>destination/portal_workflow/organisation_slap_interface_workflow/transition_approve_registration</string>
<string>destination/portal_workflow/organisation_slap_interface_workflow/transition_leave_organisation</string>
</tuple>
</value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>state_draft</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow State</string> </value>
</item>
<item>
<key> <string>state_permission_role_list_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>state_type</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Draft</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Transition" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>action_name</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/workflow</string>
<string>after_script/portal_workflow/organisation_slap_interface_workflow/script_Organisation_acceptInvitation</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>guard_permission</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>transition_accept_invitation</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Transition</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Accept Invitation</string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Transition" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>action_name</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/workflow</string>
<string>before_script/portal_workflow/organisation_slap_interface_workflow/script_Organisation_checkConsistency</string>
<string>after_script/portal_workflow/organisation_slap_interface_workflow/script_Organisation_approveRegistration</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>guard_permission</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>transition_approve_registration</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Transition</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Approve Registration</string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Transition" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>action_name</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/workflow</string>
<string>before_script/portal_workflow/organisation_slap_interface_workflow/script_Organisation_checkConsistency</string>
<string>after_script/portal_workflow/organisation_slap_interface_workflow/script_Organisation_leaveOrganisation</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>guard_permission</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>transition_leave_organisation</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Transition</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Leave Organisation</string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Variable" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>automatic_update</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>The last transition</string> </value>
</item>
<item>
<key> <string>for_catalog</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>variable_action</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Variable</string> </value>
</item>
<item>
<key> <string>status_included</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>variable_default_expression</string> </key>
<value> <string>transition/getReference|nothing</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Variable" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>automatic_update</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>The name of the user who performed the last transition</string> </value>
</item>
<item>
<key> <string>for_catalog</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>variable_actor</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Variable</string> </value>
</item>
<item>
<key> <string>status_included</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>variable_default_expression</string> </key>
<value> <string>user/getUserName</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Variable" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>automatic_update</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Comments about the last transition</string> </value>
</item>
<item>
<key> <string>for_catalog</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>variable_comment</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Variable</string> </value>
</item>
<item>
<key> <string>status_included</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>variable_default_expression</string> </key>
<value> <string>python:state_change.kwargs.get(\'comment\', \'\')</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Variable" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>automatic_update</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Error message if validation failed</string> </value>
</item>
<item>
<key> <string>for_catalog</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>variable_error_message</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Variable</string> </value>
</item>
<item>
<key> <string>status_included</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<none/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Variable" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>automatic_update</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Provides access to workflow history</string> </value>
</item>
<item>
<key> <string>for_catalog</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>variable_history</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Variable</string> </value>
</item>
<item>
<key> <string>status_included</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>variable_default_expression</string> </key>
<value> <string>state_change/getHistory</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Variable" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>automatic_update</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>portal type (use as filter for worklists)</string> </value>
</item>
<item>
<key> <string>for_catalog</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>variable_portal_type</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Variable</string> </value>
</item>
<item>
<key> <string>status_included</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<none/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Variable" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>automatic_update</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Time of the last transition</string> </value>
</item>
<item>
<key> <string>for_catalog</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>variable_time</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Variable</string> </value>
</item>
<item>
<key> <string>status_included</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>variable_default_expression</string> </key>
<value> <string>state_change/getDateTime</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -32,6 +32,12 @@ ...@@ -32,6 +32,12 @@
</tuple> </tuple>
</value> </value>
</item> </item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>person_slap_interface_workflow</string> </value> <value> <string>person_slap_interface_workflow</string> </value>
......
person = state_change['object']
portal = person.getPortalObject()
# Get required arguments
kwargs = state_change.kwargs
# Required args
# Raise TypeError if all parameters are not provided
try:
computer_network_title = kwargs['network_title']
except KeyError:
raise TypeError, "Person_requestNetwork takes exactly 1 argument"
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)
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",
limit=2)
if len(computer_network_list) == 2:
raise NotImplementedError
elif len(computer_network_list) == 1:
context.REQUEST.set("computer_network_relative_url", computer_network_list[0].getRelativeUrl())
context.REQUEST.set("computer_network_reference", computer_network_list[0].getReference())
else:
module = portal.getDefaultModule(portal_type=computer_network_portal_type)
computer_network = module.newContent(
portal_type=computer_network_portal_type,
title=computer_network_title,
source_administration=person.getRelativeUrl(),
activate_kw={'tag': tag}
)
context.REQUEST.set("computer_network_relative_url", computer_network.getRelativeUrl())
context.REQUEST.set("computer_network_reference", computer_network.getReference())
computer_network.approveRegistration()
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>script_Person_requestNetwork</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Script</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Person_requestNetwork</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
person = state_change['object']
portal = person.getPortalObject()
# Get required arguments
kwargs = state_change.kwargs
# Required args
# Raise TypeError if all parameters are not provided
try:
organisation_title = kwargs['organisation_title']
except KeyError:
raise TypeError, "Person_requestOrganisation takes exactly 1 argument"
role_id = context.REQUEST.get("role_id", "client")
tag = "%s_%s_%s_OrganisationInProgress" % (person.getUid(),
role_id,
organisation_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)
organisation_portal_type = "Organisation"
if role_id not in ["client", "host"]:
raise NotImplementedError
organisation_list = [ i for i in portal.portal_catalog.portal_catalog(
portal_type=organisation_portal_type,
title=organisation_title,
limit=2) if i.getRole() == role_id]
if len(organisation_list) == 2:
raise NotImplementedError
elif len(organisation_list) == 1:
context.REQUEST.set("organisation_relative_url", organisation_list[0].getRelativeUrl())
else:
module = portal.getDefaultModule(portal_type=organisation_portal_type)
organisation = module.newContent(
portal_type=organisation_portal_type,
title=organisation_title,
role=role_id,
activate_kw={'tag': tag}
)
context.REQUEST.set("organisation_relative_url", organisation.getRelativeUrl())
organisation.approveRegistration()
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>script_Person_requestOrganisation</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Script</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Person_requestOrganisation</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
person = state_change['object']
portal = person.getPortalObject()
# Get required arguments
kwargs = state_change.kwargs
# Required args
# Raise TypeError if all parameters are not provided
try:
project_title = kwargs['project_title']
except KeyError:
raise TypeError, "Person_requestProject takes exactly 1 argument"
tag = "%s_%s_ProjectInProgress" % (person.getUid(),
project_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)
project_portal_type = "Project"
project_list = portal.portal_catalog.portal_catalog(
portal_type=project_portal_type, title=project_title, limit=2)
if len(project_list) == 2:
raise NotImplementedError
elif len(project_list) == 1:
context.REQUEST.set("project_relative_url", project_list[0].getRelativeUrl())
context.REQUEST.set("project_reference", project_list[0].getReference())
else:
module = portal.getDefaultModule(portal_type=project_portal_type)
project = module.newContent(
portal_type=project_portal_type,
title=project_title,
destination_decision_value=person,
activate_kw={'tag': tag}
)
context.REQUEST.set("project_relative_url", project.getRelativeUrl())
context.REQUEST.set("project_reference", project.getReference())
project.approveRegistration()
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>script_Person_requestProject</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Script</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Person_requestProject</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
context.REQUEST.set("role_id", "host")
context.Person_requestOrganisation(state_change)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>script_Person_requestSite</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Script</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Person_requestSite</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
person = state_change['object']
portal = person.getPortalObject()
# Get required arguments
kwargs = state_change.kwargs
# Required args
# Raise TypeError if all parameters are not provided
try:
request_url = kwargs['request_url']
except KeyError:
raise TypeError, "Person_requestToken takes exactly 1 argument"
request_method = "POST"
access_token = portal.access_token_module.newContent(
portal_type="One Time Restricted Access Token",
agent_value=person,
url_string=request_url,
url_method=request_method
)
access_token_id = access_token.getId()
access_token.validate()
context.REQUEST.set("token", access_token_id)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>script_Person_requestToken</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Script</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Person_requestToken</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -16,11 +16,22 @@ ...@@ -16,11 +16,22 @@
<key> <string>categories</string> </key> <key> <string>categories</string> </key>
<value> <value>
<tuple> <tuple>
<string>destination/portal_workflow/person_slap_interface_workflow/transition_request_network</string>
<string>destination/portal_workflow/person_slap_interface_workflow/transition_request_compute_node</string> <string>destination/portal_workflow/person_slap_interface_workflow/transition_request_compute_node</string>
<string>destination/portal_workflow/person_slap_interface_workflow/transition_request_organisation</string>
<string>destination/portal_workflow/person_slap_interface_workflow/transition_request_project</string>
<string>destination/portal_workflow/person_slap_interface_workflow/transition_request_site</string>
<string>destination/portal_workflow/person_slap_interface_workflow/transition_request_software_instance</string> <string>destination/portal_workflow/person_slap_interface_workflow/transition_request_software_instance</string>
<string>destination/portal_workflow/person_slap_interface_workflow/transition_request_token</string>
</tuple> </tuple>
</value> </value>
</item> </item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
<value> <value>
......
...@@ -18,10 +18,19 @@ ...@@ -18,10 +18,19 @@
<tuple> <tuple>
<string>destination/portal_workflow/person_slap_interface_workflow/transition_draft</string> <string>destination/portal_workflow/person_slap_interface_workflow/transition_draft</string>
<string>destination/portal_workflow/person_slap_interface_workflow/transition_request_compute_node</string> <string>destination/portal_workflow/person_slap_interface_workflow/transition_request_compute_node</string>
<string>destination/portal_workflow/person_slap_interface_workflow/transition_request_organisation</string>
<string>destination/portal_workflow/person_slap_interface_workflow/transition_request_project</string>
<string>destination/portal_workflow/person_slap_interface_workflow/transition_request_software_instance</string> <string>destination/portal_workflow/person_slap_interface_workflow/transition_request_software_instance</string>
<string>destination/portal_workflow/person_slap_interface_workflow/transition_request_token</string>
</tuple> </tuple>
</value> </value>
</item> </item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
<value> <value>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Transition" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>action_name</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/workflow</string>
<string>before_script/portal_workflow/person_slap_interface_workflow/script_Person_checkConsistency</string>
<string>after_script/portal_workflow/person_slap_interface_workflow/script_Person_requestNetwork</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>guard_permission</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>transition_request_network</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Transition</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Request Network</string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Transition" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>action_name</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/workflow</string>
<string>before_script/portal_workflow/person_slap_interface_workflow/script_Person_checkConsistency</string>
<string>after_script/portal_workflow/person_slap_interface_workflow/script_Person_requestOrganisation</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>guard_permission</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>transition_request_organisation</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Transition</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Request Organisation</string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Transition" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>action_name</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/workflow</string>
<string>before_script/portal_workflow/person_slap_interface_workflow/script_Person_checkConsistency</string>
<string>after_script/portal_workflow/person_slap_interface_workflow/script_Person_requestProject</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>guard_permission</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>transition_request_project</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Transition</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Request Project</string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Transition" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>action_name</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/workflow</string>
<string>before_script/portal_workflow/person_slap_interface_workflow/script_Person_checkConsistency</string>
<string>after_script/portal_workflow/person_slap_interface_workflow/script_Person_requestSite</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>guard_permission</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>transition_request_site</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Transition</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Request Site</string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Transition" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>action_name</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/workflow</string>
<string>before_script/portal_workflow/person_slap_interface_workflow/script_Person_checkConsistency</string>
<string>after_script/portal_workflow/person_slap_interface_workflow/script_Person_requestToken</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>guard_permission</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>transition_request_token</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Transition</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Request Token</string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>source/portal_workflow/project_slap_interface_workflow/state_draft</string>
</tuple>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>person_slap_interface_workflow</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>project_slap_interface_workflow</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>manager_bypass</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow</string> </value>
</item>
<item>
<key> <string>state_variable</string> </key>
<value> <string>slap_state</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Project Slap Interface Workflow</string> </value>
</item>
<item>
<key> <string>workflow_managed_permission</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Length" module="BTrees.Length"/>
</pickle>
<pickle> <int>0</int> </pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
</ZopeData>
project = state_change['object']
portal = project.getPortalObject()
person = portal.portal_membership.getAuthenticatedMember().getUserValue()
# Get required arguments
kwargs = state_change.kwargs
# Required args
# Raise TypeError if all parameters are not provided
try:
token_id = kwargs['invitation_token']
except KeyError:
raise TypeError("Project_acceptInvitation takes exactly 1 argument")
try:
invitation_token = portal.invitation_token_module[token_id]
except KeyError:
raise ValueError("The Invitation Token can't be found, please review the URL.")
if person is None:
message_str = "Please login before access the invitation link."
raise ValueError(message_str)
if invitation_token.getPortalType() != "Invitation Token":
message_str = "The Invitation Token can't be found, please review the URL."
raise ValueError(message_str)
if invitation_token.getValidationState() != "validated":
message_str = "The Invitation Token was already used and it cannot be reused, please ask a new one."
raise ValueError(message_str)
if invitation_token.getSourceValue() == person:
message_str = "Invitation Token cannot be used by the same user that generated the token!"
raise ValueError(message_str)
for assignment in person.objectValues(portal_type="Assignment"):
if assignment.getDestinationProject() == project.getRelativeUrl() and \
assignment.getValidationState() == "open":
invitation_token.invalidate(comment="User already has assignment to the Person")
break
if invitation_token.getValidationState() == "validated":
person.newContent(
title="Assigment for Project %s" % project.getTitle(),
portal_type="Assignment",
destination_project_value=project).open()
invitation_token.invalidate()
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>script_Project_acceptInvitation</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Script</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Project_acceptInvitation</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -7,15 +7,15 @@ if project.getValidationState() != "draft": ...@@ -7,15 +7,15 @@ if project.getValidationState() != "draft":
return return
if project.getReference() in [None, ""]: if project.getReference() in [None, ""]:
reference = "PROJ-%s" % portal.portal_ids.generateNewId( raise ValueError("Reference is missing on the Project")
id_group='slap_project_reference',
id_generator='uid', default=1)
project.setReference(reference)
project.setStartDate(DateTime()) # Get the user id of the context owner.
project.validate() local_role_list = project.get_local_roles()
for group, role_list in local_role_list:
if 'Owner' in role_list:
user_id = group
break
user_id = project.Base_getOwnerId()
person = portal.portal_catalog.getResultValue(user_id=user_id) person = portal.portal_catalog.getResultValue(user_id=user_id)
if person is None: if person is None:
...@@ -31,4 +31,7 @@ for assignment in person.objectValues(portal_type="Assignment"): ...@@ -31,4 +31,7 @@ for assignment in person.objectValues(portal_type="Assignment"):
person.newContent( person.newContent(
title="Assigment for Project %s" % project.getTitle(), title="Assigment for Project %s" % project.getTitle(),
portal_type="Assignment", portal_type="Assignment",
destination_project_value=project).open() destination_project=project.getRelativeUrl()).open()
project.edit(start_date=DateTime())
project.validate()
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>script_Project_approveRegistration</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Script</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Project_approveRegistration</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -50,19 +50,17 @@ ...@@ -50,19 +50,17 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>state_object</string> </value> <value> <string>state_change</string> </value>
</item> </item>
<item> <item>
<key> <string>_proxy_roles</string> </key> <key> <string>description</string> </key>
<value> <value>
<tuple> <none/>
<string>Manager</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>script_ComputerNetwork_validate</string> </value> <value> <string>script_Project_checkConsistency</string> </value>
</item> </item>
<item> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
......
from zExceptions import Unauthorized
project = state_change['object']
portal = project.getPortalObject()
person = portal.portal_membership.getAuthenticatedMember().getUserValue()
if person is None:
raise Unauthorized
if project.getDestinationDecision() == person.getRelativeUrl():
project.setDestinationDecision(None)
for assignment in person.objectValues(portal_type="Assignment"):
if assignment.getDestinationProject() == project.getRelativeUrl() and \
assignment.getValidationState() != 'closed':
assignment.close()
break
...@@ -60,9 +60,15 @@ ...@@ -60,9 +60,15 @@
</tuple> </tuple>
</value> </value>
</item> </item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>script_Project_validateAndAssign</string> </value> <value> <string>script_Project_leaveProject</string> </value>
</item> </item>
<item> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow State" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>acquire_permission</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>destination/portal_workflow/project_slap_interface_workflow/transition_accept_invitation</string>
<string>destination/portal_workflow/project_slap_interface_workflow/transition_approve_registration</string>
<string>destination/portal_workflow/project_slap_interface_workflow/transition_leave_project</string>
</tuple>
</value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>state_draft</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow State</string> </value>
</item>
<item>
<key> <string>state_permission_role_list_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>state_type</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Draft</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Transition" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>action_name</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/workflow</string>
<string>after_script/portal_workflow/project_slap_interface_workflow/script_Project_acceptInvitation</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>guard_permission</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>transition_accept_invitation</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Transition</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Accept Invitation</string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Transition" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>action_name</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/workflow</string>
<string>before_script/portal_workflow/project_slap_interface_workflow/script_Project_checkConsistency</string>
<string>after_script/portal_workflow/project_slap_interface_workflow/script_Project_approveRegistration</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>guard_permission</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>transition_approve_registration</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Transition</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Approve Registration</string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Transition" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>action_name</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/workflow</string>
<string>before_script/portal_workflow/project_slap_interface_workflow/script_Project_checkConsistency</string>
<string>after_script/portal_workflow/project_slap_interface_workflow/script_Project_leaveProject</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>guard_permission</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>transition_leave_project</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Transition</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Leave Project</string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Variable" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>automatic_update</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>The last transition</string> </value>
</item>
<item>
<key> <string>for_catalog</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>variable_action</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Variable</string> </value>
</item>
<item>
<key> <string>status_included</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>variable_default_expression</string> </key>
<value> <string>transition/getReference|nothing</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Variable" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>automatic_update</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>The name of the user who performed the last transition</string> </value>
</item>
<item>
<key> <string>for_catalog</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>variable_actor</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Variable</string> </value>
</item>
<item>
<key> <string>status_included</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>variable_default_expression</string> </key>
<value> <string>user/getUserName</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Variable" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>automatic_update</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Comments about the last transition</string> </value>
</item>
<item>
<key> <string>for_catalog</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>variable_comment</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Variable</string> </value>
</item>
<item>
<key> <string>status_included</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>variable_default_expression</string> </key>
<value> <string>python:state_change.kwargs.get(\'comment\', \'\')</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Variable" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>automatic_update</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Error message if validation failed</string> </value>
</item>
<item>
<key> <string>for_catalog</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>variable_error_message</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Variable</string> </value>
</item>
<item>
<key> <string>status_included</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<none/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Variable" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>automatic_update</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Provides access to workflow history</string> </value>
</item>
<item>
<key> <string>for_catalog</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>variable_history</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Variable</string> </value>
</item>
<item>
<key> <string>status_included</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>variable_default_expression</string> </key>
<value> <string>state_change/getHistory</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Variable" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>automatic_update</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>portal type (use as filter for worklists)</string> </value>
</item>
<item>
<key> <string>for_catalog</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>variable_portal_type</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Variable</string> </value>
</item>
<item>
<key> <string>status_included</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<none/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Variable" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>automatic_update</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Time of the last transition</string> </value>
</item>
<item>
<key> <string>for_catalog</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>variable_time</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Variable</string> </value>
</item>
<item>
<key> <string>status_included</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>variable_default_expression</string> </key>
<value> <string>state_change/getDateTime</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
Compute Partition | compute_partition_slap_interface_workflow
Compute Node | compute_node_slap_interface_workflow Compute Node | compute_node_slap_interface_workflow
Compute Node | slapos_cloud_interaction_workflow Compute Node | slapos_cloud_interaction_workflow
Compute Partition | compute_partition_slap_interface_workflow
Computer Network | network_slap_interface_workflow
Hosting Subscription | edit_workflow Hosting Subscription | edit_workflow
Instance Tree | edit_workflow Instance Tree | edit_workflow
Instance Tree | instance_slap_interface_workflow Instance Tree | instance_slap_interface_workflow
Instance Tree | instance_tree_workflow Instance Tree | instance_tree_workflow
Organisation | organisation_slap_interface_workflow
Person | person_slap_interface_workflow Person | person_slap_interface_workflow
Project | project_slap_interface_workflow
Slave Instance | edit_workflow Slave Instance | edit_workflow
Slave Instance | instance_slap_interface_workflow Slave Instance | instance_slap_interface_workflow
Slave Instance | item_workflow Slave Instance | item_workflow
......
test.erp5.testSlapOSCloudAlarm test.erp5.testSlapOSCloudAlarm
test.erp5.testSlapOSCloudAllocationAlarm test.erp5.testSlapOSCloudAllocationAlarm
test.erp5.testSlapOSCloudWorkflow test.erp5.testSlapOSCloudComputePartitionSlapInterfaceWorkflow
test.erp5.testSlapOSCloudInteractionWorkflow
test.erp5.testSlapOSCloudPersonSlapInterfaceWorkflow
test.erp5.testSlapOSCloudNetworkSlapInterfaceWorkflow
test.erp5.testSlapOSCloudComputeNodeSlapInterfaceWorkflow
test.erp5.testSlapOSCloudInstanceSlapInterfaceWorkflow
test.erp5.testSlapOSCloudProjectSlapInterfaceWorkflow
test.erp5.testSlapOSCloudOrganisationSlapInterfaceWorkflow
test.erp5.testSlapOSCloudSecurityGroup test.erp5.testSlapOSCloudSecurityGroup
test.erp5.testSlapOSCloudConstraint test.erp5.testSlapOSCloudConstraint
test.erp5.testSlapOSCloudUpgrader test.erp5.testSlapOSCloudUpgrader
test.erp5.testSlapOSCloudShadow test.erp5.testSlapOSCloudShadow
test.erp5.SlapOSTestCaseMixin test.erp5.SlapOSTestCaseMixin
test.erp5.SlapOSTestCaseDefaultScenarioMixin test.erp5.SlapOSTestCaseDefaultScenarioMixin
\ No newline at end of file
test.erp5.testSlapOSCloudCreateMovementSkins
\ No newline at end of file
audit_validation_workflow audit_validation_workflow
compute_partition_slap_interface_workflow
compute_node_slap_interface_workflow compute_node_slap_interface_workflow
instance_tree_workflow compute_partition_slap_interface_workflow
installation_slap_interface_workflow installation_slap_interface_workflow
instance_slap_interface_workflow instance_slap_interface_workflow
instance_tree_workflow
network_slap_interface_workflow
organisation_slap_interface_workflow
person_slap_interface_workflow person_slap_interface_workflow
project_slap_interface_workflow
slapos_cloud_interaction_workflow slapos_cloud_interaction_workflow
\ No newline at end of file
<type_roles> <type_roles>
<role id='Assignee'>
<property id='title'>Compute Node Agent</property>
<property id='description'>Monovalued role</property>
<property id='base_category_script'>ERP5Type_getSecurityCategoryFromContent</property>
<multi_property id='categories'>local_role_group/computer</multi_property>
<multi_property id='base_category'>source_administration</multi_property>
</role>
<role id='Assignor'> <role id='Assignor'>
<property id='title'>Group company</property> <property id='title'>Group company</property>
<multi_property id='categories'>local_role_group/group</multi_property> <multi_property id='categories'>local_role_group/group</multi_property>
...@@ -20,10 +13,9 @@ ...@@ -20,10 +13,9 @@
</role> </role>
<role id='Assignee'> <role id='Assignee'>
<property id='title'>Person Owner</property> <property id='title'>Person Owner</property>
<property id='description'>XXX Review this</property> <property id='base_category_script'>ERP5Type_getSecurityCategoryFromContent</property>
<property id='base_category_script'>ERP5Type_acquireSecurityFromOwner</property>
<multi_property id='categories'>local_role_group/user</multi_property> <multi_property id='categories'>local_role_group/user</multi_property>
<multi_property id='base_category'>source</multi_property> <multi_property id='base_category'>source_administration</multi_property>
</role> </role>
<role id='Auditor'> <role id='Auditor'>
<property id='title'>Person Shadow</property> <property id='title'>Person Shadow</property>
......
...@@ -7,10 +7,9 @@ ...@@ -7,10 +7,9 @@
</role> </role>
<role id='Assignee'> <role id='Assignee'>
<property id='title'>Person Owner</property> <property id='title'>Person Owner</property>
<property id='description'>XXXX Review this later</property> <property id='base_category_script'>ERP5Type_getSecurityCategoryFromContent</property>
<property id='base_category_script'>ERP5Type_acquireSecurityFromOwner</property>
<multi_property id='categories'>local_role_group/user</multi_property> <multi_property id='categories'>local_role_group/user</multi_property>
<multi_property id='base_category'>source</multi_property> <multi_property id='base_category'>destination_decision</multi_property>
</role> </role>
<role id='Auditor'> <role id='Auditor'>
<property id='title'>Person Shadow</property> <property id='title'>Person Shadow</property>
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
</chain> </chain>
<chain> <chain>
<type>Computer Network</type> <type>Computer Network</type>
<workflow>local_permission_slapos_interaction_workflow, slapos_erp5_interaction_workflow</workflow> <workflow>local_permission_slapos_interaction_workflow</workflow>
</chain> </chain>
<chain> <chain>
<type>Contract Invitation Token</type> <type>Contract Invitation Token</type>
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
</chain> </chain>
<chain> <chain>
<type>Organisation</type> <type>Organisation</type>
<workflow>local_permission_slapos_interaction_workflow, slapos_erp5_interaction_workflow</workflow> <workflow>local_permission_slapos_interaction_workflow</workflow>
</chain> </chain>
<chain> <chain>
<type>Payment Transaction</type> <type>Payment Transaction</type>
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
</chain> </chain>
<chain> <chain>
<type>Project</type> <type>Project</type>
<workflow>local_permission_slapos_interaction_workflow, slapos_erp5_interaction_workflow</workflow> <workflow>local_permission_slapos_interaction_workflow</workflow>
</chain> </chain>
<chain> <chain>
<type>Purchase Packing List</type> <type>Purchase Packing List</type>
......
...@@ -315,7 +315,7 @@ class TestComputerNetwork(TestSlapOSGroupRoleSecurityMixin): ...@@ -315,7 +315,7 @@ class TestComputerNetwork(TestSlapOSGroupRoleSecurityMixin):
project.getReference()], False) project.getReference()], False)
self.assertRoles(network, 'G-COMPANY', ['Assignor']) self.assertRoles(network, 'G-COMPANY', ['Assignor'])
self.assertRoles(network, 'R-SHADOW-PERSON', ['Auditor']) self.assertRoles(network, 'R-SHADOW-PERSON', ['Auditor'])
self.assertRoles(network, self.user_id, ['Assignee', 'Owner']) self.assertRoles(network, self.user_id, ['Owner'])
self.assertRoles(network, person.getUserId(), ['Assignee']) self.assertRoles(network, person.getUserId(), ['Assignee'])
self.assertRoles(network, project.getReference(), ['Assignee']) self.assertRoles(network, project.getReference(), ['Assignee'])
...@@ -341,7 +341,7 @@ class TestComputerNetwork(TestSlapOSGroupRoleSecurityMixin): ...@@ -341,7 +341,7 @@ class TestComputerNetwork(TestSlapOSGroupRoleSecurityMixin):
organisation.getReference()], False) organisation.getReference()], False)
self.assertRoles(network, 'G-COMPANY', ['Assignor']) self.assertRoles(network, 'G-COMPANY', ['Assignor'])
self.assertRoles(network, 'R-SHADOW-PERSON', ['Auditor']) self.assertRoles(network, 'R-SHADOW-PERSON', ['Auditor'])
self.assertRoles(network, self.user_id, ['Assignee', 'Owner']) self.assertRoles(network, self.user_id, ['Owner'])
self.assertRoles(network, person.getUserId(), ['Assignee']) self.assertRoles(network, person.getUserId(), ['Assignee'])
self.assertRoles(network, organisation.getReference(), ['Assignee']) self.assertRoles(network, organisation.getReference(), ['Assignee'])
...@@ -353,21 +353,7 @@ class TestComputerNetwork(TestSlapOSGroupRoleSecurityMixin): ...@@ -353,21 +353,7 @@ class TestComputerNetwork(TestSlapOSGroupRoleSecurityMixin):
['G-COMPANY', 'R-SHADOW-PERSON', self.user_id], False) ['G-COMPANY', 'R-SHADOW-PERSON', self.user_id], False)
self.assertRoles(network, 'G-COMPANY', ['Assignor']) self.assertRoles(network, 'G-COMPANY', ['Assignor'])
self.assertRoles(network, 'R-SHADOW-PERSON', ['Auditor']) self.assertRoles(network, 'R-SHADOW-PERSON', ['Auditor'])
self.assertRoles(network, self.user_id, ['Assignee', 'Owner']) self.assertRoles(network, self.user_id, ['Owner'])
def test_ComputeNodeAgent(self):
reference = 'TESTPERSON-%s' % self.generateNewId()
person = self.portal.person_module.newContent(portal_type='Person',
reference=reference)
network = self.portal.computer_network_module.newContent(
portal_type='Computer Network',
source_administration=person.getRelativeUrl())
network.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(network,
['G-COMPANY', 'R-SHADOW-PERSON', self.user_id, person.getUserId()], False)
self.assertRoles(network, person.getUserId(), ['Assignee'])
self.assertRoles(network, self.user_id, ['Assignee', 'Owner'])
class TestComputerNetworkModule(TestSlapOSGroupRoleSecurityMixin): class TestComputerNetworkModule(TestSlapOSGroupRoleSecurityMixin):
def test(self): def test(self):
...@@ -526,6 +512,7 @@ class TestInstanceTree(TestSlapOSGroupRoleSecurityMixin): ...@@ -526,6 +512,7 @@ class TestInstanceTree(TestSlapOSGroupRoleSecurityMixin):
reference = 'TESTHS-%s' % self.generateNewId() reference = 'TESTHS-%s' % self.generateNewId()
subscription = self.portal.instance_tree_module.newContent( subscription = self.portal.instance_tree_module.newContent(
portal_type='Instance Tree', reference=reference, portal_type='Instance Tree', reference=reference,
title=reference,
destination_section=person.getRelativeUrl()) destination_section=person.getRelativeUrl())
project = self.portal.project_module.newContent( project = self.portal.project_module.newContent(
portal_type='Project') portal_type='Project')
...@@ -552,6 +539,7 @@ class TestInstanceTree(TestSlapOSGroupRoleSecurityMixin): ...@@ -552,6 +539,7 @@ class TestInstanceTree(TestSlapOSGroupRoleSecurityMixin):
reference = 'TESTHS-%s' % self.generateNewId() reference = 'TESTHS-%s' % self.generateNewId()
subscription = self.portal.instance_tree_module.newContent( subscription = self.portal.instance_tree_module.newContent(
portal_type='Instance Tree', reference=reference, portal_type='Instance Tree', reference=reference,
title=reference,
destination_section=person.getRelativeUrl()) destination_section=person.getRelativeUrl())
organisation = self.portal.organisation_module.newContent( organisation = self.portal.organisation_module.newContent(
portal_type='Organisation', portal_type='Organisation',
...@@ -681,6 +669,21 @@ class TestProjectModule(TestSlapOSGroupRoleSecurityMixin): ...@@ -681,6 +669,21 @@ class TestProjectModule(TestSlapOSGroupRoleSecurityMixin):
class TestProject(TestSlapOSGroupRoleSecurityMixin): class TestProject(TestSlapOSGroupRoleSecurityMixin):
def test_with_user(self):
person = self.makePerson(user=1)
project = self.portal.project_module.newContent(
portal_type='Project',
destination_decision_value=person)
project.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(project,
['G-COMPANY', self.user_id, person.getUserId(), project.getReference(), 'R-SHADOW-PERSON'], False)
self.assertRoles(project, 'G-COMPANY', ['Assignor'])
self.assertRoles(project, project.getReference(), ['Assignee'])
self.assertRoles(project, 'R-SHADOW-PERSON', ['Auditor'])
self.assertRoles(project, self.user_id, ['Owner'])
self.assertRoles(project, person.getUserId(), ['Assignee'])
def test(self): def test(self):
project = self.portal.project_module.newContent( project = self.portal.project_module.newContent(
portal_type='Project') portal_type='Project')
...@@ -690,7 +693,8 @@ class TestProject(TestSlapOSGroupRoleSecurityMixin): ...@@ -690,7 +693,8 @@ class TestProject(TestSlapOSGroupRoleSecurityMixin):
self.assertRoles(project, 'G-COMPANY', ['Assignor']) self.assertRoles(project, 'G-COMPANY', ['Assignor'])
self.assertRoles(project, project.getReference(), ['Assignee']) self.assertRoles(project, project.getReference(), ['Assignee'])
self.assertRoles(project, 'R-SHADOW-PERSON', ['Auditor']) self.assertRoles(project, 'R-SHADOW-PERSON', ['Auditor'])
self.assertRoles(project, self.user_id, ['Owner', 'Assignee']) self.assertRoles(project, self.user_id, ['Owner'])
class TestPDF(TestSlapOSGroupRoleSecurityMixin): class TestPDF(TestSlapOSGroupRoleSecurityMixin):
def test(self): def test(self):
...@@ -880,6 +884,7 @@ class TestSlaveInstance(TestSlapOSGroupRoleSecurityMixin): ...@@ -880,6 +884,7 @@ class TestSlaveInstance(TestSlapOSGroupRoleSecurityMixin):
subscription_reference = 'TESTHS-%s ' % self.generateNewId() subscription_reference = 'TESTHS-%s ' % self.generateNewId()
instance_tree = self.portal.instance_tree_module.newContent( instance_tree = self.portal.instance_tree_module.newContent(
portal_type='Instance Tree', portal_type='Instance Tree',
title="INSTTREETEST-%s" % self.generateNewId(),
reference=subscription_reference, reference=subscription_reference,
destination_section=customer.getRelativeUrl()) destination_section=customer.getRelativeUrl())
project = self.portal.project_module.newContent( project = self.portal.project_module.newContent(
...@@ -909,6 +914,7 @@ class TestSlaveInstance(TestSlapOSGroupRoleSecurityMixin): ...@@ -909,6 +914,7 @@ class TestSlaveInstance(TestSlapOSGroupRoleSecurityMixin):
subscription_reference = 'TESTHS-%s ' % self.generateNewId() subscription_reference = 'TESTHS-%s ' % self.generateNewId()
instance_tree = self.portal.instance_tree_module.newContent( instance_tree = self.portal.instance_tree_module.newContent(
portal_type='Instance Tree', portal_type='Instance Tree',
title="INSTTREETEST-%s" % self.generateNewId(),
reference=subscription_reference, reference=subscription_reference,
destination_section=customer.getRelativeUrl()) destination_section=customer.getRelativeUrl())
organisation = self.portal.organisation_module.newContent( organisation = self.portal.organisation_module.newContent(
...@@ -1116,6 +1122,7 @@ class TestSoftwareInstance(TestSlapOSGroupRoleSecurityMixin): ...@@ -1116,6 +1122,7 @@ class TestSoftwareInstance(TestSlapOSGroupRoleSecurityMixin):
subscription_reference = 'TESTHS-%s ' % self.generateNewId() subscription_reference = 'TESTHS-%s ' % self.generateNewId()
instance_tree = self.portal.instance_tree_module.newContent( instance_tree = self.portal.instance_tree_module.newContent(
portal_type='Instance Tree', portal_type='Instance Tree',
title="INSTTREETEST-%s" % self.generateNewId(),
reference=subscription_reference, reference=subscription_reference,
destination_section=customer.getRelativeUrl()) destination_section=customer.getRelativeUrl())
project = self.portal.project_module.newContent( project = self.portal.project_module.newContent(
...@@ -1145,6 +1152,7 @@ class TestSoftwareInstance(TestSlapOSGroupRoleSecurityMixin): ...@@ -1145,6 +1152,7 @@ class TestSoftwareInstance(TestSlapOSGroupRoleSecurityMixin):
subscription_reference = 'TESTHS-%s ' % self.generateNewId() subscription_reference = 'TESTHS-%s ' % self.generateNewId()
instance_tree = self.portal.instance_tree_module.newContent( instance_tree = self.portal.instance_tree_module.newContent(
portal_type='Instance Tree', portal_type='Instance Tree',
title="INSTTREETEST-%s" % self.generateNewId(),
reference=subscription_reference, reference=subscription_reference,
destination_section=customer.getRelativeUrl()) destination_section=customer.getRelativeUrl())
organisation = self.portal.organisation_module.newContent( organisation = self.portal.organisation_module.newContent(
...@@ -1942,6 +1950,8 @@ class TestMailMessage(TestSlapOSGroupRoleSecurityMixin): ...@@ -1942,6 +1950,8 @@ class TestMailMessage(TestSlapOSGroupRoleSecurityMixin):
person = self.makePerson(user=1) person = self.makePerson(user=1)
instance_tree = self.portal.instance_tree_module.newContent( instance_tree = self.portal.instance_tree_module.newContent(
portal_type='Instance Tree', portal_type='Instance Tree',
reference="INSTTREETEST-%s" % self.generateNewId(),
title="INSTTREETEST-%s" % self.generateNewId(),
destination_section=person.getRelativeUrl()) destination_section=person.getRelativeUrl())
project = self.portal.project_module.newContent( project = self.portal.project_module.newContent(
portal_type='Project') portal_type='Project')
...@@ -2017,6 +2027,8 @@ class TestMailMessage(TestSlapOSGroupRoleSecurityMixin): ...@@ -2017,6 +2027,8 @@ class TestMailMessage(TestSlapOSGroupRoleSecurityMixin):
person = self.makePerson(user=1) person = self.makePerson(user=1)
instance_tree = self.portal.instance_tree_module.newContent( instance_tree = self.portal.instance_tree_module.newContent(
portal_type='Instance Tree', portal_type='Instance Tree',
reference="INSTTREETEST-%s" % self.generateNewId(),
title="INSTTREETEST-%s" % self.generateNewId(),
destination_section=person.getRelativeUrl()) destination_section=person.getRelativeUrl())
organisation = self.portal.organisation_module.newContent( organisation = self.portal.organisation_module.newContent(
portal_type='Organisation', portal_type='Organisation',
...@@ -2289,6 +2301,8 @@ class TestSupportRequest(TestSlapOSGroupRoleSecurityMixin): ...@@ -2289,6 +2301,8 @@ class TestSupportRequest(TestSlapOSGroupRoleSecurityMixin):
person = self.makePerson(user=1) person = self.makePerson(user=1)
instance_tree = self.portal.instance_tree_module.newContent( instance_tree = self.portal.instance_tree_module.newContent(
portal_type='Instance Tree', portal_type='Instance Tree',
reference="INSTTREETEST-%s" % self.generateNewId(),
title="INSTTREETEST-%s" % self.generateNewId(),
destination_section=person.getRelativeUrl()) destination_section=person.getRelativeUrl())
project = self.portal.project_module.newContent( project = self.portal.project_module.newContent(
portal_type='Project') portal_type='Project')
...@@ -2348,6 +2362,8 @@ class TestSupportRequest(TestSlapOSGroupRoleSecurityMixin): ...@@ -2348,6 +2362,8 @@ class TestSupportRequest(TestSlapOSGroupRoleSecurityMixin):
person = self.makePerson(user=1) person = self.makePerson(user=1)
instance_tree = self.portal.instance_tree_module.newContent( instance_tree = self.portal.instance_tree_module.newContent(
portal_type='Instance Tree', portal_type='Instance Tree',
reference="INSTTREETEST-%s" % self.generateNewId(),
title="INSTTREETEST-%s" % self.generateNewId(),
destination_section=person.getRelativeUrl()) destination_section=person.getRelativeUrl())
organisation = self.portal.organisation_module.newContent( organisation = self.portal.organisation_module.newContent(
portal_type='Organisation', portal_type='Organisation',
...@@ -2788,6 +2804,8 @@ class TestUpgradeDecision(TestSlapOSGroupRoleSecurityMixin): ...@@ -2788,6 +2804,8 @@ class TestUpgradeDecision(TestSlapOSGroupRoleSecurityMixin):
person = self.makePerson(user=1) person = self.makePerson(user=1)
instance_tree = self.portal.instance_tree_module.newContent( instance_tree = self.portal.instance_tree_module.newContent(
portal_type='Instance Tree', portal_type='Instance Tree',
reference="INSTTREETEST-%s" % self.generateNewId(),
title="INSTTREETEST-%s" % self.generateNewId(),
destination_section=person.getRelativeUrl()) destination_section=person.getRelativeUrl())
project = self.portal.project_module.newContent( project = self.portal.project_module.newContent(
portal_type='Project') portal_type='Project')
...@@ -2852,6 +2870,8 @@ class TestUpgradeDecision(TestSlapOSGroupRoleSecurityMixin): ...@@ -2852,6 +2870,8 @@ class TestUpgradeDecision(TestSlapOSGroupRoleSecurityMixin):
person = self.makePerson(user=1) person = self.makePerson(user=1)
instance_tree = self.portal.instance_tree_module.newContent( instance_tree = self.portal.instance_tree_module.newContent(
portal_type='Instance Tree', portal_type='Instance Tree',
reference="INSTTREETEST-%s" % self.generateNewId(),
title="INSTTREETEST-%s" % self.generateNewId(),
destination_section=person.getRelativeUrl()) destination_section=person.getRelativeUrl())
organisation = self.portal.organisation_module.newContent( organisation = self.portal.organisation_module.newContent(
portal_type='Organisation', portal_type='Organisation',
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# #
############################################################################## ##############################################################################
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin, simulate from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope( class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
SlapOSTestCaseMixin): SlapOSTestCaseMixin):
...@@ -252,246 +252,3 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope( ...@@ -252,246 +252,3 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
self.assertEqual(compute_node.getSubjectList(), [person.getDefaultEmailCoordinateText()]) self.assertEqual(compute_node.getSubjectList(), [person.getDefaultEmailCoordinateText()])
self.assertEqual(compute_node.getDestinationSectionList(), self.assertEqual(compute_node.getDestinationSectionList(),
[person.getRelativeUrl()]) [person.getRelativeUrl()])
\ No newline at end of file
class TestSlapOSERP5InteractionWorkflowComputerNetworkSetReference(
SlapOSTestCaseMixin):
def test_ComputerNetwork_validate(self):
computer_network = self.portal.computer_network_module.newContent(
portal_type="Computer Network"
)
self.commit()
self.assertNotEqual(computer_network.getReference(), None)
self.assertEqual(computer_network.getValidationState(), "validated")
self.assertEqual(computer_network.getSourceAdministration(), None)
@simulate("ComputerNetwork_init", "*args, **kwargs", "return")
def test_ComputerNetwork_validate_manual(self):
computer_network = self.portal.computer_network_module.newContent(
portal_type="Computer Network"
)
self.commit()
self.assertEqual(computer_network.getReference(), None)
self.assertEqual(computer_network.getValidationState(), "draft")
self.assertEqual(computer_network.getSourceAdministration(), None)
computer_network.setReference(
"COMPNTEST-%s" % self.new_id
)
self.tic()
self.assertNotEqual(computer_network.getReference(), None)
self.assertEqual(computer_network.getValidationState(), "validated")
self.assertEqual(computer_network.getSourceAdministration(), None)
@simulate("ComputerNetwork_init", "*args, **kwargs", "return")
def test_ComputerNetwork_validate_manual_with_user(self):
person = self.makePerson(user=True)
self.login(person.getUserId())
computer_network = self.portal.computer_network_module.newContent(
portal_type="Computer Network"
)
self.commit()
self.assertEqual(computer_network.getReference(), None)
self.assertEqual(computer_network.getValidationState(), "draft")
self.assertEqual(computer_network.getSourceAdministration(), None)
computer_network.setReference(
"COMPNTEST-%s" % self.new_id
)
self.tic()
self.assertNotEqual(computer_network.getReference(), None)
self.assertEqual(computer_network.getValidationState(), "validated")
self.assertEqual(computer_network.getSourceAdministration(),
person.getRelativeUrl())
@simulate("ComputerNetwork_init", "*args, **kwargs", "return")
def test_ComputerNetwork_validate_manual_already_validated(self):
person = self.makePerson(user=True)
self.login(person.getUserId())
computer_network = self.portal.computer_network_module.newContent(
portal_type="Computer Network"
)
computer_network.validate()
self.commit()
self.assertEqual(computer_network.getReference(), None)
self.assertEqual(computer_network.getValidationState(), "validated")
self.assertEqual(computer_network.getSourceAdministration(), None)
computer_network.setReference(
"COMPNTEST-%s" % self.new_id
)
self.tic()
self.assertNotEqual(computer_network.getReference(), None)
self.assertEqual(computer_network.getValidationState(), "validated")
self.assertEqual(computer_network.getSourceAdministration(),
None)
class TestSlapOSERP5InteractionWorkflowProjectSetDestination(
SlapOSTestCaseMixin):
def test_Project_validateAndAssign(self):
person = self.makePerson()
self.tic()
project = self.portal.project_module.newContent(
portal_type="Project"
)
project.setDestinationDecisionValue(person)
self.commit()
self.assertEqual(project.getValidationState(), "validated")
self.assertNotEqual(project.getStartDate(), None)
self.assertNotEqual(project.getReference(), None)
self.assertTrue(project.getReference().startswith("PROJ-"),
"%s don't start with PROJ-" % project.getReference())
def test_Project_validateAndAssign_with_owner(self):
person = self.makePerson(user=1)
self.tic()
assignment_amount = len(person.objectValues(portal_type="Assignment"))
self.login(person.getUserId())
project = self.portal.project_module.newContent(
portal_type="Project"
)
project.setDestinationDecisionValue(person)
self.commit()
self.assertEqual(project.getValidationState(), "validated")
self.assertNotEqual(project.getStartDate(), None)
self.assertNotEqual(project.getReference(), None)
self.assertTrue(project.getReference().startswith("PROJ-"),
"%s don't start with PROJ-" % project.getReference())
self.assertEqual(assignment_amount + 1,
len(person.objectValues(portal_type="Assignment")))
self.assertNotEqual([],
[i for i in person.objectValues(portal_type="Assignment")
if (i.getDestinationProjectValue() == project and i.getValidationState() == "open")])
def test_Project_validateAndAssign_with_assignment(self):
person = self.makePerson(user=1)
self.tic()
assignment_amount = len(person.objectValues(portal_type="Assignment"))
self.login(person.getUserId())
project = self.portal.project_module.newContent(
portal_type="Project"
)
person.newContent(
title="Assigment for Project %s" % project.getTitle(),
portal_type="Assignment",
destination_project_value=project)
self.tic()
project.setDestinationDecisionValue(person)
self.commit()
self.assertEqual(project.getValidationState(), "validated")
self.assertNotEqual(project.getStartDate(), None)
self.assertNotEqual(project.getReference(), None)
self.assertTrue(project.getReference().startswith("PROJ-"),
"%s don't start with PROJ-" % project.getReference())
self.assertEqual(assignment_amount + 1,
len(person.objectValues(portal_type="Assignment")))
self.assertNotEqual([],
[i for i in person.objectValues(portal_type="Assignment")
if (i.getDestinationProjectValue() == project and i.getValidationState() == "open")])
class TestSlapOSERP5InteractionWorkflowOrganisationSetRole(
SlapOSTestCaseMixin):
def test_Organisation_validateAndAssign(self):
organisation = self.portal.organisation_module.newContent(
portal_type="Organisation"
)
organisation.setRole("host")
self.commit()
self.assertEqual(organisation.getValidationState(), "validated")
self.assertNotEqual(organisation.getReference(), None)
self.assertTrue(organisation.getReference().startswith("SITE-"),
"%s don't start with SITE-" % organisation.getReference())
def test_Organisation_validateAndAssign_client(self):
organisation = self.portal.organisation_module.newContent(
portal_type="Organisation"
)
organisation.setRole("client")
self.commit()
self.assertEqual(organisation.getValidationState(), "validated")
self.assertNotEqual(organisation.getReference(), None)
self.assertTrue(organisation.getReference().startswith("O-"),
"%s don't start with O-" % organisation.getReference())
def test_Organisation_validateAndAssign_other(self):
organisation = self.portal.organisation_module.newContent(
portal_type="Organisation"
)
organisation.setRole("other")
self.commit()
self.assertEqual(organisation.getValidationState(), "draft")
self.assertFalse(organisation.getReference("").startswith("O-"),
"%s start with O-" % organisation.getReference())
self.assertFalse(organisation.getReference("").startswith("SITE-"),
"%s start with SITE-" % organisation.getReference())
def test_Organisation_validateAndAssign_with_owner(self):
person = self.makePerson(user=1)
self.tic()
assignment_amount = len(person.objectValues(portal_type="Assignment"))
self.login(person.getUserId())
organisation = self.portal.organisation_module.newContent(
portal_type="Organisation"
)
organisation.setRole("host")
self.commit()
self.assertEqual(organisation.getValidationState(), "validated")
self.assertNotEqual(organisation.getReference(), None)
self.assertTrue(organisation.getReference().startswith("SITE-"),
"%s don't start with SITE-" % organisation.getReference())
self.assertEqual(assignment_amount + 1,
len(person.objectValues(portal_type="Assignment")))
self.assertNotEqual([],
[i for i in person.objectValues(portal_type="Assignment")
if (i.getDestinationValue() == organisation and i.getValidationState() == "open")])
def test_Organisation_validateAndAssign_with_assignment(self):
person = self.makePerson(user=1)
self.tic()
assignment_amount = len(person.objectValues(portal_type="Assignment"))
self.login(person.getUserId())
organisation = self.portal.organisation_module.newContent(
portal_type="Organisation"
)
person.newContent(
title="Assigment for Organisation %s" % organisation.getTitle(),
portal_type="Assignment",
subordination_value=organisation)
self.tic()
organisation.setRole("host")
self.commit()
self.assertEqual(organisation.getValidationState(), "validated")
self.assertNotEqual(organisation.getReference(), None)
self.assertTrue(organisation.getReference().startswith("SITE-"),
"%s don't start with SITE-" % organisation.getReference())
self.assertEqual(assignment_amount + 1,
len(person.objectValues(portal_type="Assignment")))
self.assertNotEqual([],
[i for i in person.objectValues(portal_type="Assignment")
if (i.getSubordinationValue() == organisation and i.getValidationState() == "open")])
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
<value> <value>
<tuple> <tuple>
<string>_setReference.*</string> <string>_setReference.*</string>
<string>_setDestinationDecision.*</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
computer_network = state_object["object"]
portal = context.getPortalObject()
person = portal.portal_membership.getAuthenticatedMember().getUserValue()
if person is not None and computer_network.getValidationState() == "draft":
computer_network.edit(
source_administration=person.getRelativeUrl()
)
if computer_network.getValidationState() == "draft":
computer_network.validate()
Acknowledgement | local_permission_slapos_interaction_workflow Acknowledgement | local_permission_slapos_interaction_workflow
Cloud Contract | local_permission_slapos_interaction_workflow Cloud Contract | local_permission_slapos_interaction_workflow
Computer Model | local_permission_slapos_interaction_workflow
Computer Network | local_permission_slapos_interaction_workflow
Computer Network | slapos_erp5_interaction_workflow
Compute Node | local_permission_slapos_interaction_workflow Compute Node | local_permission_slapos_interaction_workflow
Compute Node | slapos_erp5_interaction_workflow Compute Node | slapos_erp5_interaction_workflow
Computer Model | local_permission_slapos_interaction_workflow
Computer Network | local_permission_slapos_interaction_workflow
Contract Invitation Token | edit_workflow Contract Invitation Token | edit_workflow
Contract Invitation Token | validation_workflow Contract Invitation Token | validation_workflow
Delivery Cell | -immobilisation_movement_interaction_workflow Delivery Cell | -immobilisation_movement_interaction_workflow
...@@ -19,12 +18,10 @@ Inventory | -immobilisation_movement_interaction_workflow ...@@ -19,12 +18,10 @@ Inventory | -immobilisation_movement_interaction_workflow
Invitation Token | edit_workflow Invitation Token | edit_workflow
Invitation Token | validation_workflow Invitation Token | validation_workflow
Organisation | local_permission_slapos_interaction_workflow Organisation | local_permission_slapos_interaction_workflow
Organisation | slapos_erp5_interaction_workflow
Payment Transaction | local_permission_slapos_interaction_workflow Payment Transaction | local_permission_slapos_interaction_workflow
Payzen Event | local_permission_slapos_interaction_workflow Payzen Event | local_permission_slapos_interaction_workflow
Person | local_permission_slapos_interaction_workflow Person | local_permission_slapos_interaction_workflow
Project | local_permission_slapos_interaction_workflow Project | local_permission_slapos_interaction_workflow
Project | slapos_erp5_interaction_workflow
Purchase Packing List Cell | -immobilisation_movement_interaction_workflow Purchase Packing List Cell | -immobilisation_movement_interaction_workflow
Purchase Packing List Line | -immobilisation_movement_interaction_workflow Purchase Packing List Line | -immobilisation_movement_interaction_workflow
Purchase Packing List | -immobilisation_movement_interaction_workflow Purchase Packing List | -immobilisation_movement_interaction_workflow
......
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>text</string> </key> <key> <string>text</string> </key>
<value> <string>string:${object_url}/Base_viewDummyAsHateoas</string> </value> <value> <string>string:${object_url}/ProjectModule_viewProjectListAsHateoas</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
/*global window, rJS, RSVP */ /*global window, rJS, RSVP, jIO */
/*jslint nomen: true, indent: 2, maxerr: 3 */ /*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP) { (function (window, rJS, RSVP, jIO) {
"use strict"; "use strict";
rJS(window) rJS(window)
...@@ -10,9 +10,10 @@ ...@@ -10,9 +10,10 @@
.declareAcquiredMethod("updateHeader", "updateHeader") .declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("updatePanel", "updatePanel") .declareAcquiredMethod("updatePanel", "updatePanel")
.declareAcquiredMethod("getSetting", "getSetting") .declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("getSettingList", "getSettingList")
.declareAcquiredMethod("getUrlFor", "getUrlFor") .declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("redirect", "redirect") .declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("jio_post", "jio_post") .declareAcquiredMethod("jio_putAttachment", "jio_putAttachment")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting") .declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted') .declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
.declareAcquiredMethod("getTranslationList", "getTranslationList") .declareAcquiredMethod("getTranslationList", "getTranslationList")
...@@ -31,17 +32,28 @@ ...@@ -31,17 +32,28 @@
return gadget.getDeclaredGadget('form_view'); return gadget.getDeclaredGadget('form_view');
}) })
.push(function (form_gadget) { .push(function (form_gadget) {
return form_gadget.getContent(); return RSVP.all([form_gadget.getContent(),
gadget.getSettingList(['me', 'hateoas_url'])]);
}) })
.push(function (doc) { .push(function (result) {
return gadget.jio_post(doc); var doc = result[0],
me = result[1][0],
url = result[1][1];
return gadget.jio_putAttachment(me,
url + me + "/Person_requestNetwork", {title: doc.title});
})
.push(function (attachment) {
return jIO.util.readBlobAsText(attachment.target.response);
}) })
.push(function (key) { .push(function (response) {
return JSON.parse(response.target.result);
})
.push(function (result) {
return gadget.notifySubmitted({message: gadget.message_translation, status: 'success'}) return gadget.notifySubmitted({message: gadget.message_translation, status: 'success'})
.push(function () { .push(function () {
// Workaround, find a way to open document without break gadget. // Workaround, find a way to open document without break gadget.
return gadget.redirect({"command": "change", return gadget.redirect({"command": "change",
"options": {"jio_key": key, "page": "slap_controller"}}); "options": {"jio_key": result.relative_url, "page": "slap_controller"}});
}); });
}); });
}) })
...@@ -83,28 +95,6 @@ ...@@ -83,28 +95,6 @@
"key": "title", "key": "title",
"hidden": 0, "hidden": 0,
"type": "StringField" "type": "StringField"
},
"my_portal_type": {
"description": "The name of a document in ERP5",
"title": result[1][1],
"default": "Computer Network",
"css_class": "",
"required": 1,
"editable": 1,
"key": "portal_type",
"hidden": 1,
"type": "StringField"
},
"my_parent_relative_url": {
"description": "",
"title": result[1][2],
"default": "computer_network_module",
"css_class": "",
"required": 1,
"editable": 1,
"key": "parent_relative_url",
"hidden": 1,
"type": "StringField"
} }
}}, }},
"_links": { "_links": {
...@@ -117,7 +107,7 @@ ...@@ -117,7 +107,7 @@
form_definition: { form_definition: {
group_list: [[ group_list: [[
"left", "left",
[["my_title"], ["my_portal_type"], ["my_parent_relative_url"]] [["my_title"]]
]] ]]
} }
}); });
...@@ -140,4 +130,4 @@ ...@@ -140,4 +130,4 @@
}); });
}); });
}); });
}(window, rJS, RSVP)); }(window, rJS, RSVP, jIO));
\ No newline at end of file \ No newline at end of file
...@@ -279,7 +279,7 @@ ...@@ -279,7 +279,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>987.11840.22638.11383</string> </value> <value> <string>996.64461.17044.24763</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -297,7 +297,7 @@ ...@@ -297,7 +297,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1602261150.28</float> <float>1640118847.62</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*global window, rJS, RSVP */ /*global window, rJS, RSVP, jIO */
/*jslint nomen: true, indent: 2, maxerr: 3 */ /*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP) { (function (window, rJS, RSVP, jIO) {
"use strict"; "use strict";
var content_type = {
Spreadsheet: 'application/x-asc-spreadsheet',
Presentation: 'application/x-asc-presentation',
Text: 'application/x-asc-text'
};
rJS(window) rJS(window)
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Acquired methods // Acquired methods
...@@ -16,9 +10,10 @@ ...@@ -16,9 +10,10 @@
.declareAcquiredMethod("updateHeader", "updateHeader") .declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("updatePanel", "updatePanel") .declareAcquiredMethod("updatePanel", "updatePanel")
.declareAcquiredMethod("getSetting", "getSetting") .declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("getSettingList", "getSettingList")
.declareAcquiredMethod("getUrlFor", "getUrlFor") .declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("redirect", "redirect") .declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("jio_post", "jio_post") .declareAcquiredMethod("jio_putAttachment", "jio_putAttachment")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting") .declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted') .declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
.declareAcquiredMethod("getTranslationList", "getTranslationList") .declareAcquiredMethod("getTranslationList", "getTranslationList")
...@@ -37,20 +32,28 @@ ...@@ -37,20 +32,28 @@
return gadget.getDeclaredGadget('form_view'); return gadget.getDeclaredGadget('form_view');
}) })
.push(function (form_gadget) { .push(function (form_gadget) {
return form_gadget.getContent(); return RSVP.all([form_gadget.getContent(),
gadget.getSettingList(['me', 'hateoas_url'])]);
}) })
.push(function (doc) { .push(function (result) {
if (content_type.hasOwnProperty(doc.portal_type)) { var doc = result[0],
doc.content_type = content_type[doc.portal_type]; me = result[1][0],
} url = result[1][1];
return gadget.jio_post(doc); return gadget.jio_putAttachment(me,
url + me + "/Person_requestSite", {title: doc.title});
})
.push(function (attachment) {
return jIO.util.readBlobAsText(attachment.target.response);
})
.push(function (response) {
return JSON.parse(response.target.result);
}) })
.push(function (key) { .push(function (result) {
return gadget.notifySubmitted({message: gadget.message_translation, status: 'success'}) return gadget.notifySubmitted({message: gadget.message_translation, status: 'success'})
.push(function () { .push(function () {
// Workaround, find a way to open document without break gadget. // Workaround, find a way to open document without break gadget.
return gadget.redirect({"command": "change", return gadget.redirect({"command": "change",
"options": {"jio_key": key, "page": "slap_controller"}}); "options": {"jio_key": result.relative_url, "page": "slap_controller"}});
}); });
}); });
}) })
...@@ -96,39 +99,6 @@ ...@@ -96,39 +99,6 @@
"key": "title", "key": "title",
"hidden": 0, "hidden": 0,
"type": "StringField" "type": "StringField"
},
"my_role": {
"description": result[1][3],
"title": result[1][4],
"default": "host",
"css_class": "",
"required": 0,
"editable": 1,
"key": "role",
"hidden": 1,
"type": "StringField"
},
"my_portal_type": {
"description": result[1][1],
"title": result[1][5],
"default": "Organisation",
"css_class": "",
"required": 1,
"editable": 1,
"key": "portal_type",
"hidden": 1,
"type": "StringField"
},
"my_parent_relative_url": {
"description": "",
"title": result[1][7],
"default": "organisation_module",
"css_class": "",
"required": 1,
"editable": 1,
"key": "parent_relative_url",
"hidden": 1,
"type": "StringField"
} }
}}, }},
"_links": { "_links": {
...@@ -141,7 +111,7 @@ ...@@ -141,7 +111,7 @@
form_definition: { form_definition: {
group_list: [[ group_list: [[
"left", "left",
[["my_title"], ["my_role"], ["my_portal_type"], ["my_parent_relative_url"]] [["my_title"]]
]] ]]
} }
}); });
...@@ -164,4 +134,4 @@ ...@@ -164,4 +134,4 @@
}); });
}); });
}); });
}(window, rJS, RSVP)); }(window, rJS, RSVP, jIO));
\ No newline at end of file \ No newline at end of file
...@@ -147,7 +147,7 @@ ...@@ -147,7 +147,7 @@
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string>SlapOS Add Organisation JS</string> </value> <value> <string>SlapOS Add Organisation Site JS</string> </value>
</item> </item>
<item> <item>
<key> <string>url_string</string> </key> <key> <string>url_string</string> </key>
...@@ -290,7 +290,7 @@ ...@@ -290,7 +290,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>986.45437.22132.61764</string> </value> <value> <string>996.64499.26395.1621</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -308,7 +308,7 @@ ...@@ -308,7 +308,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1602261100.43</float> <float>1640118973.31</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -197,11 +197,13 @@ ...@@ -197,11 +197,13 @@
</record> </record>
<record id="3" aka="AAAAAAAAAAM="> <record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<key> <string>_log</string> </key>
<value>
<list> <list>
<dictionary> <dictionary>
<item> <item>
...@@ -245,17 +247,20 @@ ...@@ -245,17 +247,20 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
<none/> </value>
</tuple> </item>
</dictionary>
</pickle> </pickle>
</record> </record>
<record id="4" aka="AAAAAAAAAAQ="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<key> <string>_log</string> </key>
<value>
<list> <list>
<dictionary> <dictionary>
<item> <item>
...@@ -278,7 +283,7 @@ ...@@ -278,7 +283,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>982.16656.9604.44475</string> </value> <value> <string>996.45665.13466.27972</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -296,7 +301,7 @@ ...@@ -296,7 +301,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1583925144.16</float> <float>1640183877.21</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
...@@ -305,17 +310,20 @@ ...@@ -305,17 +310,20 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
<none/> </value>
</tuple> </item>
</dictionary>
</pickle> </pickle>
</record> </record>
<record id="5" aka="AAAAAAAAAAU="> <record id="5" aka="AAAAAAAAAAU=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<key> <string>_log</string> </key>
<value>
<list> <list>
<dictionary> <dictionary>
<item> <item>
...@@ -363,8 +371,9 @@ ...@@ -363,8 +371,9 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
<none/> </value>
</tuple> </item>
</dictionary>
</pickle> </pickle>
</record> </record>
</ZopeData> </ZopeData>
/*global window, rJS, RSVP */ /*global window, rJS, RSVP, jIO*/
/*jslint nomen: true, indent: 2, maxerr: 3 */ /*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP) { (function (window, rJS, RSVP, jIO) {
"use strict"; "use strict";
rJS(window) rJS(window)
...@@ -10,9 +10,10 @@ ...@@ -10,9 +10,10 @@
.declareAcquiredMethod("updateHeader", "updateHeader") .declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("updatePanel", "updatePanel") .declareAcquiredMethod("updatePanel", "updatePanel")
.declareAcquiredMethod("getSetting", "getSetting") .declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("getSettingList", "getSettingList")
.declareAcquiredMethod("getUrlFor", "getUrlFor") .declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("redirect", "redirect") .declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("jio_post", "jio_post") .declareAcquiredMethod("jio_putAttachment", "jio_putAttachment")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting") .declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted') .declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
.declareAcquiredMethod("getTranslationList", "getTranslationList") .declareAcquiredMethod("getTranslationList", "getTranslationList")
...@@ -31,17 +32,28 @@ ...@@ -31,17 +32,28 @@
return gadget.getDeclaredGadget('form_view'); return gadget.getDeclaredGadget('form_view');
}) })
.push(function (form_gadget) { .push(function (form_gadget) {
return form_gadget.getContent(); return RSVP.all([form_gadget.getContent(),
gadget.getSettingList(['me', 'hateoas_url'])]);
}) })
.push(function (doc) { .push(function (result) {
return gadget.jio_post(doc); var doc = result[0],
me = result[1][0],
url = result[1][1];
return gadget.jio_putAttachment(me,
url + me + "/Person_requestProject", {title: doc.title});
})
.push(function (attachment) {
return jIO.util.readBlobAsText(attachment.target.response);
}) })
.push(function (key) { .push(function (response) {
return JSON.parse(response.target.result);
})
.push(function (result) {
return gadget.notifySubmitted({message: gadget.message_translation, status: 'success'}) return gadget.notifySubmitted({message: gadget.message_translation, status: 'success'})
.push(function () { .push(function () {
// Workaround, find a way to open document without break gadget. // Workaround, find a way to open document without break gadget.
return gadget.redirect({"command": "change", return gadget.redirect({"command": "change",
"options": {"jio_key": key, "page": "slap_controller"}}); "options": {"jio_key": result.relative_url, "page": "slap_controller"}});
}); });
}); });
}) })
...@@ -88,50 +100,6 @@ ...@@ -88,50 +100,6 @@
"key": "title", "key": "title",
"hidden": 0, "hidden": 0,
"type": "StringField" "type": "StringField"
},
"my_description": {
"description": result[2][1],
"title": result[2][3],
"default": "",
"css_class": "",
"required": 0,
"editable": 1,
"key": "description",
"hidden": 0,
"type": "TextAreaField"
},
"my_destination_decision": {
"description": "",
"title": result[2][4],
"default": result[1],
"css_class": "",
"required": 1,
"editable": 1,
"key": "destination_decision",
"hidden": 1,
"type": "StringField"
},
"my_portal_type": {
"description": result[2][1],
"title": result[2][5],
"default": "Project",
"css_class": "",
"required": 1,
"editable": 1,
"key": "portal_type",
"hidden": 1,
"type": "StringField"
},
"my_parent_relative_url": {
"description": "",
"title": result[2][7],
"default": "project_module",
"css_class": "",
"required": 1,
"editable": 1,
"key": "parent_relative_url",
"hidden": 1,
"type": "StringField"
} }
}}, }},
"_links": { "_links": {
...@@ -144,7 +112,7 @@ ...@@ -144,7 +112,7 @@
form_definition: { form_definition: {
group_list: [[ group_list: [[
"left", "left",
[["my_title"], ["my_description"], ["my_destination_decision"], ["my_portal_type"], ["my_parent_relative_url"]] [["my_title"]]
]] ]]
} }
}); });
...@@ -161,4 +129,4 @@ ...@@ -161,4 +129,4 @@
}); });
}); });
}); });
}(window, rJS, RSVP)); }(window, rJS, RSVP, jIO));
\ No newline at end of file \ No newline at end of file
...@@ -279,7 +279,7 @@ ...@@ -279,7 +279,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>987.11838.43854.55603</string> </value> <value> <string>996.45681.58470.58709</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -297,7 +297,7 @@ ...@@ -297,7 +297,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1602261041.19</float> <float>1640118896.01</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -195,11 +195,13 @@ ...@@ -195,11 +195,13 @@
</record> </record>
<record id="3" aka="AAAAAAAAAAM="> <record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<key> <string>_log</string> </key>
<value>
<list> <list>
<dictionary> <dictionary>
<item> <item>
...@@ -243,17 +245,20 @@ ...@@ -243,17 +245,20 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
<none/> </value>
</tuple> </item>
</dictionary>
</pickle> </pickle>
</record> </record>
<record id="4" aka="AAAAAAAAAAQ="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<key> <string>_log</string> </key>
<value>
<list> <list>
<dictionary> <dictionary>
<item> <item>
...@@ -276,7 +281,7 @@ ...@@ -276,7 +281,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>982.36088.1118.26658</string> </value> <value> <string>996.45665.56224.23449</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -294,7 +299,7 @@ ...@@ -294,7 +299,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1584314425.96</float> <float>1640183701.65</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
...@@ -303,17 +308,20 @@ ...@@ -303,17 +308,20 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
<none/> </value>
</tuple> </item>
</dictionary>
</pickle> </pickle>
</record> </record>
<record id="5" aka="AAAAAAAAAAU="> <record id="5" aka="AAAAAAAAAAU=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<key> <string>_log</string> </key>
<value>
<list> <list>
<dictionary> <dictionary>
<item> <item>
...@@ -361,8 +369,9 @@ ...@@ -361,8 +369,9 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
<none/> </value>
</tuple> </item>
</dictionary>
</pickle> </pickle>
</record> </record>
</ZopeData> </ZopeData>
/*global window, rJS, RSVP */ /*global window, rJS, RSVP, jIO*/
/*jslint nomen: true, indent: 2, maxerr: 3 */ /*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP) { (function (window, rJS, RSVP, jIO) {
"use strict"; "use strict";
var content_type = {
Spreadsheet: 'application/x-asc-spreadsheet',
Presentation: 'application/x-asc-presentation',
Text: 'application/x-asc-text'
};
rJS(window) rJS(window)
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Acquired methods // Acquired methods
...@@ -16,9 +10,10 @@ ...@@ -16,9 +10,10 @@
.declareAcquiredMethod("updateHeader", "updateHeader") .declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("updatePanel", "updatePanel") .declareAcquiredMethod("updatePanel", "updatePanel")
.declareAcquiredMethod("getSetting", "getSetting") .declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("getSettingList", "getSettingList")
.declareAcquiredMethod("getUrlFor", "getUrlFor") .declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("redirect", "redirect") .declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("jio_post", "jio_post") .declareAcquiredMethod("jio_putAttachment", "jio_putAttachment")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting") .declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted') .declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
.declareAcquiredMethod("getTranslationList", "getTranslationList") .declareAcquiredMethod("getTranslationList", "getTranslationList")
...@@ -37,23 +32,28 @@ ...@@ -37,23 +32,28 @@
return gadget.getDeclaredGadget('form_view'); return gadget.getDeclaredGadget('form_view');
}) })
.push(function (form_gadget) { .push(function (form_gadget) {
return form_gadget.getContent(); return RSVP.all([form_gadget.getContent(),
gadget.getSettingList(['me', 'hateoas_url'])]);
}) })
.push(function (doc) { .push(function (result) {
if (content_type.hasOwnProperty(doc.portal_type)) { var doc = result[0],
doc.content_type = content_type[doc.portal_type]; me = result[1][0],
} url = result[1][1];
return RSVP.all([ return gadget.jio_putAttachment(me,
gadget.jio_post(doc), url + me + "/Person_requestOrganisation", {title: doc.title});
gadget.message_translation })
]); .push(function (attachment) {
return jIO.util.readBlobAsText(attachment.target.response);
})
.push(function (response) {
return JSON.parse(response.target.result);
}) })
.push(function (result) { .push(function (result) {
return gadget.notifySubmitted({message: result[1], status: 'success'}) return gadget.notifySubmitted({message: gadget.message_translation, status: 'success'})
.push(function () { .push(function () {
// Workaround, find a way to open document without break gadget. // Workaround, find a way to open document without break gadget.
return gadget.redirect({"command": "change", return gadget.redirect({"command": "change",
"options": {"jio_key": result[0], "page": "slap_controller"}}); "options": {"jio_key": result.relative_url, "page": "slap_controller"}});
}); });
}); });
}) })
...@@ -98,39 +98,6 @@ ...@@ -98,39 +98,6 @@
"key": "title", "key": "title",
"hidden": 0, "hidden": 0,
"type": "StringField" "type": "StringField"
},
"my_role": {
"description": result[1][3],
"title": result[1][4],
"default": "client",
"css_class": "",
"required": 0,
"editable": 1,
"key": "role",
"hidden": 1,
"type": "StringField"
},
"my_portal_type": {
"description": result[1][2],
"title": result[1][5],
"default": "Organisation",
"css_class": "",
"required": 1,
"editable": 1,
"key": "portal_type",
"hidden": 1,
"type": "StringField"
},
"my_parent_relative_url": {
"description": "",
"title": result[1][6],
"default": "organisation_module",
"css_class": "",
"required": 1,
"editable": 1,
"key": "parent_relative_url",
"hidden": 1,
"type": "StringField"
} }
}}, }},
"_links": { "_links": {
...@@ -143,7 +110,7 @@ ...@@ -143,7 +110,7 @@
form_definition: { form_definition: {
group_list: [[ group_list: [[
"left", "left",
[["my_title"], ["my_role"], ["my_portal_type"], ["my_parent_relative_url"]] [["my_title"]]
]] ]]
} }
}); });
...@@ -166,4 +133,4 @@ ...@@ -166,4 +133,4 @@
}); });
}); });
}); });
}(window, rJS, RSVP)); }(window, rJS, RSVP, jIO));
\ No newline at end of file \ No newline at end of file
...@@ -288,7 +288,7 @@ ...@@ -288,7 +288,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>987.11805.33415.21179</string> </value> <value> <string>996.64494.45558.13687</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -306,7 +306,7 @@ ...@@ -306,7 +306,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1602259071.92</float> <float>1640191658.53</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -58,75 +58,23 @@ ...@@ -58,75 +58,23 @@
}) })
.declareMethod("render", function () { .declareMethod("render", function () {
var gadget = this, var gadget = this,
lines_limit,
projects_translation, projects_translation,
translation_list = [ translation_list = [
"Title",
"Reference",
"Status",
"Projects" "Projects"
]; ];
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
return RSVP.all([
gadget.getSetting("listbox_lines_limit", 20),
window.getSettingMe(gadget)
]);
})
.push(function (settings) {
lines_limit = settings[0];
return RSVP.all([ return RSVP.all([
gadget.getDeclaredGadget('form_list'), gadget.getDeclaredGadget('form_list'),
gadget.jio_get(settings[1]), gadget.jio_getAttachment('project_module', 'view'),
gadget.getTranslationList(translation_list) gadget.getTranslationList(translation_list)
]); ])
}) })
.push(function (result) { .push(function (result) {
var destination_project_list, i, projects_translation = result[2][0];
column_list = [
['title', result[2][0]],
['reference', result[2][1]],
['Project_getNewsDict', result[2][2]]
];
projects_translation = result[2][3];
destination_project_list = "%22NULL%22%2C";
for (i in result[1].assignment_destination_project_list) {
if (result[1].assignment_destination_project_list.hasOwnProperty(i)) {
destination_project_list += "%22" + result[1].assignment_destination_project_list[i] + "%22%2C";
}
}
return result[0].render({ return result[0].render({
erp5_document: { erp5_document: result[1],
"_embedded": {"_view": {
"listbox": {
"column_list": column_list,
"show_anchor": 0,
"default_params": {},
"editable": 0,
"editable_column_list": [],
"key": "slap_project_listbox",
"lines": lines_limit,
"list_method": "portal_catalog",
// XXX TODO Filter by default_strict_allocation_scope_uid="!=%s" % context.getPortalObject().portal_categories.allocation_scope.close.forever.getUid(),
"query": "urn:jio:allDocs?query=portal_type%3A%22" +
"Project" + "%22%20AND%20validation_state%3Avalidated%20AND%20" +
"relative_url%3A(" + destination_project_list + ")",
"portal_type": [],
"search_column_list": column_list,
"sort_column_list": column_list,
"sort": [["title", "ascending"]],
"title": projects_translation,
"type": "ListBox"
}
}},
"_links": {
"type": {
// form_list display portal_type in header
name: ""
}
}
},
form_definition: { form_definition: {
group_list: [[ group_list: [[
"bottom", "bottom",
......
...@@ -84,12 +84,7 @@ ...@@ -84,12 +84,7 @@
return gadget.jio_get(me); return gadget.jio_get(me);
}) })
.push(function (me) { .push(function (me) {
var i, destination_list = '"NULL",', destination_project_list = '"NULL",'; var i, destination_list = '"NULL",';
for (i in me.assignment_destination_project_list) {
if (me.assignment_destination_project_list.hasOwnProperty(i)) {
destination_project_list += '"' + me.assignment_destination_project_list[i] + '",';
}
}
for (i in me.assignment_destination_list) { for (i in me.assignment_destination_list) {
if (me.assignment_destination_list.hasOwnProperty(i)) { if (me.assignment_destination_list.hasOwnProperty(i)) {
destination_list += '"' + me.assignment_destination_list[i] + '",'; destination_list += '"' + me.assignment_destination_list[i] + '",';
...@@ -104,7 +99,7 @@ ...@@ -104,7 +99,7 @@
select_list: ['reference', 'title'] select_list: ['reference', 'title']
}), }),
gadget.jio_allDocs({ gadget.jio_allDocs({
query: 'portal_type:"Project" AND validation_state:"validated" AND relative_url:(' + destination_project_list + ')', query: 'portal_type:"Project" AND validation_state:"validated"',
sort_on: [['reference', 'ascending']], sort_on: [['reference', 'ascending']],
select_list: ['reference', 'title'] select_list: ['reference', 'title']
}), }),
......
...@@ -279,7 +279,7 @@ ...@@ -279,7 +279,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>987.11742.24961.22050</string> </value> <value> <string>994.62925.42961.44083</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -297,7 +297,7 @@ ...@@ -297,7 +297,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1602255287.46</float> <float>1638836612.1</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -82,12 +82,7 @@ ...@@ -82,12 +82,7 @@
return gadget.jio_get(me); return gadget.jio_get(me);
}) })
.push(function (me) { .push(function (me) {
var i, destination_list = '"NULL",', destination_project_list = '"NULL",'; var i, destination_list = '"NULL",';
for (i in me.assignment_destination_project_list) {
if (me.assignment_destination_project_list.hasOwnProperty(i)) {
destination_project_list += '"' + me.assignment_destination_project_list[i] + '",';
}
}
for (i in me.assignment_destination_list) { for (i in me.assignment_destination_list) {
if (me.assignment_destination_list.hasOwnProperty(i)) { if (me.assignment_destination_list.hasOwnProperty(i)) {
destination_list += '"' + me.assignment_destination_list[i] + '",'; destination_list += '"' + me.assignment_destination_list[i] + '",';
...@@ -97,7 +92,7 @@ ...@@ -97,7 +92,7 @@
gadget.getDeclaredGadget('form_view'), gadget.getDeclaredGadget('form_view'),
gadget.jio_get(options.jio_key), gadget.jio_get(options.jio_key),
gadget.jio_allDocs({ gadget.jio_allDocs({
query: 'portal_type:"Project" AND validation_state:"validated" AND relative_url:(' + destination_project_list + ')', query: 'portal_type:"Project" AND validation_state:"validated"',
sort_on: [['reference', 'ascending']], sort_on: [['reference', 'ascending']],
select_list: ['reference', 'title'] select_list: ['reference', 'title']
}), }),
......
...@@ -277,7 +277,7 @@ ...@@ -277,7 +277,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>987.11739.65160.27938</string> </value> <value> <string>993.49407.7079.26129</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -295,7 +295,7 @@ ...@@ -295,7 +295,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1602255203.72</float> <float>1638836685.2</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -79,12 +79,7 @@ ...@@ -79,12 +79,7 @@
return gadget.jio_get(me); return gadget.jio_get(me);
}) })
.push(function (me) { .push(function (me) {
var i, destination_list = '"NULL",', destination_project_list = '"NULL",'; var i, destination_list = '"NULL",';
for (i in me.assignment_destination_project_list) {
if (me.assignment_destination_project_list.hasOwnProperty(i)) {
destination_project_list += '"' + me.assignment_destination_project_list[i] + '",';
}
}
for (i in me.assignment_destination_list) { for (i in me.assignment_destination_list) {
if (me.assignment_destination_list.hasOwnProperty(i)) { if (me.assignment_destination_list.hasOwnProperty(i)) {
destination_list += '"' + me.assignment_destination_list[i] + '",'; destination_list += '"' + me.assignment_destination_list[i] + '",';
...@@ -99,7 +94,7 @@ ...@@ -99,7 +94,7 @@
select_list: ['reference', 'title'] select_list: ['reference', 'title']
}), }),
gadget.jio_allDocs({ gadget.jio_allDocs({
query: 'portal_type:"Project" AND validation_state:"validated" AND relative_url:(' + destination_project_list + ')', query: 'portal_type:"Project" AND validation_state:"validated"',
sort_on: [['reference', 'ascending']], sort_on: [['reference', 'ascending']],
select_list: ['reference', 'title'] select_list: ['reference', 'title']
}), }),
......
...@@ -277,7 +277,7 @@ ...@@ -277,7 +277,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>987.11732.53320.3003</string> </value> <value> <string>993.49407.7079.26129</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -295,7 +295,7 @@ ...@@ -295,7 +295,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1602490257.93</float> <float>1638836764.88</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -4,21 +4,15 @@ portal = context.getPortalObject() ...@@ -4,21 +4,15 @@ portal = context.getPortalObject()
person = portal.portal_membership.getAuthenticatedMember().getUserValue() person = portal.portal_membership.getAuthenticatedMember().getUserValue()
web_site = context.getWebSiteValue() web_site = context.getWebSiteValue()
request_method = "POST"
slapos_master_web_url = web_site.getLayoutProperty( slapos_master_web_url = web_site.getLayoutProperty(
"configuration_slapos_master_web_url", web_site.absolute_url()) "configuration_slapos_master_web_url",
default=web_site.absolute_url()
)
request_url = "%s/%s" % (slapos_master_web_url, "Person_requestComputer") request_url = "%s/%s" % (slapos_master_web_url, "Person_requestComputer")
access_token = portal.access_token_module.newContent( person.requestToken(request_url=request_url)
portal_type="One Time Restricted Access Token", access_token_id = context.REQUEST.get("token")
agent_value=person,
url_string=request_url,
url_method=request_method
)
access_token_id = access_token.getId()
access_token.validate()
slapos_master_api = web_site.getLayoutProperty( slapos_master_api = web_site.getLayoutProperty(
"configuration_slapos_master_api", "https://slap.vifib.com") "configuration_slapos_master_api", "https://slap.vifib.com")
......
...@@ -10,8 +10,6 @@ except ValueError: ...@@ -10,8 +10,6 @@ except ValueError:
pass pass
web_site = context.getWebSiteValue() web_site = context.getWebSiteValue()
request_method = "POST"
request_url = "%s/%s" % ( request_url = "%s/%s" % (
web_site.getLayoutProperty( web_site.getLayoutProperty(
"configuration_slapos_master_web_url", "configuration_slapos_master_web_url",
...@@ -20,14 +18,8 @@ request_url = "%s/%s" % ( ...@@ -20,14 +18,8 @@ request_url = "%s/%s" % (
"Person_getCertificate" "Person_getCertificate"
) )
access_token = portal.access_token_module.newContent( person.requestToken(request_url=request_url)
portal_type="One Time Restricted Access Token", access_token_id = context.REQUEST.get("token")
agent_value=person,
url_string=request_url,
url_method=request_method
)
access_token_id = access_token.getId()
access_token.validate()
request = context.REQUEST request = context.REQUEST
response = request.RESPONSE response = request.RESPONSE
......
person = context.getPortalObject().portal_membership.getAuthenticatedMember().getUserValue() context.leaveOrganisation()
for assignment in person.objectValues(portal_type="Assignment"):
if assignment.getDestination() == context.getRelativeUrl():
assignment.close()
return
from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
# Use a script for overcome security
return [i.getDestinationProject() for i in context.objectValues(portal_type="Assignment")
if i.getDestinationProject() and i.getValidationState() == "open"]
...@@ -13,6 +13,7 @@ else: ...@@ -13,6 +13,7 @@ else:
compute_node = context.restrictedTraverse(context.REQUEST.get('compute_node')) compute_node = context.restrictedTraverse(context.REQUEST.get('compute_node'))
compute_node.generateCertificate() compute_node.generateCertificate()
response.setHeader('Content-Type', "application/json")
return json.dumps({ return json.dumps({
"certificate" : request.get('compute_node_certificate'), "certificate" : request.get('compute_node_certificate'),
"key" : request.get('compute_node_key'), "key" : request.get('compute_node_key'),
......
import json
portal = context.getPortalObject()
person = portal.portal_membership.getAuthenticatedMember().getUserValue()
request = context.REQUEST
response = request.RESPONSE
if person is None:
response.setStatus(403)
else:
request_kw = dict(network_title=title)
person.requestNetwork(**request_kw)
network_relative_url = request.get('computer_network_relative_url')
network_reference = request.get('computer_network_reference')
response.setHeader('Content-Type', "application/json")
return json.dumps({
"reference": network_reference,
"relative_url": network_relative_url
})
...@@ -50,19 +50,11 @@ ...@@ -50,19 +50,11 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>REQUEST=None</string> </value> <value> <string>title</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>Person_getAssignmentDestinationProjectList</string> </value> <value> <string>Person_requestNetwork</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
import json
portal = context.getPortalObject()
person = portal.portal_membership.getAuthenticatedMember().getUserValue()
request = context.REQUEST
response = request.RESPONSE
if person is None:
response.setStatus(403)
else:
request_kw = dict(organisation_title=title)
person.requestOrganisation(**request_kw)
organisation_relative_url = request.get('organisation_relative_url')
organisation_reference = request.get('organisation_reference')
response.setHeader('Content-Type', "application/json")
return json.dumps({
"reference": organisation_reference,
"relative_url": organisation_relative_url
})
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>title</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Person_requestOrganisation</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
import json
portal = context.getPortalObject()
person = portal.portal_membership.getAuthenticatedMember().getUserValue()
request = context.REQUEST
response = request.RESPONSE
if person is None:
response.setStatus(403)
else:
request_kw = dict(project_title=title)
person.requestProject(**request_kw)
project_relative_url = request.get('project_relative_url')
project_reference = request.get('project_reference')
response.setHeader('Content-Type', "application/json")
return json.dumps({
"reference": project_reference,
"relative_url": project_relative_url
})
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>title</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Person_requestProject</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
import json
portal = context.getPortalObject()
person = portal.portal_membership.getAuthenticatedMember().getUserValue()
request = context.REQUEST
response = request.RESPONSE
if person is None:
response.setStatus(403)
else:
request_kw = dict(organisation_title=title)
person.requestSite(**request_kw)
organisation_relative_url = request.get('organisation_relative_url')
organisation_reference = request.get('organisation_reference')
response.setHeader('Content-Type', "application/json")
return json.dumps({
"reference": organisation_reference,
"relative_url": organisation_relative_url
})
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>title</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Person_requestSite</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -92,7 +92,6 @@ ...@@ -92,7 +92,6 @@
<string>my_reference</string> <string>my_reference</string>
<string>my_last_name</string> <string>my_last_name</string>
<string>my_assignment_destination_list</string> <string>my_assignment_destination_list</string>
<string>my_assignment_destination_project_list</string>
<string>my_default_address_city</string> <string>my_default_address_city</string>
<string>my_default_address_region</string> <string>my_default_address_region</string>
<string>my_default_address_street_address</string> <string>my_default_address_street_address</string>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="StringField" module="Products.Formulator.StandardFields"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>my_assignment_destination_project_list</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
<item>
<key> <string>required_not_found</string> </key>
<value> <string>Input is required but no input given.</string> </value>
</item>
<item>
<key> <string>too_long</string> </key>
<value> <string>Too much input was given.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_maxwidth</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_width</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>input_type</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_length</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>truncate</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_maxwidth</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_width</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>input_type</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_length</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>truncate</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_maxwidth</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_width</string> </key>
<value> <int>20</int> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>input_type</string> </key>
<value> <string>text</string> </value>
</item>
<item>
<key> <string>max_length</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Reference</string> </value>
</item>
<item>
<key> <string>truncate</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <int>0</int> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>here/Person_getAssignmentDestinationProjectList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ERP5 Form" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value> <string>Base_doSelect</string> </value>
</item>
<item>
<key> <string>action_title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>edit_order</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>enctype</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<list>
<string>left</string>
<string>right</string>
<string>center</string>
<string>bottom</string>
<string>hidden</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list>
<string>listbox</string>
</list>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>hidden</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>left</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value>
<list/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ProjectModule_viewProjectListAsHateoas</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>ProjectModule_viewProjectListAsHateoas</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_list</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>stored_encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Projects</string> </value>
</item>
<item>
<key> <string>unicode_mode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>update_action</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>update_action_title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>all_columns</string>
<string>columns</string>
<string>default_params</string>
<string>portal_types</string>
<string>selection_name</string>
<string>sort</string>
<string>style_columns</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>listbox</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>all_columns</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>columns</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>selection_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>sort</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>style_columns</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>all_columns</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>columns</string> </key>
<value>
<list>
<tuple>
<string>title</string>
<string>Title</string>
</tuple>
<tuple>
<string>reference</string>
<string>Reference</string>
</tuple>
<tuple>
<string>Project_getNewsDict</string>
<string>Status</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>default_params</string> </key>
<value>
<list>
<tuple>
<string>validation_state</string>
<string>validated</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_list_mode_listbox</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value>
<list>
<tuple>
<string>Instance Tree</string>
<string>Instance Tree</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>portal_types</string> </key>
<value>
<list>
<tuple>
<string>Project</string>
<string>Project</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>selection_name</string> </key>
<value> <string>project_module_hateoas_selection</string> </value>
</item>
<item>
<key> <string>sort</string> </key>
<value>
<list>
<tuple>
<string>title</string>
<string>ascending</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>style_columns</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Projects</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from zExceptions import Unauthorized
portal = context.getPortalObject() portal = context.getPortalObject()
person = portal.portal_membership.getAuthenticatedMember().getUserValue() person = portal.portal_membership.getAuthenticatedMember().getUserValue()
...@@ -15,43 +14,11 @@ def redirect(message, message_type): ...@@ -15,43 +14,11 @@ def redirect(message, message_type):
"/#/?page=slap_notify_and_redirect&message_type=%s" % message_type + \ "/#/?page=slap_notify_and_redirect&message_type=%s" % message_type + \
"&portal_status_message=%s" % context.Base_translateString(message)) "&portal_status_message=%s" % context.Base_translateString(message))
if invitation_token is None:
message_str = "The Invitation Token is not present on the URL, please review the URL."
return redirect(message_str, "error")
if context.getPortalType() != "Project":
raise Unauthorized("Context is not an Project, please review your URL.")
try: try:
invitation_token = portal.invitation_token_module[invitation_token] context.acceptInvitation(invitation_token=invitation_token)
except KeyError: except ValueError as e:
message_str = "The Invitation Token can't be found, please review the URL." return redirect(context.Base_translateString(e), "error")
return redirect(message_str, "error")
if invitation_token.getPortalType() != "Invitation Token":
message_str = "The Invitation Token can't be found, please review the URL."
return redirect(message_str, "error")
if invitation_token.getValidationState() != "validated":
message_str = "The Invitation Token was already used and it cannot be reused, please ask a new one."
return redirect(message_str, "error")
if invitation_token.getSourceValue() == person:
message_str = "Invitation Token cannot be used by the same user that generated the token!"
return redirect(message_str, "error")
for assignment in person.objectValues(portal_type="Assignment"):
if assignment.getDestinationProject() == context.getRelativeUrl():
invitation_token.invalidate(comment="User already has assignment to the Person")
message_str = "You sucessfully join a new project: %s." % context.getTitle()
return redirect(message_str, "success")
person.newContent(
title="Assigment for Project %s" % context.getTitle(),
portal_type="Assignment",
destination_project_value=context).open()
invitation_token.invalidate()
message_str = "You sucessfully join a new project: %s." % context.getTitle() message_str = context.Base_translateString("You sucessfully join a new project: ")
message_str += context.getTitle()
return redirect(message_str, "success") return redirect(message_str, "success")
person = context.getPortalObject().portal_membership.getAuthenticatedMember().getUserValue() return context.leaveProject()
for assignment in person.objectValues(portal_type="Assignment"):
if assignment.getDestinationProject() == context.getRelativeUrl():
assignment.close()
return
...@@ -2,14 +2,14 @@ Accounting Transaction Module | slaposjs_view ...@@ -2,14 +2,14 @@ Accounting Transaction Module | slaposjs_view
Category | slaposjs_view Category | slaposjs_view
Cloud Contract | slaposjs_view Cloud Contract | slaposjs_view
Compute Node Module | slaposjs_view Compute Node Module | slaposjs_view
Computer Network Module | slaposjs_view
Computer Network | slaposjs_view
Compute Node | new_ticket Compute Node | new_ticket
Compute Node | request_certificate_action Compute Node | request_certificate_action
Compute Node | revoke_certificate Compute Node | revoke_certificate
Compute Node | slaposjs_view Compute Node | slaposjs_view
Compute Node | update_allocation_scope Compute Node | update_allocation_scope
Compute Node | update_category Compute Node | update_category
Computer Network Module | slaposjs_view
Computer Network | slaposjs_view
ERP5 Login | slaposjs_view ERP5 Login | slaposjs_view
Facebook Login | slaposjs_view Facebook Login | slaposjs_view
Google Login | slaposjs_view Google Login | slaposjs_view
......
...@@ -40,14 +40,14 @@ web_page_module/rjs_gadget_erp5_page_slap_compute_node_get_token_html ...@@ -40,14 +40,14 @@ web_page_module/rjs_gadget_erp5_page_slap_compute_node_get_token_html
web_page_module/rjs_gadget_erp5_page_slap_compute_node_get_token_js web_page_module/rjs_gadget_erp5_page_slap_compute_node_get_token_js
web_page_module/rjs_gadget_erp5_page_slap_compute_node_list_html web_page_module/rjs_gadget_erp5_page_slap_compute_node_list_html
web_page_module/rjs_gadget_erp5_page_slap_compute_node_list_js web_page_module/rjs_gadget_erp5_page_slap_compute_node_list_js
web_page_module/rjs_gadget_erp5_page_slap_computer_network_view_html
web_page_module/rjs_gadget_erp5_page_slap_computer_network_view_js
web_page_module/rjs_gadget_erp5_page_slap_compute_node_request_certificate_html web_page_module/rjs_gadget_erp5_page_slap_compute_node_request_certificate_html
web_page_module/rjs_gadget_erp5_page_slap_compute_node_request_certificate_js web_page_module/rjs_gadget_erp5_page_slap_compute_node_request_certificate_js
web_page_module/rjs_gadget_erp5_page_slap_compute_node_revoke_certificate_html web_page_module/rjs_gadget_erp5_page_slap_compute_node_revoke_certificate_html
web_page_module/rjs_gadget_erp5_page_slap_compute_node_revoke_certificate_js web_page_module/rjs_gadget_erp5_page_slap_compute_node_revoke_certificate_js
web_page_module/rjs_gadget_erp5_page_slap_compute_node_view_html web_page_module/rjs_gadget_erp5_page_slap_compute_node_view_html
web_page_module/rjs_gadget_erp5_page_slap_compute_node_view_js web_page_module/rjs_gadget_erp5_page_slap_compute_node_view_js
web_page_module/rjs_gadget_erp5_page_slap_computer_network_view_html
web_page_module/rjs_gadget_erp5_page_slap_computer_network_view_js
web_page_module/rjs_gadget_erp5_page_slap_controller_html web_page_module/rjs_gadget_erp5_page_slap_controller_html
web_page_module/rjs_gadget_erp5_page_slap_controller_js web_page_module/rjs_gadget_erp5_page_slap_controller_js
web_page_module/rjs_gadget_erp5_page_slap_delete_network_html web_page_module/rjs_gadget_erp5_page_slap_delete_network_html
......
...@@ -245,7 +245,7 @@ ...@@ -245,7 +245,7 @@
<tr> <tr>
<td>assertTextPresent</td> <td>assertTextPresent</td>
<td>You sucessfully join a new project: TEST-SLAPOSJS-PROJECT-TO-SHARE-NETWORK 0. <td>You sucessfully join a new project: TEST-SLAPOSJS-PROJECT-TO-SHARE-NETWORK 0
</td> </td>
<td></td> <td></td>
</tr> </tr>
......
...@@ -128,7 +128,7 @@ ...@@ -128,7 +128,7 @@
<tr> <tr>
<td>assertTextPresent</td> <td>assertTextPresent</td>
<td>You sucessfully join a new project: TEST-SLAPOSJS-PROJECT-INVITATION 0. <td>You sucessfully join a new project: TEST-SLAPOSJS-PROJECT-INVITATION 0
</td> </td>
<td></td> <td></td>
</tr> </tr>
......
...@@ -211,7 +211,7 @@ ...@@ -211,7 +211,7 @@
<tr> <tr>
<td>assertTextPresent</td> <td>assertTextPresent</td>
<td>You sucessfully join a new project: TEST-SLAPOSJS-PROJECT-TO-SHARE-COMPUTER 0. <td>You sucessfully join a new project: TEST-SLAPOSJS-PROJECT-TO-SHARE-COMPUTER 0
</td> </td>
<td></td> <td></td>
</tr> </tr>
......
...@@ -415,7 +415,7 @@ ...@@ -415,7 +415,7 @@
<tr> <tr>
<td>assertTextPresent</td> <td>assertTextPresent</td>
<td>You sucessfully join a new project: TEST-SLAPOSJS-PROJECT-TO-SHARE-SERVICE 0. <td>You sucessfully join a new project: TEST-SLAPOSJS-PROJECT-TO-SHARE-SERVICE 0
</td> </td>
<td></td> <td></td>
</tr> </tr>
......
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