Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Xiaowu Zhang
slapos.core
Commits
7e382c9b
Commit
7e382c9b
authored
Jul 01, 2019
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_jio: An user can invite another user to its organisation
parent
bd7b6ca5
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
351 additions
and
17 deletions
+351
-17
master/bt5/slapos_jio/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_slap_organisation_view_js.js
..._module/rjs_gadget_erp5_page_slap_organisation_view_js.js
+55
-13
master/bt5/slapos_jio/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_slap_organisation_view_js.xml
...module/rjs_gadget_erp5_page_slap_organisation_view_js.xml
+2
-2
master/bt5/slapos_jio/PathTemplateItem/web_page_module/rjs_gadget_slapos_header_js.js
...mplateItem/web_page_module/rjs_gadget_slapos_header_js.js
+1
-0
master/bt5/slapos_jio/PathTemplateItem/web_page_module/rjs_gadget_slapos_header_js.xml
...plateItem/web_page_module/rjs_gadget_slapos_header_js.xml
+2
-2
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/Base_getInvitationLink.py
...tal_skins/slapos_hal_json_style/Base_getInvitationLink.py
+27
-0
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/Base_getInvitationLink.xml
...al_skins/slapos_hal_json_style/Base_getInvitationLink.xml
+70
-0
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/Organisation_acceptInvitation.py
...ns/slapos_hal_json_style/Organisation_acceptInvitation.py
+41
-0
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/Organisation_acceptInvitation.xml
...s/slapos_hal_json_style/Organisation_acceptInvitation.xml
+70
-0
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/Organisation_getAssociatedPersonList.py
...os_hal_json_style/Organisation_getAssociatedPersonList.py
+13
-0
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/Organisation_getAssociatedPersonList.xml
...s_hal_json_style/Organisation_getAssociatedPersonList.xml
+70
-0
No files found.
master/bt5/slapos_jio/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_slap_organisation_view_js.js
View file @
7e382c9b
...
...
@@ -30,6 +30,48 @@
});
})
.
allowPublicAcquisition
(
"
jio_allDocs
"
,
function
(
param_list
)
{
var
gadget
=
this
;
return
gadget
.
jio_allDocs
(
param_list
[
0
])
.
push
(
function
(
result
)
{
var
i
,
value
,
jio_key_value
,
len
=
result
.
data
.
total_rows
;
for
(
i
=
0
;
i
<
len
;
i
+=
1
)
{
if
(
1
||
(
result
.
data
.
rows
[
i
].
value
.
hasOwnProperty
(
"
title
"
)))
{
value
=
result
.
data
.
rows
[
i
].
value
.
title
;
result
.
data
.
rows
[
i
].
value
.
title
=
{
field_gadget_param
:
{
css_class
:
""
,
"
default
"
:
value
,
key
:
"
title
"
,
editable
:
1
,
url
:
"
gadget_slapos_label_listbox_field.html
"
,
title
:
"
Title
"
,
type
:
"
GadgetField
"
}
};
value
=
result
.
data
.
rows
[
i
].
value
.
default_email_text
;
result
.
data
.
rows
[
i
].
value
.
default_email_text
=
{
field_gadget_param
:
{
css_class
:
""
,
"
default
"
:
value
,
key
:
"
default_email_text
"
,
editable
:
1
,
url
:
"
gadget_slapos_label_listbox_field.html
"
,
title
:
"
Status
"
,
type
:
"
GadgetField
"
}
};
result
.
data
.
rows
[
i
].
value
[
"
listbox_uid:list
"
]
=
{
key
:
"
listbox_uid:list
"
,
value
:
2713
};
}
}
return
result
;
});
})
.
onEvent
(
'
submit
'
,
function
()
{
var
gadget
=
this
;
return
gadget
.
notifySubmitting
()
...
...
@@ -61,7 +103,10 @@
]);
})
.
push
(
function
(
result
)
{
var
column_list
=
[],
var
column_list
=
[
[
'
title
'
,
'
Title
'
],
[
'
default_email_text
'
,
'
Email
'
]
],
editable
=
gadget
.
state
.
editable
;
return
result
[
0
].
render
({
erp5_document
:
{
...
...
@@ -92,13 +137,13 @@
"
column_list
"
:
column_list
,
"
show_anchor
"
:
0
,
"
default_params
"
:
{},
"
editable
"
:
0
,
"
editable
"
:
1
,
"
editable_column_list
"
:
[],
"
key
"
:
"
slap_organisation_computer_listbox
"
,
"
lines
"
:
10
,
"
list_method
"
:
"
Organisation_get
ComputerTracking
List
"
,
"
list_method
"
:
"
Organisation_get
AssociatedPerson
List
"
,
"
list_method_template
"
:
result
[
1
]
+
"
ERP5Document_getHateoas?mode=search&
"
+
"
list_method=Organisation_get
ComputerTracking
List&relative_url=
"
+
"
list_method=Organisation_get
AssociatedPerson
List&relative_url=
"
+
gadget
.
state
.
jio_key
+
"
&default_param_json=eyJpZ25vcmVfdW5rbm93bl9jb2x1bW5zIjogdHJ1ZX0={&query,select_list*,limit*,sort_on*,local_roles*}
"
,
"
query
"
:
"
urn:jio:allDocs?query=
"
,
"
portal_type
"
:
[],
...
...
@@ -119,12 +164,7 @@
form_definition
:
{
group_list
:
[[
"
left
"
,
[[
"
my_title
"
],
[
"
my_reference
"
],
[
'
my_monitoring_status
'
],
[
"
my_default_geographical_location_longitude
"
],
[
"
my_default_geographical_location_latitude
"
]]
],
[
"
right
"
,
[[
'
my_organisation_map
'
]]
[[
"
my_title
"
],
[
"
my_reference
"
]]
],
[
"
bottom
"
,
[[
"
listbox
"
]]
...
...
@@ -135,15 +175,17 @@
.
push
(
function
()
{
return
RSVP
.
all
([
gadget
.
getUrlFor
({
command
:
"
change
"
,
options
:
{
editable
:
true
}}),
gadget
.
getUrlFor
({
command
:
'
history_previous
'
}),
gadget
.
getUrlFor
({
command
:
"
change
"
,
options
:
{
page
:
"
slap_delete_organisation
"
}})
gadget
.
getUrlFor
({
command
:
"
change
"
,
options
:
{
page
:
"
slap_person_view
"
}}),
gadget
.
getUrlFor
({
command
:
"
change
"
,
options
:
{
page
:
"
slap_delete_organisation
"
}}),
gadget
.
getUrlFor
({
command
:
"
change
"
,
options
:
{
page
:
"
slap_organisation_get_invitation_link
"
}})
]);
})
.
push
(
function
(
url_list
)
{
var
header_dict
=
{
selection_url
:
url_list
[
1
],
page_title
:
"
Site
:
"
+
gadget
.
state
.
doc
.
title
,
page_title
:
"
Organisation
:
"
+
gadget
.
state
.
doc
.
title
,
delete_url
:
url_list
[
2
],
invitation_url
:
url_list
[
3
],
save_action
:
true
};
if
(
!
gadget
.
state
.
editable
)
{
...
...
master/bt5/slapos_jio/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_slap_organisation_view_js.xml
View file @
7e382c9b
...
...
@@ -230,7 +230,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
976.
40660.54394.14284
</string>
</value>
<value>
<string>
976.
51816.56601.26897
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>
156
1428006.67
</float>
<float>
156
2012361.29
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
master/bt5/slapos_jio/PathTemplateItem/web_page_module/rjs_gadget_slapos_header_js.js
View file @
7e382c9b
...
...
@@ -43,6 +43,7 @@
[
'
add_login_url
'
,
'
Add Login
'
,
'
plus
'
],
[
'
add_organisation_url
'
,
'
Add Organisation
'
,
'
plus
'
],
[
'
token_url
'
,
'
Token
'
,
'
key
'
],
[
'
invitation_url
'
,
'
Invite User
'
,
'
key
'
],
[
'
request_certificate_url
'
,
'
Request Certificate
'
,
'
certificate
'
],
[
'
revoke_certificate_url
'
,
'
Revoke Certificate
'
,
'
ban
'
],
[
'
rss_url
'
,
'
RSS
'
,
'
rss
'
],
...
...
master/bt5/slapos_jio/PathTemplateItem/web_page_module/rjs_gadget_slapos_header_js.xml
View file @
7e382c9b
...
...
@@ -230,7 +230,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
976.
9867.41515.40260
</string>
</value>
<value>
<string>
976.
40547.45717.53213
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>
1561
421021.85
</float>
<float>
1561
750946.36
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/Base_getInvitationLink.py
0 → 100644
View file @
7e382c9b
import
json
from
zExceptions
import
Unauthorized
portal
=
context
.
getPortalObject
()
person
=
portal
.
portal_membership
.
getAuthenticatedMember
().
getUserValue
()
if
context
.
getPortalType
()
!=
"Organisation"
:
raise
Unauthorized
web_site
=
context
.
getWebSiteValue
()
request_method
=
"POST"
request_url
=
"%s/%s/%s"
%
(
web_site
.
absolute_url
(),
context
.
getRelativeUrl
(),
"Organisation_acceptInvitation"
)
# Maybe it would be better to use another portal_type
access_token
=
portal
.
invitation_token_module
.
newContent
(
portal_type
=
"Invitation Token"
,
source_value
=
person
,
url_string
=
request_url
,
url_method
=
request_method
)
access_token
.
validate
()
request
=
context
.
REQUEST
response
=
request
.
RESPONSE
response
.
setHeader
(
'Content-Type'
,
"application/json"
)
return
json
.
dumps
({
'invitation_link'
:
"%s?invitation_token=%s"
%
(
request_url
,
access_token
.
getId
())})
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/Base_getInvitationLink.xml
0 → 100644
View file @
7e382c9b
<?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></string>
</value>
</item>
<item>
<key>
<string>
_proxy_roles
</string>
</key>
<value>
<tuple>
<string>
Manager
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Base_getInvitationLink
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/Organisation_acceptInvitation.py
0 → 100644
View file @
7e382c9b
from
zExceptions
import
Unauthorized
portal
=
context
.
getPortalObject
()
if
invitation_token
is
None
:
raise
ValueError
(
"Invitation Token is required"
)
if
context
.
getPortalType
()
!=
"Organisation"
:
raise
Unauthorized
(
"Context is not an Organisation"
)
person
=
portal
.
portal_membership
.
getAuthenticatedMember
().
getUserValue
()
if
person
is
None
:
raise
ValueError
(
"You must be logged in!"
)
try
:
invitation_token
=
portal
.
invitation_token_module
[
invitation_token
]
except
KeyError
:
raise
ValueError
(
"Invitation Token is not found."
)
if
invitation_token
.
getPortalType
()
!=
"Invitation Token"
:
raise
ValueError
(
"Invitation Token is not found."
)
if
invitation_token
.
getValidationState
()
!=
"validated"
:
raise
ValueError
(
"Invitation Token was already used."
)
if
invitation_token
.
getSourceValue
()
==
person
:
raise
ValueError
(
"Invitation Token cannot be used by the same user that generated the token!"
)
for
assignment
in
person
.
objectValues
(
portal_type
=
"Assignment"
):
if
assignment
.
getSubordination
()
==
context
.
getRelativeUrl
():
invitation_token
.
invalidate
(
comment
=
"User already has assignment to the Person"
)
return
"Already had stuff"
person
.
newContent
(
title
=
"Assigment for Site %s"
%
context
.
getTitle
(),
portal_type
=
"Assignment"
,
destination_value
=
context
).
open
()
invitation_token
.
invalidate
()
return
'Go charlie'
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/Organisation_acceptInvitation.xml
0 → 100644
View file @
7e382c9b
<?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>
invitation_token=None
</string>
</value>
</item>
<item>
<key>
<string>
_proxy_roles
</string>
</key>
<value>
<tuple>
<string>
Manager
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Organisation_acceptInvitation
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/Organisation_getAssociatedPersonList.py
0 → 100644
View file @
7e382c9b
from
Products.ERP5Type.Document
import
newTempDocument
temp_object_list
=
[]
for
assignment
in
context
.
getDestinationRelatedValueList
(
portal_type
=
"Assignment"
):
person
=
assignment
.
getParentValue
()
temp_object_list
.
append
(
newTempDocument
(
context
,
str
(
person
.
getId
()),
title
=
person
.
getTitle
(),
default_email_text
=
person
.
getDefaultEmailText
()
)
)
return
temp_object_list
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/Organisation_getAssociatedPersonList.xml
0 → 100644
View file @
7e382c9b
<?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>
**kw
</string>
</value>
</item>
<item>
<key>
<string>
_proxy_roles
</string>
</key>
<value>
<tuple>
<string>
Manager
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Organisation_getAssociatedPersonList
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment