Commit 10ef6697 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_cloud&jio&erp5: Implement Person.request[Organisation|Site] API

   Introduce API on person to handle the requests of Organisations and
Sites.
parent 0293d863
project = state_change["object"]
from DateTime import DateTime
organisation = state_change["object"]
portal = context.getPortalObject()
if project.getValidationState() != "draft":
return
role = organisation.getRole()
if role == "host":
reference_prefix = "SITE"
else:
reference_prefix = "O"
if project.getReference() in [None, ""]:
reference = "PROJ-%s" % portal.portal_ids.generateNewId(
id_group='slap_project_reference',
id_generator='uid', default=1)
project.setReference(reference)
if organisation.getReference() in [None, ""]:
reference = "%s-%s" % (reference_prefix, portal.portal_ids.generateNewId(
id_group='slap_organisation_reference',
id_generator='uid'))
organisation.setReference(reference)
organisation.validate()
# Get the user id of the context owner.
local_role_list = project.get_local_roles()
local_role_list = organisation.get_local_roles()
for group, role_list in local_role_list:
if 'Owner' in role_list:
user_id = group
......@@ -27,15 +30,13 @@ if person is None:
return
for assignment in person.objectValues(portal_type="Assignment"):
if assignment.getDestinationProject() == project.getRelativeUrl():
if assignment.getSubordination() == organisation.getRelativeUrl():
if assignment.getValidationState() != "open":
assignment.open()
return
person.newContent(
title="Assigment for Project %s" % project.getTitle(),
title="Assigment for Organisation (%s) %s" % (organisation.getRole(), organisation.getTitle()),
portal_type="Assignment",
destination_project=project.getRelativeUrl()).open()
project.edit(start_date=DateTime())
project.validate()
subordination_value=organisation,
destination_value=organisation).open()
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"
organisation_list = portal.portal_catalog.portal_catalog(
portal_type=organisation_portal_type,
title=organisation_title,
# check if this works
role_id=role_id,
limit=2)
if len(organisation_list) == 2:
raise NotImplementedError
elif len(organisation_list) == 1:
context.REQUEST.set("organisation_relative_url", organisation_list[0].getRelativeUrl())
context.REQUEST.set("organisation_reference", organisation_list[0].getReference())
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())
context.REQUEST.set("organisation_reference", organisation.getReference())
organisation.approveRegistration()
......@@ -53,16 +53,14 @@
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<key> <string>description</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>script_Organisation_validateAndAssign</string> </value>
<value> <string>script_Person_requestOrganisation</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
......@@ -70,9 +68,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value>
<none/>
</value>
<value> <string>Person_requestOrganisation</string> </value>
</item>
</dictionary>
</pickle>
......
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>
......@@ -16,10 +16,12 @@
<key> <string>categories</string> </key>
<value>
<tuple>
<string>destination/portal_workflow/person_slap_interface_workflow/transition_request_token</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_token</string>
</tuple>
</value>
</item>
......
......@@ -18,10 +18,19 @@
<tuple>
<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_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_token</string>
</tuple>
</value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
......
......@@ -2,61 +2,61 @@
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Interaction Workflow Interaction" module="erp5.portal_type"/>
<global name="Workflow Transition" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<key> <string>action</string> </key>
<value>
<tuple>
<string>before_commit_script/portal_workflow/slapos_erp5_interaction_workflow/script_Organisation_validateAndAssign</string>
</tuple>
<none/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<key> <string>action_name</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</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>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>Organisation</string>
<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>portal_type_group_filter</string> </key>
<key> <string>description</string> </key>
<value>
<tuple/>
<none/>
</value>
</item>
<item>
<key> <string>temporary_document_disallowed</string> </key>
<value> <int>0</int> </value>
<key> <string>guard_permission</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>trigger_method_id</string> </key>
<key> <string>icon</string> </key>
<value>
<tuple>
<string>_setRole*</string>
</tuple>
<none/>
</value>
</item>
<item>
<key> <string>trigger_once_per_transaction</string> </key>
<value> <int>1</int> </value>
<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>
......
<?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>
......@@ -61,7 +61,7 @@
</chain>
<chain>
<type>Organisation</type>
<workflow>local_permission_slapos_interaction_workflow, slapos_erp5_interaction_workflow</workflow>
<workflow>local_permission_slapos_interaction_workflow</workflow>
</chain>
<chain>
<type>Payment Transaction</type>
......
......@@ -329,95 +329,3 @@ class TestSlapOSERP5InteractionWorkflowComputerNetworkSetReference(
self.assertEqual(computer_network.getValidationState(), "validated")
self.assertEqual(computer_network.getSourceAdministration(),
None)
\ No newline at end of file
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")])
organisation = state_change["object"]
portal = context.getPortalObject()
if organisation.getValidationState() != "draft":
return
role = organisation.getRole()
if role not in ["host", "client"]:
return
if role == "host":
reference_prefix = "SITE"
else:
reference_prefix = "O"
if organisation.getReference() in [None, ""]:
reference = "%s-%s" % (reference_prefix, portal.portal_ids.generateNewId(
id_group='slap_organisation_reference',
id_generator='uid'))
organisation.setReference(reference)
organisation.validate()
user_id = organisation.Base_getOwnerId()
person = context.getPortalObject().portal_catalog.getResultValue(user_id=user_id)
if person is None:
return
for assignment in person.objectValues(portal_type="Assignment"):
if assignment.getSubordination() == organisation.getRelativeUrl():
if assignment.getValidationState() != "open":
assignment.open()
return
person.newContent(
title="Assigment for Site %s" % organisation.getTitle(),
portal_type="Assignment",
subordination_value=organisation,
destination_value=organisation).open()
......@@ -3,12 +3,6 @@
(function (window, rJS, RSVP) {
"use strict";
var content_type = {
Spreadsheet: 'application/x-asc-spreadsheet',
Presentation: 'application/x-asc-presentation',
Text: 'application/x-asc-text'
};
rJS(window)
/////////////////////////////////////////////////////////////////
// Acquired methods
......@@ -18,7 +12,7 @@
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("jio_post", "jio_post")
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
.declareAcquiredMethod("getTranslationList", "getTranslationList")
......@@ -37,20 +31,23 @@
return gadget.getDeclaredGadget('form_view');
})
.push(function (form_gadget) {
return form_gadget.getContent();
return RSVP.all([form_gadget.getContent(),
gadget.getSetting('me')]);
})
.push(function (doc) {
if (content_type.hasOwnProperty(doc.portal_type)) {
doc.content_type = content_type[doc.portal_type];
}
return gadget.jio_post(doc);
.push(function (result) {
var doc = result[0], me = result[1];
return gadget.getSetting("hateoas_url")
.push(function (url) {
return gadget.jio_getAttachment(me,
url + me + "/Person_requestSite?title=" + doc.title);
});
})
.push(function (key) {
.push(function (result) {
return gadget.notifySubmitted({message: gadget.message_translation, status: 'success'})
.push(function () {
// Workaround, find a way to open document without break gadget.
return gadget.redirect({"command": "change",
"options": {"jio_key": key, "page": "slap_controller"}});
"options": {"jio_key": result.relative_url, "page": "slap_controller"}});
});
});
})
......@@ -96,39 +93,6 @@
"key": "title",
"hidden": 0,
"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": {
......@@ -141,7 +105,7 @@
form_definition: {
group_list: [[
"left",
[["my_title"], ["my_role"], ["my_portal_type"], ["my_parent_relative_url"]]
[["my_title"]]
]]
}
});
......
......@@ -290,7 +290,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>986.45437.22132.61764</string> </value>
<value> <string>996.47007.31595.62890</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -308,7 +308,7 @@
</tuple>
<state>
<tuple>
<float>1602261100.43</float>
<float>1639070506.86</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -20,6 +20,7 @@
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="gadget_slapos_utils.js" type="text/javascript"></script>
<script src="gadget_erp5_page_slap_add_project.js"></script>
</head>
......
......@@ -197,11 +197,13 @@
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -245,17 +247,20 @@
</item>
</dictionary>
</list>
<none/>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -278,7 +283,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>982.16656.9604.44475</string> </value>
<value> <string>994.61547.14201.59494</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -296,7 +301,7 @@
</tuple>
<state>
<tuple>
<float>1583925144.16</float>
<float>1638988872.31</float>
<string>UTC</string>
</tuple>
</state>
......@@ -305,17 +310,20 @@
</item>
</dictionary>
</list>
<none/>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -363,8 +371,9 @@
</item>
</dictionary>
</list>
<none/>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -31,14 +31,15 @@
return gadget.getDeclaredGadget('form_view');
})
.push(function (form_gadget) {
return form_gadget.getContent();
return RSVP.all([form_gadget.getContent(),
gadget.getSetting('me')]);
})
.push(function (doc) {
.push(function (result) {
var doc = result[0], me = result[1];
return gadget.getSetting("hateoas_url")
.push(function (url) {
// This is horrible
return gadget.jio_getAttachment(doc.parent_relative_url,
url + doc.parent_relative_url + "/Person_requestProject?title=" + doc.title);
return gadget.jio_getAttachment(me,
url + me + "/Person_requestProject?title=" + doc.title);
});
})
.push(function (result) {
......@@ -93,17 +94,6 @@
"key": "title",
"hidden": 0,
"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": {
......@@ -116,7 +106,7 @@
form_definition: {
group_list: [[
"left",
[["my_title"], ["my_parent_relative_url"]]
[["my_title"]]
]]
}
});
......
......@@ -279,7 +279,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>987.11838.43854.55603</string> </value>
<value> <string>996.45661.39570.44526</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -297,7 +297,7 @@
</tuple>
<state>
<tuple>
<float>1602261041.19</float>
<float>1638989873.52</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -19,6 +19,7 @@
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="gadget_slapos_utils.js" type="text/javascript"></script>
<script src="gadget_erp5_page_slap_person_add_organisation.js"></script>
</head>
......
......@@ -195,11 +195,13 @@
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -243,17 +245,20 @@
</item>
</dictionary>
</list>
<none/>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -276,7 +281,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>982.36088.1118.26658</string> </value>
<value> <string>994.61547.14201.59494</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -294,7 +299,7 @@
</tuple>
<state>
<tuple>
<float>1584314425.96</float>
<float>1638988911.46</float>
<string>UTC</string>
</tuple>
</state>
......@@ -303,17 +308,20 @@
</item>
</dictionary>
</list>
<none/>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -361,8 +369,9 @@
</item>
</dictionary>
</list>
<none/>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -3,12 +3,6 @@
(function (window, rJS, RSVP) {
"use strict";
var content_type = {
Spreadsheet: 'application/x-asc-spreadsheet',
Presentation: 'application/x-asc-presentation',
Text: 'application/x-asc-text'
};
rJS(window)
/////////////////////////////////////////////////////////////////
// Acquired methods
......@@ -18,7 +12,7 @@
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("jio_post", "jio_post")
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
.declareAcquiredMethod("getTranslationList", "getTranslationList")
......@@ -37,23 +31,23 @@
return gadget.getDeclaredGadget('form_view');
})
.push(function (form_gadget) {
return form_gadget.getContent();
return RSVP.all([form_gadget.getContent(),
gadget.getSetting('me')]);
})
.push(function (doc) {
if (content_type.hasOwnProperty(doc.portal_type)) {
doc.content_type = content_type[doc.portal_type];
}
return RSVP.all([
gadget.jio_post(doc),
gadget.message_translation
]);
.push(function (result) {
var doc = result[0], me = result[1];
return gadget.getSetting("hateoas_url")
.push(function (url) {
return gadget.jio_getAttachment(me,
url + me + "/Person_requestOrganisation?title=" + doc.title);
});
})
.push(function (result) {
return gadget.notifySubmitted({message: result[1], status: 'success'})
return gadget.notifySubmitted({message: gadget.message_translation, status: 'success'})
.push(function () {
// Workaround, find a way to open document without break gadget.
return gadget.redirect({"command": "change",
"options": {"jio_key": result[0], "page": "slap_controller"}});
"options": {"jio_key": result.relative_url, "page": "slap_controller"}});
});
});
})
......@@ -98,39 +92,6 @@
"key": "title",
"hidden": 0,
"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": {
......@@ -143,7 +104,7 @@
form_definition: {
group_list: [[
"left",
[["my_title"], ["my_role"], ["my_portal_type"], ["my_parent_relative_url"]]
[["my_title"]]
]]
}
});
......
......@@ -288,7 +288,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>987.11805.33415.21179</string> </value>
<value> <string>996.45677.54455.28313</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -306,7 +306,7 @@
</tuple>
<state>
<tuple>
<float>1602259071.92</float>
<float>1638989850.16</float>
<string>UTC</string>
</tuple>
</state>
......
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 = context.REQUEST.get('organisation_relative_url')
organisation_reference = context.REQUEST.get('organisation_reference')
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(organisation_title=title)
person.requestSite(**request_kw)
organisation_relative_url = context.REQUEST.get('organisation_relative_url')
organisation_reference = context.REQUEST.get('organisation_reference')
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>
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