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
Ophélie Gagnard
slapos.core
Commits
27cabb78
Commit
27cabb78
authored
May 12, 2014
by
Alain Takoudjou
Committed by
Rafael Monnerat
Jul 10, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Alarm for check and change wrong allocation scope on public and friend computer
parent
141b611d
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
1030 additions
and
179 deletions
+1030
-179
master/bt5/slapos_cloud/TestTemplateItem/testSlapOSComputerAllocationScope.py
...oud/TestTemplateItem/testSlapOSComputerAllocationScope.py
+0
-118
master/bt5/slapos_crm/PathTemplateItem/portal_alarms/slapos_crm_check_update_allocation_scope.xml
...ortal_alarms/slapos_crm_check_update_allocation_scope.xml
+889
-0
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/Alarm_checkAndUpdateComputerAllocationScope.xml
...lapos_crm/Alarm_checkAndUpdateComputerAllocationScope.xml
+0
-0
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/Base_generateSupportRequestForSlapOS.xml
...skins/slapos_crm/Base_generateSupportRequestForSlapOS.xml
+4
-5
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/Computer_checkAndUpdateAllocationScope.xml
...ins/slapos_crm/Computer_checkAndUpdateAllocationScope.xml
+41
-44
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/ERP5Site_isSupportRequestCreationClosed.xml
...ns/slapos_crm/ERP5Site_isSupportRequestCreationClosed.xml
+10
-7
master/bt5/slapos_crm/TestTemplateItem/testSlapOSCRMSupportRequestGeneration.py
...TestTemplateItem/testSlapOSCRMSupportRequestGeneration.py
+86
-5
No files found.
master/bt5/slapos_cloud/TestTemplateItem/testSlapOSComputerAllocationScope.py
deleted
100644 → 0
View file @
141b611d
# Copyright (c) 2012 Nexedi SA and Contributors. All Rights Reserved.
from
Products.SlapOS.tests.testSlapOSMixin
import
testSlapOSMixin
from
AccessControl
import
getSecurityManager
from
DateTime
import
DateTime
import
transaction
class
TestAllocationScope
(
testSlapOSMixin
):
def
afterSetUp
(
self
):
super
(
TestAllocationScope
,
self
).
afterSetUp
()
self
.
user_id
=
getSecurityManager
().
getUser
().
getId
()
def
beforeTearDown
(
self
):
transaction
.
abort
()
def
generateNewId
(
self
):
return
self
.
getPortalObject
().
portal_ids
.
generateNewId
(
id_group
=
(
'slapos_core_test'
))
def
test_GroupCompany
(
self
):
computer
=
self
.
portal
.
computer_module
.
newContent
(
portal_type
=
'Computer'
)
computer
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
computer
,
[
'G-COMPANY'
,
self
.
user_id
],
False
)
self
.
assertRoles
(
computer
,
'G-COMPANY'
,
[
'Assignor'
])
self
.
assertRoles
(
computer
,
self
.
user_id
,
[
'Owner'
])
def
test_ComputerAgent
(
self
):
reference
=
'TESTPERSON-%s'
%
self
.
generateNewId
()
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
,
reference
=
reference
)
computer
=
self
.
portal
.
computer_module
.
newContent
(
portal_type
=
'Computer'
,
source_administration
=
person
.
getRelativeUrl
())
computer
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
computer
,
[
self
.
user_id
,
'G-COMPANY'
,
reference
],
False
)
self
.
assertRoles
(
computer
,
reference
,
[
'Assignee'
])
self
.
assertRoles
(
computer
,
self
.
user_id
,
[
'Owner'
])
def
test_NotAllowedAllocationScope
(
self
):
reference
=
'TESTPERSON-%s'
%
self
.
generateNewId
()
computer_ref
=
'TESTCOMP-%s'
%
self
.
generateNewId
()
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
,
reference
=
reference
)
assignment
=
person
.
newContent
(
portal_type
=
'Assignment'
)
assignment
.
setRole
(
'role/member'
)
assignment
.
setStartDate
(
DateTime
())
assignment
.
open
()
assignment
.
updateLocalRolesOnSecurityGroups
()
computer
=
self
.
portal
.
computer_module
.
newContent
(
portal_type
=
'Computer'
,
source_administration
=
person
.
getRelativeUrl
(),
reference
=
computer_ref
)
# open/public
computer
.
edit
(
allocation_scope
=
'open/public'
)
computer
.
updateLocalRolesOnSecurityGroups
()
computer
.
Computer_checkAndUpdateAllocationScope
()
self
.
assertEquals
(
computer
.
getAllocationScope
(),
'open/personal'
)
# open/personal
computer
.
edit
(
allocation_scope
=
'open/personal'
,
source_administration
=
person
.
getRelativeUrl
()
)
computer
.
updateLocalRolesOnSecurityGroups
()
computer
.
Computer_checkAndUpdateAllocationScope
()
self
.
assertEquals
(
computer
.
getAllocationScope
(),
'open/personal'
)
# open/friend
friend_reference
=
'TESTPERSON-%s'
%
self
.
generateNewId
()
friend_person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
,
reference
=
friend_reference
)
computer
.
edit
(
allocation_scope
=
'open/friend'
,
destination_section
=
friend_person
.
getRelativeUrl
()
)
computer
.
updateLocalRolesOnSecurityGroups
()
computer
.
Computer_checkAndUpdateAllocationScope
()
self
.
assertEquals
(
computer
.
getAllocationScope
(),
'open/personal'
)
def
test_AllowedAllocationScope
(
self
):
# Test computer allocation scope with 'service_provider' user assignment
reference
=
'TESTPERSON-%s'
%
self
.
generateNewId
()
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
,
reference
=
reference
)
assignment
=
person
.
newContent
(
portal_type
=
'Assignment'
)
assignment
.
setRole
(
'role/service_provider'
)
assignment
.
setStartDate
(
DateTime
())
assignment
.
open
()
assignment
.
updateLocalRolesOnSecurityGroups
()
computer
=
self
.
portal
.
computer_module
.
newContent
(
portal_type
=
'Computer'
,
source_administration
=
person
.
getRelativeUrl
())
# open/public
computer
.
edit
(
allocation_scope
=
'open/public'
)
computer
.
updateLocalRolesOnSecurityGroups
()
computer
.
Computer_checkAndUpdateAllocationScope
()
self
.
assertEquals
(
computer
.
getAllocationScope
(),
'open/public'
)
# open/personal
computer
.
edit
(
allocation_scope
=
'open/personal'
,
source_administration
=
person
.
getRelativeUrl
()
)
computer
.
updateLocalRolesOnSecurityGroups
()
computer
.
Computer_checkAndUpdateAllocationScope
()
self
.
assertEquals
(
computer
.
getAllocationScope
(),
'open/personal'
)
# open/friend
friend_reference
=
'TESTPERSON-%s'
%
self
.
generateNewId
()
friend_person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
,
reference
=
friend_reference
)
computer
.
edit
(
allocation_scope
=
'open/friend'
,
destination_section
=
friend_person
.
getRelativeUrl
()
)
computer
.
updateLocalRolesOnSecurityGroups
()
computer
.
Computer_checkAndUpdateAllocationScope
()
self
.
assertEquals
(
computer
.
getAllocationScope
(),
'open/friend'
)
\ No newline at end of file
master/bt5/slapos_crm/PathTemplateItem/portal_alarms/slapos_crm_check_update_allocation_scope.xml
0 → 100644
View file @
27cabb78
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Alarm"
module=
"erp5.portal_type"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
active_sense_method_id
</string>
</key>
<value>
<string>
Alarm_checkAndUpdateComputerAllocationScope
</string>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<string>
Automatically turn allocation scope of public and friend computer to personnal if the owner is not a service provider.
</string>
</value>
</item>
<item>
<key>
<string>
enabled
</string>
</key>
<value>
<int>
0
</int>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
slapos_crm_check_update_allocation_scope
</string>
</value>
</item>
<item>
<key>
<string>
periodicity_hour
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
periodicity_minute
</string>
</key>
<value>
<tuple>
<int>
5
</int>
</tuple>
</value>
</item>
<item>
<key>
<string>
periodicity_minute_frequency
</string>
</key>
<value>
<int>
1
</int>
</value>
</item>
<item>
<key>
<string>
periodicity_month
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
periodicity_month_day
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
periodicity_start_date
</string>
</key>
<value>
<object>
<klass>
<global
name=
"DateTime"
module=
"DateTime.DateTime"
/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>
1399420800.0
</float>
<string>
GMT
</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
periodicity_week
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Alarm
</string>
</value>
</item>
<item>
<key>
<string>
sense_method_id
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string>
Check and Update Computer Allocation Scope
</string>
</value>
</item>
<item>
<key>
<string>
workflow_history
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<pickle>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
data
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
edit_workflow
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAM=
</string>
</persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"3"
aka=
"AAAAAAAAAAM="
>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.patches.WorkflowTool"
/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string>
edit
</string>
</value>
</item>
<item>
<key>
<string>
actor
</string>
</key>
<value>
<string>
zope
</string>
</value>
</item>
<item>
<key>
<string>
comment
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
error_message
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
0.0.0.0
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
<value>
<string>
current
</string>
</value>
</item>
<item>
<key>
<string>
time
</string>
</key>
<value>
<object>
<klass>
<global
id=
"3.1"
name=
"DateTime"
module=
"DateTime.DateTime"
/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>
1399462323.31
</float>
<string>
GMT+2
</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string>
edit
</string>
</value>
</item>
<item>
<key>
<string>
actor
</string>
</key>
<value>
<string>
zope
</string>
</value>
</item>
<item>
<key>
<string>
comment
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAQ=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
error_message
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
0.0.0.0
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
<value>
<string>
current
</string>
</value>
</item>
<item>
<key>
<string>
time
</string>
</key>
<value>
<object>
<klass>
<reference
id=
"3.1"
/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>
1399462323.32
</float>
<string>
GMT+2
</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string>
edit
</string>
</value>
</item>
<item>
<key>
<string>
actor
</string>
</key>
<value>
<string>
zope
</string>
</value>
</item>
<item>
<key>
<string>
comment
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
error_message
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
934.44788.3677.10376
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
<value>
<string>
current
</string>
</value>
</item>
<item>
<key>
<string>
time
</string>
</key>
<value>
<object>
<klass>
<reference
id=
"3.1"
/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>
1399462420.07
</float>
<string>
GMT+2
</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string>
edit
</string>
</value>
</item>
<item>
<key>
<string>
actor
</string>
</key>
<value>
<string>
zope
</string>
</value>
</item>
<item>
<key>
<string>
comment
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
error_message
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
934.44789.43824.24388
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
<value>
<string>
current
</string>
</value>
</item>
<item>
<key>
<string>
time
</string>
</key>
<value>
<object>
<klass>
<reference
id=
"3.1"
/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>
1399462482.4
</float>
<string>
GMT+2
</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string>
edit
</string>
</value>
</item>
<item>
<key>
<string>
actor
</string>
</key>
<value>
<string>
zope
</string>
</value>
</item>
<item>
<key>
<string>
comment
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
error_message
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
934.44790.46367.11861
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
<value>
<string>
current
</string>
</value>
</item>
<item>
<key>
<string>
time
</string>
</key>
<value>
<object>
<klass>
<reference
id=
"3.1"
/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>
1399462539.9
</float>
<string>
GMT+2
</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string>
edit
</string>
</value>
</item>
<item>
<key>
<string>
actor
</string>
</key>
<value>
<string>
zope
</string>
</value>
</item>
<item>
<key>
<string>
comment
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
error_message
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
934.44791.43645.47974
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
<value>
<string>
current
</string>
</value>
</item>
<item>
<key>
<string>
time
</string>
</key>
<value>
<object>
<klass>
<reference
id=
"3.1"
/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>
1399464797.44
</float>
<string>
GMT+2
</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string>
edit
</string>
</value>
</item>
<item>
<key>
<string>
actor
</string>
</key>
<value>
<string>
zope
</string>
</value>
</item>
<item>
<key>
<string>
comment
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
error_message
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
934.44829.19063.19336
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
<value>
<string>
current
</string>
</value>
</item>
<item>
<key>
<string>
time
</string>
</key>
<value>
<object>
<klass>
<reference
id=
"3.1"
/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>
1399464833.05
</float>
<string>
GMT+2
</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string>
edit
</string>
</value>
</item>
<item>
<key>
<string>
actor
</string>
</key>
<value>
<string>
zope
</string>
</value>
</item>
<item>
<key>
<string>
comment
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
error_message
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
934.44829.58001.59016
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
<value>
<string>
current
</string>
</value>
</item>
<item>
<key>
<string>
time
</string>
</key>
<value>
<object>
<klass>
<reference
id=
"3.1"
/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>
1399464906.01
</float>
<string>
GMT+2
</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string>
edit
</string>
</value>
</item>
<item>
<key>
<string>
actor
</string>
</key>
<value>
<string>
zope
</string>
</value>
</item>
<item>
<key>
<string>
comment
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
error_message
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
934.44831.6626.1211
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
<value>
<string>
current
</string>
</value>
</item>
<item>
<key>
<string>
time
</string>
</key>
<value>
<object>
<klass>
<reference
id=
"3.1"
/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>
1399466320.91
</float>
<string>
GMT+2
</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string>
edit
</string>
</value>
</item>
<item>
<key>
<string>
actor
</string>
</key>
<value>
<string>
zope
</string>
</value>
</item>
<item>
<key>
<string>
comment
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
error_message
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
934.44854.44737.26641
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
<value>
<string>
current
</string>
</value>
</item>
<item>
<key>
<string>
time
</string>
</key>
<value>
<object>
<klass>
<reference
id=
"3.1"
/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>
1399469708.7
</float>
<string>
GMT+2
</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string>
edit
</string>
</value>
</item>
<item>
<key>
<string>
actor
</string>
</key>
<value>
<string>
zope
</string>
</value>
</item>
<item>
<key>
<string>
comment
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
error_message
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
934.44911.9592.42786
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
<value>
<string>
current
</string>
</value>
</item>
<item>
<key>
<string>
time
</string>
</key>
<value>
<object>
<klass>
<reference
id=
"3.1"
/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>
1399470895.07
</float>
<string>
GMT+2
</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string>
edit
</string>
</value>
</item>
<item>
<key>
<string>
actor
</string>
</key>
<value>
<string>
zope
</string>
</value>
</item>
<item>
<key>
<string>
comment
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
error_message
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
934.44930.60217.7662
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
<value>
<string>
current
</string>
</value>
</item>
<item>
<key>
<string>
time
</string>
</key>
<value>
<object>
<klass>
<reference
id=
"3.1"
/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>
1399470936.19
</float>
<string>
GMT+2
</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string>
edit
</string>
</value>
</item>
<item>
<key>
<string>
actor
</string>
</key>
<value>
<string>
zope
</string>
</value>
</item>
<item>
<key>
<string>
comment
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
error_message
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
934.44931.39577.42188
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
<value>
<string>
current
</string>
</value>
</item>
<item>
<key>
<string>
time
</string>
</key>
<value>
<object>
<klass>
<reference
id=
"3.1"
/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>
1399470941.46
</float>
<string>
GMT+2
</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string>
edit
</string>
</value>
</item>
<item>
<key>
<string>
actor
</string>
</key>
<value>
<string>
zope
</string>
</value>
</item>
<item>
<key>
<string>
comment
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
error_message
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
934.44931.39577.42188
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
<value>
<string>
current
</string>
</value>
</item>
<item>
<key>
<string>
time
</string>
</key>
<value>
<object>
<klass>
<reference
id=
"3.1"
/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>
1400070577.23
</float>
<string>
GMT+2
</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string>
edit
</string>
</value>
</item>
<item>
<key>
<string>
actor
</string>
</key>
<value>
<string>
zope
</string>
</value>
</item>
<item>
<key>
<string>
comment
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
error_message
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
934.54925.40679.37085
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
<value>
<string>
current
</string>
</value>
</item>
<item>
<key>
<string>
time
</string>
</key>
<value>
<object>
<klass>
<reference
id=
"3.1"
/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>
1400168314.37
</float>
<string>
GMT+2
</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string>
edit
</string>
</value>
</item>
<item>
<key>
<string>
actor
</string>
</key>
<value>
<string>
zope
</string>
</value>
</item>
<item>
<key>
<string>
comment
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
error_message
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
934.56554.37603.12185
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
<value>
<string>
current
</string>
</value>
</item>
<item>
<key>
<string>
time
</string>
</key>
<value>
<object>
<klass>
<reference
id=
"3.1"
/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>
1400168344.77
</float>
<string>
GMT+2
</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
<record
id=
"4"
aka=
"AAAAAAAAAAQ="
>
<pickle>
<global
name=
"Message"
module=
"Products.ERP5Type.Message"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
default
</string>
</key>
<value>
<string>
Object copied from ${source_item}
</string>
</value>
</item>
<item>
<key>
<string>
domain
</string>
</key>
<value>
<string>
erp5_ui
</string>
</value>
</item>
<item>
<key>
<string>
mapping
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
source_item
</string>
</key>
<value>
<string>
/erp5/portal_alarms/slapos_free_computer_partition
</string>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key>
<string>
message
</string>
</key>
<value>
<string>
Object copied from ${source_item}
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_c
loud/SkinTemplateItem/portal_skins/slapos_cloud
/Alarm_checkAndUpdateComputerAllocationScope.xml
→
master/bt5/slapos_c
rm/SkinTemplateItem/portal_skins/slapos_crm
/Alarm_checkAndUpdateComputerAllocationScope.xml
View file @
27cabb78
File moved
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/Base_generateSupportRequestForSlapOS.xml
View file @
27cabb78
...
...
@@ -53,11 +53,6 @@
<value>
<string>
from DateTime import DateTime\n
\n
portal = context.getPortalObject()\n
\n
if portal.ERP5Site_isSupportRequestCreationClosed():\n
# Stop ticket creation\n
return\n
\n
source_project_value = portal.restrictedTraverse(source_relative_url)\n
\n
if source_project_value.getPortalType() == "Computer":\n
...
...
@@ -67,6 +62,10 @@ elif source_project_value.getPortalType() == "Software Instance":\n
else:\n
destination_decision = None\n
\n
if portal.ERP5Site_isSupportRequestCreationClosed(destination_decision):\n
# Stop ticket creation\n
return\n
\n
support_request_in_progress = portal.portal_catalog.getResultValue(\n
portal_type = \'Support Request\',\n
title = title,\n
...
...
master/bt5/slapos_c
loud/SkinTemplateItem/portal_skins/slapos_cloud
/Computer_checkAndUpdateAllocationScope.xml
→
master/bt5/slapos_c
rm/SkinTemplateItem/portal_skins/slapos_crm
/Computer_checkAndUpdateAllocationScope.xml
View file @
27cabb78
...
...
@@ -57,6 +57,7 @@ from DateTime import DateTime\n
computer = context\n
portal = context.getPortalObject()\n
allocation_scope = computer.getAllocationScope()\n
computer_reference = computer.getReference()\n
\n
if allocation_scope != \'open/public\' and \\\n
allocation_scope != \'open/friend\':\n
...
...
@@ -66,7 +67,6 @@ is_service_provider = False\n
person = computer.getSourceAdministrationValue(portal_type="Person")\n
\n
for assignment in person.contentValues(portal_type="Assignment"):\n
assignment = assignment.getObject()\n
if assignment.getRole() == \'service_provider\':\n
is_service_provider = True\n
break\n
...
...
@@ -75,67 +75,64 @@ if not is_service_provider:\n
#Turn this computer allocation scope to \'open/personal\'\n
edit_kw = {\n
\'allocation_scope\': \'open/personal\',\n
\'subject_list\': [\'\'],\n
\'destination_section_value\': person,\n
} \n
}\n
computer.edit(**edit_kw)\n
\n
# Create a ticket (or re-open it) for this issue!\n
ticket_title = \'Allocation scope has been changed for %s\' % computer.\\\n
getReference()\n
message = """Dear user,\n
\n
Your computer %s with ID %s was configured with allocation scope \'%s\', but you are\n
not allowed to turn computer to \'public\' or \'friend\' state because you are not a service provider.\n
The computer allocation scope has been changed to \'open/personal\'. Please contact us for more informations.\n
\n
Regards,\n
\n
SlapOS Team\n
""" % (computer.getTitle(), computer.getReference(),\n
allocation_scope)\n
request_title = \'Allocation scope has been changed for %s\' % computer_reference\n
request_description = \'Allocation scope has been changed back to \' \\\n
\'open/personal for %s\' % computer_reference\n
message_title = \'We have changed allocation scope for %s\' % computer_reference\n
notification_reference = \'slapos-crm-computer_allocation_scope.notification\'\n
notification_message = portal.portal_notifications.getDocumentValue(\n
reference=notification_reference)\n
ressource = portal.service_module.slapos_crm_information.getRelativeUrl()\n
mapping_dict = {\'computer_title\':computer.getTitle(),\n
\'computer_id\':computer_reference,\n
\'allocation_scope\':allocation_scope}\n
message = notification_message.asText(\n
substitution_method_parameter_dict={\'mapping_dict\':mapping_dict})\n
\n
support_request_in_progress = portal.portal_catalog.getResultValue(\n
portal_type = \'Support Request\',\n
title = ticket_title,\n
simulation_state = ["validated","submitted","suspended"],\n
source_project_uid = computer.getUid()\n
support_request_url = context.Base_generateSupportRequestForSlapOS(\n
request_title,\n
request_description,\n
computer.getRelativeUrl()\n
)\n
if support_request_in_progress is None:\n
support_request = portal.support_request_module.\\\n
slapos_crm_support_request_template.\\\n
Base_createCloneDocument(batch_mode=1)\n
support_request.edit(\n
title = ticket_title,\n
resource = ressource,\n
description = ticket_title,\n
start_date = DateTime(),\n
destination_decision=computer.getSourceAdministration(),\n
source_project_value = computer.getRelativeUrl()\n
)\n
support_request.validate()\n
if support_request_url:\n
support_request = portal.restrictedTraverse(support_request_url)\n
support_request.suspend()\n
else:\n
support_request = support_request_in_progress.getObject()\n
# XXX - Base_generateSupportRequestForSlapOS return None if the \n
# support_request already exist, but we want to use it again so...\n
support_request = portal.portal_catalog.getResultValue(\n
portal_type = \'Support Request\',\n
title = request_title,\n
simulation_state = \'suspended\',\n
source_project_uid = computer.getUid()\n
)\n
if support_request is None:\n
# Existing ticket not found, can not create event for the moment\n
return\n
support_request_url = support_request.getRelativeUrl()\n
\n
# create Web message if needed for this ticket\n
event_list = context.portal_catalog(follow_up_uid=support_request.getUid(), \n
last_event = context.portal_catalog.getResultValue(\n
follow_up_uid=support_request.getUid(), \n
sort_on=[(\'delivery.start_date\', \'DESC\')],\n
)\n
if l
en(event_list) >
0
and \\\n
(
event_list[0].getStartDate() - DateTim
e()
< 1
):\n
#
User
has
already
been
notified
this
day
.\n
if l
ast_event
and \\\n
(
DateTime() - last_event.getStartDat
e() < 1):\n
# User has already been notified this
last 24h
.\n
return\n
event = portal.event_module.slapos_crm_web_message_template.\\\n
Base_createCloneDocument(batch_mode=1)\n
event.edit(\n
title=
\'We
have
changed
allocation
scope
for
%s\'
%
computer.getReference()
,\n
title=
message_title
,\n
text_content=message,\n
start_date = DateTime(),\n
resource = ressource,\n
source=person.getRelativeUrl(),\n
follow_up=
support_request
.getRelativeUrl()
,\n
follow_up=support_request
_url
,\n
)\n
event.stop()\n
event.deliver()\n
...
...
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/ERP5Site_isSupportRequestCreationClosed.xml
View file @
27cabb78
...
...
@@ -51,20 +51,23 @@
<item>
<key>
<string>
_body
</string>
</key>
<value>
<string>
# HARDCODED LIMIT TO BE MOVED TO GLOBAL PREFERENCES\n
limit =
3
\n
limit =
5
\n
\n
support_request_list = context.portal_catalog(\n
portal_type = \'Support Request\',\n
simulation_state = ["validated","submitted", "suspended"],\n
limit=limit\n
)\n
kw[\'limit\'] = limit\n
kw[\'portal_type\'] = \'Support Request\'\n
kw[\'simulation_state\'] = ["validated","submitted", "suspended"]\n
if destination_decision:\n
kw[\'default_destination_decision_uid\'] = context.restrictedTraverse(\n
destination_decision).getUid()\n
\n
support_request_list = context.portal_catalog(**kw)\n
\n
return len(support_request_list) == limit\n
</string>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string></string>
</value>
<value>
<string>
destination_decision=None, **kw
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
...
...
master/bt5/slapos_crm/TestTemplateItem/testSlapOSCRMSupportRequestGeneration.py
View file @
27cabb78
...
...
@@ -46,8 +46,30 @@ class TestSlapOSCloudSupportRequestGeneration(testSlapOSMixin):
title
=
"Test Support Request %"
,
simulation_state
=
"validated"
):
support_request
.
invalidate
()
for
support_request
in
self
.
portal
.
portal_catalog
(
portal_type
=
"Support Request"
,
title
=
"Allocation scope has been changed for TESTCOMPT%"
,
simulation_state
=
"suspended"
):
support_request
.
invalidate
()
self
.
tic
()
def
_updatePersonAssignment
(
self
,
person
,
role
=
'role/member'
):
for
assignment
in
person
.
contentValues
(
portal_type
=
"Assignment"
):
assignment
.
cancel
()
assignment
=
person
.
newContent
(
portal_type
=
'Assignment'
)
assignment
.
setRole
(
role
)
assignment
.
setStartDate
(
DateTime
())
assignment
.
open
()
return
assignment
def
_makePerson
(
self
,
new_id
):
# Clone computer document
person
=
self
.
portal
.
person_module
.
template_member
\
.
Base_createCloneDocument
(
batch_mode
=
1
)
person
.
edit
(
reference
=
'TESTPERSON-%s'
%
(
new_id
,
))
person
.
immediateReindexObject
()
return
person
def
_makeComputer
(
self
,
new_id
):
# Clone computer document
person
=
self
.
portal
.
person_module
.
template_member
\
...
...
@@ -184,21 +206,35 @@ class TestSlapOSCloudSupportRequestGeneration(testSlapOSMixin):
def
test_ERP5Site_isSupportRequestCreationClosed
(
self
):
person
=
self
.
_makePerson
(
self
.
new_id
)
other_person
=
self
.
_makePerson
(
'other-%s'
%
self
.
new_id
)
url
=
person
.
getRelativeUrl
()
self
.
assertFalse
(
self
.
portal
.
ERP5Site_isSupportRequestCreationClosed
(
url
))
self
.
assertFalse
(
self
.
portal
.
ERP5Site_isSupportRequestCreationClosed
())
def
newSupportRequest
():
sr
=
self
.
portal
.
support_request_module
.
newContent
(
\
title
=
"Test Support Request POIUY"
)
title
=
"Test Support Request POIUY"
,
destination_decision
=
url
)
sr
.
validate
()
sr
.
immediateReindexObject
()
newSupportRequest
()
self
.
assertFalse
(
self
.
portal
.
ERP5Site_isSupportRequestCreationClosed
())
self
.
assertFalse
(
self
.
portal
.
ERP5Site_isSupportRequestCreationClosed
(
url
))
newSupportRequest
()
self
.
assertFalse
(
self
.
portal
.
ERP5Site_isSupportRequestCreationClosed
())
self
.
assertFalse
(
self
.
portal
.
ERP5Site_isSupportRequestCreationClosed
(
url
))
newSupportRequest
()
self
.
assertFalse
(
self
.
portal
.
ERP5Site_isSupportRequestCreationClosed
(
url
))
newSupportRequest
()
self
.
assertFalse
(
self
.
portal
.
ERP5Site_isSupportRequestCreationClosed
(
url
))
newSupportRequest
()
self
.
assertTrue
(
self
.
portal
.
ERP5Site_isSupportRequestCreationClosed
(
url
))
self
.
assertTrue
(
self
.
portal
.
ERP5Site_isSupportRequestCreationClosed
())
self
.
assertFalse
(
self
.
portal
.
ERP5Site_isSupportRequestCreationClosed
(
other_person
.
getRelativeUrl
()))
def
test_Base_generateSupportRequestForSlapOS_recreate_if_closed
(
self
):
title
=
"Test Support Request %s"
%
self
.
new_id
computer
=
self
.
_makeComputer
(
self
.
new_id
)
...
...
@@ -656,3 +692,48 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
self
.
assertEqual
(
'Visited by SoftwareRelease_testForAllocation'
,
software_release
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
def
test_Alarm_notAllowedAllocationScope
(
self
):
computer
=
self
.
_makeComputer
(
self
.
new_id
)
person
=
computer
.
getSourceAdministrationValue
()
self
.
_updatePersonAssignment
(
person
,
'role/member'
)
computer
.
edit
(
allocation_scope
=
'open/public'
)
self
.
portal
.
portal_alarms
.
slapos_check_update_allocation_scope
.
activeSense
()
self
.
tic
()
self
.
assertEquals
(
computer
.
getAllocationScope
(),
'open/personal'
)
computer
.
edit
(
allocation_scope
=
'open/personal'
)
self
.
portal
.
portal_alarms
.
slapos_check_update_allocation_scope
.
activeSense
()
self
.
tic
()
self
.
assertEquals
(
computer
.
getAllocationScope
(),
'open/personal'
)
friend_person
=
self
.
_makePerson
(
self
.
new_id
)
computer
.
edit
(
allocation_scope
=
'open/friend'
,
destination_section
=
friend_person
.
getRelativeUrl
())
self
.
portal
.
portal_alarms
.
slapos_check_update_allocation_scope
.
activeSense
()
self
.
tic
()
self
.
assertEquals
(
computer
.
getAllocationScope
(),
'open/personal'
)
def
test_Alarm_allowedAllocationScope
(
self
):
computer
=
self
.
_makeComputer
(
self
.
new_id
)
person
=
computer
.
getSourceAdministrationValue
()
self
.
_updatePersonAssignment
(
person
,
'role/service_provider'
)
computer
.
edit
(
allocation_scope
=
'open/public'
)
self
.
portal
.
portal_alarms
.
slapos_check_update_allocation_scope
.
activeSense
()
self
.
tic
()
self
.
assertEquals
(
computer
.
getAllocationScope
(),
'open/public'
)
computer
.
edit
(
allocation_scope
=
'open/personal'
)
self
.
portal
.
portal_alarms
.
slapos_check_update_allocation_scope
.
activeSense
()
self
.
tic
()
self
.
assertEquals
(
computer
.
getAllocationScope
(),
'open/personal'
)
friend_person
=
self
.
_makePerson
(
self
.
new_id
)
computer
.
edit
(
allocation_scope
=
'open/friend'
,
destination_section
=
friend_person
.
getRelativeUrl
())
self
.
portal
.
portal_alarms
.
slapos_check_update_allocation_scope
.
activeSense
()
self
.
tic
()
self
.
assertEquals
(
computer
.
getAllocationScope
(),
'open/friend'
)
\ No newline at end of file
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