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
Cédric Le Ninivin
slapos.core
Commits
eb785c81
Commit
eb785c81
authored
Oct 08, 2018
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_subscription_request: Add alarm to bootstrap user and notify him.
parent
78bb5c00
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
421 additions
and
0 deletions
+421
-0
master/bt5/slapos_subscription_request/PathTemplateItem/portal_alarms/slapos_subscription_request_process_planned.xml
...al_alarms/slapos_subscription_request_process_planned.xml
+95
-0
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/Alarm_processPlannedSubscriptionRequest.py
...iption_request/Alarm_processPlannedSubscriptionRequest.py
+11
-0
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/Alarm_processPlannedSubscriptionRequest.xml
...ption_request/Alarm_processPlannedSubscriptionRequest.xml
+62
-0
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_boostrapUserAccount.py
...iption_request/SubscriptionRequest_boostrapUserAccount.py
+89
-0
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_boostrapUserAccount.xml
...ption_request/SubscriptionRequest_boostrapUserAccount.xml
+62
-0
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_sendAcceptedNotification.py
...n_request/SubscriptionRequest_sendAcceptedNotification.py
+40
-0
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_sendAcceptedNotification.xml
..._request/SubscriptionRequest_sendAcceptedNotification.xml
+62
-0
No files found.
master/bt5/slapos_subscription_request/PathTemplateItem/portal_alarms/slapos_subscription_request_process_planned.xml
0 → 100644
View file @
eb785c81
<?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_processPlannedSubscriptionRequest
</string>
</value>
</item>
<item>
<key>
<string>
automatic_solve
</string>
</key>
<value>
<int>
0
</int>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
enabled
</string>
</key>
<value>
<int>
1
</int>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
slapos_subscription_request_process_planned
</string>
</value>
</item>
<item>
<key>
<string>
periodicity_hour
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
periodicity_minute
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
periodicity_minute_frequency
</string>
</key>
<value>
<int>
10
</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>
1357002060.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>
title
</string>
</key>
<value>
<string>
Process Planned Subscription Requests
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/Alarm_processPlannedSubscriptionRequest.py
0 → 100644
View file @
eb785c81
from
DateTime
import
DateTime
portal
=
context
.
getPortalObject
()
portal
.
portal_catalog
.
searchAndActivate
(
portal_type
=
"Subscription Request"
,
simulation_state
=
"planned"
,
method_id
=
"SubscriptionRequest_boostrapUserAccount"
,
activity_kw
=
{
tag
:
tag
}
)
context
.
activate
(
after_tag
=
tag
).
getId
()
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/Alarm_processPlannedSubscriptionRequest.xml
0 → 100644
View file @
eb785c81
<?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>
tag, fixit, params
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Alarm_processPlannedSubscriptionRequest
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_boostrapUserAccount.py
0 → 100644
View file @
eb785c81
# Update update user information, by creating
# - creating one cloud contract
# Send an email for the user with a URL, so he can set the password.
# Create conpensation payment for future payment, and attach to the subscription request
# Person_findPartition must check if Subscription Request is on confirmed state to allocate.
from
Products.ERP5Type.Errors
import
UnsupportedWorkflowMethod
portal
=
context
.
getPortalObject
()
portal_preferences
=
context
.
portal_preferences
reference
=
None
password
=
None
person
=
context
.
getDestinationSectionValue
(
portal_type
=
"Person"
)
# Should come from subscription condition probably or preference
role_list
=
[
'member'
,
'subscriber'
]
open_assignment_list
=
person
.
searchFolder
(
portal_type
=
"Assignment"
,
validation_state
=
"open"
)
#Initialisation
assignment_duration
=
context
.
portal_preferences
.
getPreferredCredentialAssignmentDuration
()
today
=
DateTime
()
delay
=
today
+
assignment_duration
current_assignment_list
=
{}
for
assignment
in
open_assignment_list
:
role
=
assignment
.
getRole
()
if
role
in
current_assignment_list
:
current_assignment_list
[
role
].
append
(
assignment
)
else
:
current_assignment_list
[
role
]
=
[
assignment
]
for
role
in
role_list
:
if
role
in
current_assignment_list
:
#Update assignment
for
assignment
in
current_assignment_list
[
role
]:
assignment
.
update
()
assignment
.
edit
(
stop_date
=
delay
)
assignment
.
open
()
else
:
#Create assignment
assignment
=
person
.
newContent
(
portal_type
=
'Assignment'
,
title
=
'%s Assignment'
%
(
role
.
capitalize
()),
role
=
role
,
start_date
=
today
-
1
,
stop_date
=
delay
)
assignment
.
open
()
login_list
=
[
x
for
x
in
person
.
objectValues
(
portal_type
=
'ERP5 Login'
)
\
if
x
.
getValidationState
()
==
'validated'
]
if
not
login_list
:
raise
ValueError
(
'Something is wrong'
)
login
=
login_list
[
0
]
# Let's reset password if the user is his first login.
if
not
open_assignment_list
and
person
.
getUserId
()
==
login_list
[
0
].
getReference
():
login
.
invalidate
()
login
.
setReference
(
person
.
getDefaultEmailText
())
reference
=
person
.
getDefaultEmailText
()
# Update password of the user
password
=
person
.
Person_generatePassword
(
alpha
=
5
,
numeric
=
3
)
login
.
setPassword
(
password
)
login
.
validate
()
# Update Roles and Title
try
:
person
.
validate
()
except
UnsupportedWorkflowMethod
:
pass
person
.
edit
(
default_career_role_list
=
role_list
)
default_career
=
getattr
(
person
,
'default_career'
,
None
)
#Try to validate the default career
try
:
default_career
.
start
()
default_career
.
setStartDate
(
DateTime
())
except
UnsupportedWorkflowMethod
:
pass
context
.
activate
(
activity
=
'SQLQueue'
).
SubscriptionRequest_sendAcceptedNotification
(
reference
,
password
)
context
.
order
()
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_boostrapUserAccount.xml
0 → 100644
View file @
eb785c81
<?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>
id
</string>
</key>
<value>
<string>
SubscriptionRequest_boostrapUserAccount
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_sendAcceptedNotification.py
0 → 100644
View file @
eb785c81
portal
=
context
.
getPortalObject
()
recipient
=
context
.
getDestinationSectionValue
(
portal_type
=
"Person"
)
#Define the type of notification
notification_type
=
"without-password"
if
password
:
notification_type
=
"with-password"
#Get message from catalog
notification_reference
=
'subscription_request-confirmation-%s'
%
notification_type
notification_message
=
portal
.
portal_notifications
.
getDocumentValue
(
reference
=
notification_reference
,
language
=
recipient
.
getLanguage
())
if
notification_message
is
None
:
raise
ValueError
,
'Unable to found Notification Message with reference "%s".'
%
notification_reference
#Set notification mapping
notification_mapping_dict
=
{
'login_name'
:
reference
}
if
password
:
notification_mapping_dict
.
update
(
{
'login_password'
:
password
})
#Preserve HTML else convert to text
if
notification_message
.
getContentType
()
==
"text/html"
:
mail_text
=
notification_message
.
asEntireHTML
(
substitution_method_parameter_dict
=
{
'mapping_dict'
:
notification_mapping_dict
})
else
:
mail_text
=
notification_message
.
asText
(
substitution_method_parameter_dict
=
{
'mapping_dict'
:
notification_mapping_dict
})
#Send email
portal
.
portal_notifications
.
sendMessage
(
sender
=
None
,
recipient
=
recipient
,
subject
=
notification_message
.
getTitle
(),
message
=
mail_text
,
message_text_format
=
notification_message
.
getContentType
(),
notifier_list
=
(
portal
.
portal_preferences
.
getPreferredLoginAndPasswordNotifier
(),),
store_as_event
=
portal
.
portal_preferences
.
isPreferredStoreEvents
(),
event_keyword_argument_dict
=
{
'follow_up'
:
context
.
getRelativeUrl
()},
)
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_sendAcceptedNotification.xml
0 → 100644
View file @
eb785c81
<?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>
reference, password
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
SubscriptionRequest_sendAcceptedNotification
</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