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
0c25cfac
Commit
0c25cfac
authored
Jul 28, 2022
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Plain Diff
slapos_subscription_request: Set empty Start/Stop dates for assignments
See merge request
nexedi/slapos.core!408
parents
afda535e
ed97d47d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
55 deletions
+21
-55
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_boostrapUserAccount.py
...iption_request/SubscriptionRequest_boostrapUserAccount.py
+14
-22
master/bt5/slapos_subscription_request/TestTemplateItem/portal_components/test.erp5.testSlapOSSubscriptionSkins.py
...ortal_components/test.erp5.testSlapOSSubscriptionSkins.py
+4
-9
master/bt5/slapos_subscription_request/TestTemplateItem/portal_components/test.erp5.testSlapOSSubscriptionSkins.xml
...rtal_components/test.erp5.testSlapOSSubscriptionSkins.xml
+3
-24
No files found.
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_boostrapUserAccount.py
View file @
0c25cfac
# Send an email for the user with a URL, so he can set the password.
# Send an email for the user with a URL, so he can set the password.
from
Products.ERP5Type.Errors
import
UnsupportedWorkflowMethod
from
Products.ERP5Type.Errors
import
UnsupportedWorkflowMethod
portal
=
context
.
getPortalObject
()
portal_preferences
=
portal
.
portal_preferences
reference
=
None
reference
=
None
password
=
None
password
=
None
...
@@ -21,12 +17,6 @@ role_list = ['member', 'subscriber']
...
@@ -21,12 +17,6 @@ role_list = ['member', 'subscriber']
open_assignment_list
=
person
.
searchFolder
(
portal_type
=
"Assignment"
,
open_assignment_list
=
person
.
searchFolder
(
portal_type
=
"Assignment"
,
validation_state
=
"open"
)
validation_state
=
"open"
)
# Initialisation
assignment_duration
=
portal_preferences
.
getPreferredCredentialAssignmentDuration
()
today
=
DateTime
()
delay
=
today
+
assignment_duration
current_assignment_list
=
{}
current_assignment_list
=
{}
for
assignment
in
open_assignment_list
:
for
assignment
in
open_assignment_list
:
role
=
assignment
.
getRole
()
role
=
assignment
.
getRole
()
...
@@ -37,21 +27,23 @@ for assignment in open_assignment_list:
...
@@ -37,21 +27,23 @@ for assignment in open_assignment_list:
for
role
in
role_list
:
for
role
in
role_list
:
if
role
in
current_assignment_list
:
if
role
in
current_assignment_list
:
#
Update assignment
#
Update assignment (Reset stop/start dates)
for
assignment
in
current_assignment_list
[
role
]:
for
assignment
in
current_assignment_list
[
role
]:
if
assignment
.
getStartDate
()
is
None
or
\
assignment
.
getStopDate
()
is
None
:
assignment
.
update
()
assignment
.
update
()
assignment
.
edit
(
stop_date
=
delay
)
assignment
.
edit
(
stop_date
=
None
,
assignment
.
open
()
start_date
=
None
)
assignment
.
open
(
comment
=
"Start and Stop reset by Subscription Request"
)
else
:
else
:
#Create assignment
#
Create assignment
assignment
=
person
.
newContent
(
assignment
=
person
.
newContent
(
portal_type
=
'Assignment'
,
portal_type
=
'Assignment'
,
title
=
'%s Assignment'
%
(
role
.
capitalize
()),
title
=
'%s Assignment'
%
(
role
.
capitalize
()),
role
=
role
,
role
=
role
)
start_date
=
today
-
1
,
stop_date
=
delay
)
assignment
.
open
()
assignment
.
open
(
comment
=
"Created by Subscription Request"
)
login_list
=
[
x
for
x
in
person
.
objectValues
(
portal_type
=
[
'ERP5 Login'
,
'Google Login'
,
'Facebook Login'
])
\
login_list
=
[
x
for
x
in
person
.
objectValues
(
portal_type
=
[
'ERP5 Login'
,
'Google Login'
,
'Facebook Login'
])
\
if
x
.
getValidationState
()
==
'validated'
]
if
x
.
getValidationState
()
==
'validated'
]
...
@@ -68,7 +60,7 @@ if not open_assignment_list and person.getUserId() == login_list[0].getReference
...
@@ -68,7 +60,7 @@ if not open_assignment_list and person.getUserId() == login_list[0].getReference
# Update password of the user
# Update password of the user
password
=
person
.
Person_generatePassword
()
password
=
person
.
Person_generatePassword
()
login
.
setPassword
(
password
)
login
.
setPassword
(
password
)
login
.
validate
()
login
.
validate
(
comment
=
"Updated by Subscription Request"
)
# Update Roles and Title
# Update Roles and Title
try
:
try
:
...
@@ -79,9 +71,9 @@ except UnsupportedWorkflowMethod:
...
@@ -79,9 +71,9 @@ except UnsupportedWorkflowMethod:
person
.
edit
(
default_career_role_list
=
role_list
)
person
.
edit
(
default_career_role_list
=
role_list
)
default_career
=
getattr
(
person
,
'default_career'
,
None
)
default_career
=
getattr
(
person
,
'default_career'
,
None
)
#Try to validate the default career
#
Try to validate the default career
try
:
try
:
default_career
.
start
()
default_career
.
start
(
comment
=
"Started by Subscription Request"
)
default_career
.
setStartDate
(
DateTime
())
default_career
.
setStartDate
(
DateTime
())
except
UnsupportedWorkflowMethod
:
except
UnsupportedWorkflowMethod
:
pass
pass
...
...
master/bt5/slapos_subscription_request/TestTemplateItem/portal_components/test.erp5.testSlapOSSubscriptionSkins.py
View file @
0c25cfac
...
@@ -410,15 +410,10 @@ assert password""")
...
@@ -410,15 +410,10 @@ assert password""")
subscriber_role
=
[
i
for
i
in
open_assignment_list
if
i
.
getRole
()
==
'subscriber'
][
0
]
subscriber_role
=
[
i
for
i
in
open_assignment_list
if
i
.
getRole
()
==
'subscriber'
][
0
]
member_role
=
[
i
for
i
in
open_assignment_list
if
i
.
getRole
()
==
'member'
][
0
]
member_role
=
[
i
for
i
in
open_assignment_list
if
i
.
getRole
()
==
'member'
][
0
]
self
.
assertNotEqual
(
subscriber_role
.
getStartDate
(),
None
)
self
.
assertEqual
(
subscriber_role
.
getStartDate
(),
None
)
self
.
assertNotEqual
(
member_role
.
getStopDate
(),
None
)
self
.
assertEqual
(
member_role
.
getStopDate
(),
None
)
self
.
assertNotEqual
(
subscriber_role
.
getStartDate
(),
None
)
self
.
assertEqual
(
subscriber_role
.
getStartDate
(),
None
)
self
.
assertNotEqual
(
member_role
.
getStopDate
(),
None
)
self
.
assertEqual
(
member_role
.
getStopDate
(),
None
)
self
.
assertTrue
(
subscriber_role
.
getStartDate
()
<
DateTime
())
self
.
assertTrue
(
member_role
.
getStopDate
()
>
DateTime
()
+
365
*
5
)
self
.
assertTrue
(
subscriber_role
.
getStartDate
()
<
DateTime
())
self
.
assertTrue
(
member_role
.
getStopDate
()
>
DateTime
()
+
365
*
5
)
login_list
=
person
.
searchFolder
(
portal_type
=
'ERP5 Login'
,
validation_state
=
"validated"
)
login_list
=
person
.
searchFolder
(
portal_type
=
'ERP5 Login'
,
validation_state
=
"validated"
)
self
.
assertEqual
(
len
(
login_list
),
1
)
self
.
assertEqual
(
len
(
login_list
),
1
)
...
...
master/bt5/slapos_subscription_request/TestTemplateItem/portal_components/test.erp5.testSlapOSSubscriptionSkins.xml
View file @
0c25cfac
...
@@ -6,12 +6,6 @@
...
@@ -6,12 +6,6 @@
</pickle>
</pickle>
<pickle>
<pickle>
<dictionary>
<dictionary>
<item>
<key>
<string>
_recorded_property_dict
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
<item>
<item>
<key>
<string>
default_reference
</string>
</key>
<key>
<string>
default_reference
</string>
</key>
<value>
<string>
testSlapOSSubscriptionSkins
</string>
</value>
<value>
<string>
testSlapOSSubscriptionSkins
</string>
</value>
...
@@ -55,28 +49,13 @@
...
@@ -55,28 +49,13 @@
<item>
<item>
<key>
<string>
workflow_history
</string>
</key>
<key>
<string>
workflow_history
</string>
</key>
<value>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
M
=
</string>
</persistent>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
I
=
</string>
</persistent>
</value>
</value>
</item>
</item>
</dictionary>
</dictionary>
</pickle>
</pickle>
</record>
</record>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<pickle>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
data
</string>
</key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"3"
aka=
"AAAAAAAAAAM="
>
<pickle>
<pickle>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
</pickle>
...
@@ -89,7 +68,7 @@
...
@@ -89,7 +68,7 @@
<item>
<item>
<key>
<string>
component_validation_workflow
</string>
</key>
<key>
<string>
component_validation_workflow
</string>
</key>
<value>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
Q
=
</string>
</persistent>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
M
=
</string>
</persistent>
</value>
</value>
</item>
</item>
</dictionary>
</dictionary>
...
@@ -98,7 +77,7 @@
...
@@ -98,7 +77,7 @@
</dictionary>
</dictionary>
</pickle>
</pickle>
</record>
</record>
<record
id=
"
4"
aka=
"AAAAAAAAAAQ
="
>
<record
id=
"
3"
aka=
"AAAAAAAAAAM
="
>
<pickle>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.Workflow"
/>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.Workflow"
/>
</pickle>
</pickle>
...
...
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