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
Arnaud Véron
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
!408
parents
afda535e
ed97d47d
Changes
3
Hide 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.
from
Products.ERP5Type.Errors
import
UnsupportedWorkflowMethod
portal
=
context
.
getPortalObject
()
portal_preferences
=
portal
.
portal_preferences
reference
=
None
password
=
None
...
...
@@ -21,12 +17,6 @@ role_list = ['member', 'subscriber']
open_assignment_list
=
person
.
searchFolder
(
portal_type
=
"Assignment"
,
validation_state
=
"open"
)
# Initialisation
assignment_duration
=
portal_preferences
.
getPreferredCredentialAssignmentDuration
()
today
=
DateTime
()
delay
=
today
+
assignment_duration
current_assignment_list
=
{}
for
assignment
in
open_assignment_list
:
role
=
assignment
.
getRole
()
...
...
@@ -37,21 +27,23 @@ for assignment in open_assignment_list:
for
role
in
role_list
:
if
role
in
current_assignment_list
:
#
Update assignment
#
Update assignment (Reset stop/start dates)
for
assignment
in
current_assignment_list
[
role
]:
assignment
.
update
()
assignment
.
edit
(
stop_date
=
delay
)
assignment
.
open
()
if
assignment
.
getStartDate
()
is
None
or
\
assignment
.
getStopDate
()
is
None
:
assignment
.
update
()
assignment
.
edit
(
stop_date
=
None
,
start_date
=
None
)
assignment
.
open
(
comment
=
"Start and Stop reset by Subscription Request"
)
else
:
#Create assignment
#
Create assignment
assignment
=
person
.
newContent
(
portal_type
=
'Assignment'
,
title
=
'%s Assignment'
%
(
role
.
capitalize
()),
role
=
role
,
start_date
=
today
-
1
,
stop_date
=
delay
)
role
=
role
)
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'
])
\
if
x
.
getValidationState
()
==
'validated'
]
...
...
@@ -68,7 +60,7 @@ if not open_assignment_list and person.getUserId() == login_list[0].getReference
# Update password of the user
password
=
person
.
Person_generatePassword
()
login
.
setPassword
(
password
)
login
.
validate
()
login
.
validate
(
comment
=
"Updated by Subscription Request"
)
# Update Roles and Title
try
:
...
...
@@ -79,9 +71,9 @@ except UnsupportedWorkflowMethod:
person
.
edit
(
default_career_role_list
=
role_list
)
default_career
=
getattr
(
person
,
'default_career'
,
None
)
#Try to validate the default career
#
Try to validate the default career
try
:
default_career
.
start
()
default_career
.
start
(
comment
=
"Started by Subscription Request"
)
default_career
.
setStartDate
(
DateTime
())
except
UnsupportedWorkflowMethod
:
pass
...
...
master/bt5/slapos_subscription_request/TestTemplateItem/portal_components/test.erp5.testSlapOSSubscriptionSkins.py
View file @
0c25cfac
...
...
@@ -410,15 +410,10 @@ assert password""")
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
]
self
.
assertNotEqual
(
subscriber_role
.
getStartDate
(),
None
)
self
.
assertNotEqual
(
member_role
.
getStopDate
(),
None
)
self
.
assertNotEqual
(
subscriber_role
.
getStartDate
(),
None
)
self
.
assertNotEqual
(
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
)
self
.
assertEqual
(
subscriber_role
.
getStartDate
(),
None
)
self
.
assertEqual
(
member_role
.
getStopDate
(),
None
)
self
.
assertEqual
(
subscriber_role
.
getStartDate
(),
None
)
self
.
assertEqual
(
member_role
.
getStopDate
(),
None
)
login_list
=
person
.
searchFolder
(
portal_type
=
'ERP5 Login'
,
validation_state
=
"validated"
)
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 @@
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_recorded_property_dict
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
default_reference
</string>
</key>
<value>
<string>
testSlapOSSubscriptionSkins
</string>
</value>
...
...
@@ -55,28 +49,13 @@
<item>
<key>
<string>
workflow_history
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
M
=
</string>
</persistent>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
I
=
</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/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"3"
aka=
"AAAAAAAAAAM="
>
<pickle>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
...
...
@@ -89,7 +68,7 @@
<item>
<key>
<string>
component_validation_workflow
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
Q
=
</string>
</persistent>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
M
=
</string>
</persistent>
</value>
</item>
</dictionary>
...
...
@@ -98,7 +77,7 @@
</dictionary>
</pickle>
</record>
<record
id=
"
4"
aka=
"AAAAAAAAAAQ
="
>
<record
id=
"
3"
aka=
"AAAAAAAAAAM
="
>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.Workflow"
/>
</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