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"] organisation = state_change["object"]
from DateTime import DateTime
portal = context.getPortalObject() portal = context.getPortalObject()
if project.getValidationState() != "draft": role = organisation.getRole()
return if role == "host":
reference_prefix = "SITE"
else:
reference_prefix = "O"
if project.getReference() in [None, ""]: if organisation.getReference() in [None, ""]:
reference = "PROJ-%s" % portal.portal_ids.generateNewId( reference = "%s-%s" % (reference_prefix, portal.portal_ids.generateNewId(
id_group='slap_project_reference', id_group='slap_organisation_reference',
id_generator='uid', default=1) id_generator='uid'))
project.setReference(reference)
organisation.setReference(reference)
organisation.validate()
# Get the user id of the context owner. # 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: for group, role_list in local_role_list:
if 'Owner' in role_list: if 'Owner' in role_list:
user_id = group user_id = group
...@@ -27,15 +30,13 @@ if person is None: ...@@ -27,15 +30,13 @@ if person is None:
return return
for assignment in person.objectValues(portal_type="Assignment"): for assignment in person.objectValues(portal_type="Assignment"):
if assignment.getDestinationProject() == project.getRelativeUrl(): if assignment.getSubordination() == organisation.getRelativeUrl():
if assignment.getValidationState() != "open": if assignment.getValidationState() != "open":
assignment.open() assignment.open()
return return
person.newContent( person.newContent(
title="Assigment for Project %s" % project.getTitle(), title="Assigment for Organisation (%s) %s" % (organisation.getRole(), organisation.getTitle()),
portal_type="Assignment", portal_type="Assignment",
destination_project=project.getRelativeUrl()).open() subordination_value=organisation,
destination_value=organisation).open()
project.edit(start_date=DateTime())
project.validate()
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 @@ ...@@ -53,16 +53,14 @@
<value> <string>state_change</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_Organisation_validateAndAssign</string> </value> <value> <string>script_Person_requestOrganisation</string> </value>
</item> </item>
<item> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
...@@ -70,9 +68,7 @@ ...@@ -70,9 +68,7 @@
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <value> <string>Person_requestOrganisation</string> </value>
<none/>
</value>
</item> </item>
</dictionary> </dictionary>
</pickle> </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 @@ ...@@ -16,10 +16,12 @@
<key> <string>categories</string> </key> <key> <string>categories</string> </key>
<value> <value>
<tuple> <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_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_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>
......
...@@ -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>
......
...@@ -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_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>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> </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_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>
<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/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 @@ ...@@ -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>
......
...@@ -328,96 +328,4 @@ class TestSlapOSERP5InteractionWorkflowComputerNetworkSetReference( ...@@ -328,96 +328,4 @@ class TestSlapOSERP5InteractionWorkflowComputerNetworkSetReference(
self.assertNotEqual(computer_network.getReference(), None) self.assertNotEqual(computer_network.getReference(), None)
self.assertEqual(computer_network.getValidationState(), "validated") self.assertEqual(computer_network.getValidationState(), "validated")
self.assertEqual(computer_network.getSourceAdministration(), self.assertEqual(computer_network.getSourceAdministration(),
None) 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 @@ ...@@ -3,12 +3,6 @@
(function (window, rJS, RSVP) { (function (window, rJS, RSVP) {
"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
...@@ -18,7 +12,7 @@ ...@@ -18,7 +12,7 @@
.declareAcquiredMethod("getSetting", "getSetting") .declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("getUrlFor", "getUrlFor") .declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("redirect", "redirect") .declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("jio_post", "jio_post") .declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting") .declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted') .declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
.declareAcquiredMethod("getTranslationList", "getTranslationList") .declareAcquiredMethod("getTranslationList", "getTranslationList")
...@@ -37,20 +31,23 @@ ...@@ -37,20 +31,23 @@
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.getSetting('me')]);
}) })
.push(function (doc) { .push(function (result) {
if (content_type.hasOwnProperty(doc.portal_type)) { var doc = result[0], me = result[1];
doc.content_type = content_type[doc.portal_type]; return gadget.getSetting("hateoas_url")
} .push(function (url) {
return gadget.jio_post(doc); 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'}) 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 +93,6 @@ ...@@ -96,39 +93,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 +105,7 @@ ...@@ -141,7 +105,7 @@
form_definition: { form_definition: {
group_list: [[ group_list: [[
"left", "left",
[["my_title"], ["my_role"], ["my_portal_type"], ["my_parent_relative_url"]] [["my_title"]]
]] ]]
} }
}); });
......
...@@ -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.47007.31595.62890</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>1639070506.86</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
<script src="rsvp.js"></script> <script src="rsvp.js"></script>
<script src="renderjs.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> <script src="gadget_erp5_page_slap_add_project.js"></script>
</head> </head>
......
...@@ -197,174 +197,183 @@ ...@@ -197,174 +197,183 @@
</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>
<list> <key> <string>_log</string> </key>
<dictionary> <value>
<item> <list>
<key> <string>action</string> </key> <dictionary>
<value> <string>publish_alive</string> </value> <item>
</item> <key> <string>action</string> </key>
<item> <value> <string>publish_alive</string> </value>
<key> <string>actor</string> </key> </item>
<value> <string>zope</string> </value> <item>
</item> <key> <string>actor</string> </key>
<item> <value> <string>zope</string> </value>
<key> <string>comment</string> </key> </item>
<value> <string></string> </value> <item>
</item> <key> <string>comment</string> </key>
<item> <value> <string></string> </value>
<key> <string>error_message</string> </key> </item>
<value> <string></string> </value> <item>
</item> <key> <string>error_message</string> </key>
<item> <value> <string></string> </value>
<key> <string>time</string> </key> </item>
<value> <item>
<object> <key> <string>time</string> </key>
<klass> <value>
<global name="DateTime" module="DateTime.DateTime"/> <object>
</klass> <klass>
<tuple> <global name="DateTime" module="DateTime.DateTime"/>
<none/> </klass>
</tuple> <tuple>
<state> <none/>
<tuple> </tuple>
<float>1508509434.37</float> <state>
<string>UTC</string> <tuple>
</tuple> <float>1508509434.37</float>
</state> <string>UTC</string>
</object> </tuple>
</value> </state>
</item> </object>
<item> </value>
<key> <string>validation_state</string> </key> </item>
<value> <string>published_alive</string> </value> <item>
</item> <key> <string>validation_state</string> </key>
</dictionary> <value> <string>published_alive</string> </value>
</list> </item>
<none/> </dictionary>
</tuple> </list>
</value>
</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>
<list> <key> <string>_log</string> </key>
<dictionary> <value>
<item> <list>
<key> <string>action</string> </key> <dictionary>
<value> <string>edit</string> </value> <item>
</item> <key> <string>action</string> </key>
<item> <value> <string>edit</string> </value>
<key> <string>actor</string> </key> </item>
<value> <string>zope</string> </value> <item>
</item> <key> <string>actor</string> </key>
<item> <value> <string>zope</string> </value>
<key> <string>comment</string> </key> </item>
<value> <item>
<none/> <key> <string>comment</string> </key>
</value> <value>
</item> <none/>
<item> </value>
<key> <string>error_message</string> </key> </item>
<value> <string></string> </value> <item>
</item> <key> <string>error_message</string> </key>
<item> <value> <string></string> </value>
<key> <string>serial</string> </key> </item>
<value> <string>982.16656.9604.44475</string> </value> <item>
</item> <key> <string>serial</string> </key>
<item> <value> <string>994.61547.14201.59494</string> </value>
<key> <string>state</string> </key> </item>
<value> <string>current</string> </value> <item>
</item> <key> <string>state</string> </key>
<item> <value> <string>current</string> </value>
<key> <string>time</string> </key> </item>
<value> <item>
<object> <key> <string>time</string> </key>
<klass> <value>
<global name="DateTime" module="DateTime.DateTime"/> <object>
</klass> <klass>
<tuple> <global name="DateTime" module="DateTime.DateTime"/>
<none/> </klass>
</tuple> <tuple>
<state> <none/>
<tuple> </tuple>
<float>1583925144.16</float> <state>
<string>UTC</string> <tuple>
</tuple> <float>1638988872.31</float>
</state> <string>UTC</string>
</object> </tuple>
</value> </state>
</item> </object>
</dictionary> </value>
</list> </item>
<none/> </dictionary>
</tuple> </list>
</value>
</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>
<list> <key> <string>_log</string> </key>
<dictionary> <value>
<item> <list>
<key> <string>action</string> </key> <dictionary>
<value> <string>detect_converted_file</string> </value> <item>
</item> <key> <string>action</string> </key>
<item> <value> <string>detect_converted_file</string> </value>
<key> <string>actor</string> </key> </item>
<value> <string>zope</string> </value> <item>
</item> <key> <string>actor</string> </key>
<item> <value> <string>zope</string> </value>
<key> <string>comment</string> </key> </item>
<value> <string></string> </value> <item>
</item> <key> <string>comment</string> </key>
<item> <value> <string></string> </value>
<key> <string>error_message</string> </key> </item>
<value> <string></string> </value> <item>
</item> <key> <string>error_message</string> </key>
<item> <value> <string></string> </value>
<key> <string>external_processing_state</string> </key> </item>
<value> <string>converted</string> </value> <item>
</item> <key> <string>external_processing_state</string> </key>
<item> <value> <string>converted</string> </value>
<key> <string>serial</string> </key> </item>
<value> <string>0.0.0.0</string> </value> <item>
</item> <key> <string>serial</string> </key>
<item> <value> <string>0.0.0.0</string> </value>
<key> <string>time</string> </key> </item>
<value> <item>
<object> <key> <string>time</string> </key>
<klass> <value>
<global name="DateTime" module="DateTime.DateTime"/> <object>
</klass> <klass>
<tuple> <global name="DateTime" module="DateTime.DateTime"/>
<none/> </klass>
</tuple> <tuple>
<state> <none/>
<tuple> </tuple>
<float>1508509417.57</float> <state>
<string>UTC</string> <tuple>
</tuple> <float>1508509417.57</float>
</state> <string>UTC</string>
</object> </tuple>
</value> </state>
</item> </object>
</dictionary> </value>
</list> </item>
<none/> </dictionary>
</tuple> </list>
</value>
</item>
</dictionary>
</pickle> </pickle>
</record> </record>
</ZopeData> </ZopeData>
...@@ -31,14 +31,15 @@ ...@@ -31,14 +31,15 @@
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.getSetting('me')]);
}) })
.push(function (doc) { .push(function (result) {
var doc = result[0], me = result[1];
return gadget.getSetting("hateoas_url") return gadget.getSetting("hateoas_url")
.push(function (url) { .push(function (url) {
// This is horrible return gadget.jio_getAttachment(me,
return gadget.jio_getAttachment(doc.parent_relative_url, url + me + "/Person_requestProject?title=" + doc.title);
url + doc.parent_relative_url + "/Person_requestProject?title=" + doc.title);
}); });
}) })
.push(function (result) { .push(function (result) {
...@@ -93,17 +94,6 @@ ...@@ -93,17 +94,6 @@
"key": "title", "key": "title",
"hidden": 0, "hidden": 0,
"type": "StringField" "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": {
...@@ -116,7 +106,7 @@ ...@@ -116,7 +106,7 @@
form_definition: { form_definition: {
group_list: [[ group_list: [[
"left", "left",
[["my_title"], ["my_parent_relative_url"]] [["my_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.11838.43854.55603</string> </value> <value> <string>996.45661.39570.44526</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>1638989873.52</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
<script src="rsvp.js"></script> <script src="rsvp.js"></script>
<script src="renderjs.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> <script src="gadget_erp5_page_slap_person_add_organisation.js"></script>
</head> </head>
......
...@@ -195,174 +195,183 @@ ...@@ -195,174 +195,183 @@
</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>
<list> <key> <string>_log</string> </key>
<dictionary> <value>
<item> <list>
<key> <string>action</string> </key> <dictionary>
<value> <string>publish_alive</string> </value> <item>
</item> <key> <string>action</string> </key>
<item> <value> <string>publish_alive</string> </value>
<key> <string>actor</string> </key> </item>
<value> <string>zope</string> </value> <item>
</item> <key> <string>actor</string> </key>
<item> <value> <string>zope</string> </value>
<key> <string>comment</string> </key> </item>
<value> <string></string> </value> <item>
</item> <key> <string>comment</string> </key>
<item> <value> <string></string> </value>
<key> <string>error_message</string> </key> </item>
<value> <string></string> </value> <item>
</item> <key> <string>error_message</string> </key>
<item> <value> <string></string> </value>
<key> <string>time</string> </key> </item>
<value> <item>
<object> <key> <string>time</string> </key>
<klass> <value>
<global name="DateTime" module="DateTime.DateTime"/> <object>
</klass> <klass>
<tuple> <global name="DateTime" module="DateTime.DateTime"/>
<none/> </klass>
</tuple> <tuple>
<state> <none/>
<tuple> </tuple>
<float>1561415375.85</float> <state>
<string>UTC</string> <tuple>
</tuple> <float>1561415375.85</float>
</state> <string>UTC</string>
</object> </tuple>
</value> </state>
</item> </object>
<item> </value>
<key> <string>validation_state</string> </key> </item>
<value> <string>published_alive</string> </value> <item>
</item> <key> <string>validation_state</string> </key>
</dictionary> <value> <string>published_alive</string> </value>
</list> </item>
<none/> </dictionary>
</tuple> </list>
</value>
</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>
<list> <key> <string>_log</string> </key>
<dictionary> <value>
<item> <list>
<key> <string>action</string> </key> <dictionary>
<value> <string>edit</string> </value> <item>
</item> <key> <string>action</string> </key>
<item> <value> <string>edit</string> </value>
<key> <string>actor</string> </key> </item>
<value> <string>zope</string> </value> <item>
</item> <key> <string>actor</string> </key>
<item> <value> <string>zope</string> </value>
<key> <string>comment</string> </key> </item>
<value> <item>
<none/> <key> <string>comment</string> </key>
</value> <value>
</item> <none/>
<item> </value>
<key> <string>error_message</string> </key> </item>
<value> <string></string> </value> <item>
</item> <key> <string>error_message</string> </key>
<item> <value> <string></string> </value>
<key> <string>serial</string> </key> </item>
<value> <string>982.36088.1118.26658</string> </value> <item>
</item> <key> <string>serial</string> </key>
<item> <value> <string>994.61547.14201.59494</string> </value>
<key> <string>state</string> </key> </item>
<value> <string>current</string> </value> <item>
</item> <key> <string>state</string> </key>
<item> <value> <string>current</string> </value>
<key> <string>time</string> </key> </item>
<value> <item>
<object> <key> <string>time</string> </key>
<klass> <value>
<global name="DateTime" module="DateTime.DateTime"/> <object>
</klass> <klass>
<tuple> <global name="DateTime" module="DateTime.DateTime"/>
<none/> </klass>
</tuple> <tuple>
<state> <none/>
<tuple> </tuple>
<float>1584314425.96</float> <state>
<string>UTC</string> <tuple>
</tuple> <float>1638988911.46</float>
</state> <string>UTC</string>
</object> </tuple>
</value> </state>
</item> </object>
</dictionary> </value>
</list> </item>
<none/> </dictionary>
</tuple> </list>
</value>
</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>
<list> <key> <string>_log</string> </key>
<dictionary> <value>
<item> <list>
<key> <string>action</string> </key> <dictionary>
<value> <string>detect_converted_file</string> </value> <item>
</item> <key> <string>action</string> </key>
<item> <value> <string>detect_converted_file</string> </value>
<key> <string>actor</string> </key> </item>
<value> <string>zope</string> </value> <item>
</item> <key> <string>actor</string> </key>
<item> <value> <string>zope</string> </value>
<key> <string>comment</string> </key> </item>
<value> <string></string> </value> <item>
</item> <key> <string>comment</string> </key>
<item> <value> <string></string> </value>
<key> <string>error_message</string> </key> </item>
<value> <string></string> </value> <item>
</item> <key> <string>error_message</string> </key>
<item> <value> <string></string> </value>
<key> <string>external_processing_state</string> </key> </item>
<value> <string>converted</string> </value> <item>
</item> <key> <string>external_processing_state</string> </key>
<item> <value> <string>converted</string> </value>
<key> <string>serial</string> </key> </item>
<value> <string>0.0.0.0</string> </value> <item>
</item> <key> <string>serial</string> </key>
<item> <value> <string>0.0.0.0</string> </value>
<key> <string>time</string> </key> </item>
<value> <item>
<object> <key> <string>time</string> </key>
<klass> <value>
<global name="DateTime" module="DateTime.DateTime"/> <object>
</klass> <klass>
<tuple> <global name="DateTime" module="DateTime.DateTime"/>
<none/> </klass>
</tuple> <tuple>
<state> <none/>
<tuple> </tuple>
<float>1561415347.25</float> <state>
<string>UTC</string> <tuple>
</tuple> <float>1561415347.25</float>
</state> <string>UTC</string>
</object> </tuple>
</value> </state>
</item> </object>
</dictionary> </value>
</list> </item>
<none/> </dictionary>
</tuple> </list>
</value>
</item>
</dictionary>
</pickle> </pickle>
</record> </record>
</ZopeData> </ZopeData>
...@@ -3,12 +3,6 @@ ...@@ -3,12 +3,6 @@
(function (window, rJS, RSVP) { (function (window, rJS, RSVP) {
"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
...@@ -18,7 +12,7 @@ ...@@ -18,7 +12,7 @@
.declareAcquiredMethod("getSetting", "getSetting") .declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("getUrlFor", "getUrlFor") .declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("redirect", "redirect") .declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("jio_post", "jio_post") .declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting") .declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted') .declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
.declareAcquiredMethod("getTranslationList", "getTranslationList") .declareAcquiredMethod("getTranslationList", "getTranslationList")
...@@ -37,23 +31,23 @@ ...@@ -37,23 +31,23 @@
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.getSetting('me')]);
}) })
.push(function (doc) { .push(function (result) {
if (content_type.hasOwnProperty(doc.portal_type)) { var doc = result[0], me = result[1];
doc.content_type = content_type[doc.portal_type]; return gadget.getSetting("hateoas_url")
} .push(function (url) {
return RSVP.all([ return gadget.jio_getAttachment(me,
gadget.jio_post(doc), url + me + "/Person_requestOrganisation?title=" + doc.title);
gadget.message_translation });
]);
}) })
.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 +92,6 @@ ...@@ -98,39 +92,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 +104,7 @@ ...@@ -143,7 +104,7 @@
form_definition: { form_definition: {
group_list: [[ group_list: [[
"left", "left",
[["my_title"], ["my_role"], ["my_portal_type"], ["my_parent_relative_url"]] [["my_title"]]
]] ]]
} }
}); });
......
...@@ -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.45677.54455.28313</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>1638989850.16</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </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