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
246d37c8
Commit
246d37c8
authored
Feb 21, 2017
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_trial: Send and store Mail Messages when it is sent.
parent
a31fd79b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
137 additions
and
60 deletions
+137
-60
master/bt5/slapos_trial_request/SkinTemplateItem/portal_skins/slapos_trial/TrialRequest_processDestroy.py
.../portal_skins/slapos_trial/TrialRequest_processDestroy.py
+22
-10
master/bt5/slapos_trial_request/SkinTemplateItem/portal_skins/slapos_trial/TrialRequest_processNotify.py
...m/portal_skins/slapos_trial/TrialRequest_processNotify.py
+9
-50
master/bt5/slapos_trial_request/SkinTemplateItem/portal_skins/slapos_trial/TrialRequest_sendMailMessage.py
...portal_skins/slapos_trial/TrialRequest_sendMailMessage.py
+44
-0
master/bt5/slapos_trial_request/SkinTemplateItem/portal_skins/slapos_trial/TrialRequest_sendMailMessage.xml
...ortal_skins/slapos_trial/TrialRequest_sendMailMessage.xml
+62
-0
No files found.
master/bt5/slapos_trial_request/SkinTemplateItem/portal_skins/slapos_trial/TrialRequest_processDestroy.py
View file @
246d37c8
...
...
@@ -4,9 +4,8 @@ person = portal.portal_catalog.getResultValue(
portal_type
=
"Person"
,
reference
=
"free_trial_user"
)
if
context
.
getStopDate
()
>=
DateTime
():
return
return
if
person
is
None
:
return
...
...
@@ -18,21 +17,34 @@ if context.getValidationState() != "validated":
return
state
=
"destroyed"
shared
=
False
hosting_subscription
=
context
.
getSpecialiseValue
()
request_kw
=
{}
request_kw
.
update
(
software_release
=
context
.
getUrlString
(),
software_title
=
context
.
getTitle
(),
software_type
=
"RootSoftwareInstance"
,
instance_xml
=
context
.
getTextContent
(),
software_release
=
hosting_subscription
.
getUrlString
(),
software_title
=
hosting_subscription
.
getTitle
(),
software_type
=
hosting_subscription
.
getSourceReference
()
,
instance_xml
=
hosting_subscription
.
getTextContent
(),
sla_xml
=
""
,
shared
=
shared
,
shared
=
hosting_subscription
.
getRootSlave
()
,
state
=
state
,
)
person
.
requestSoftwareInstance
(
**
request_kw
)
context
.
invalidate
()
return
connection_dict
=
hosting_subscription
.
getPredecessorValue
().
getConnectionXmlAsDict
()
connection_key_list
=
context
.
getSubjectList
()
connection_string
=
'
\
n
'
.
join
([
'%s: %s'
%
(
x
,
y
)
for
x
,
y
in
connection_dict
.
items
()
if
x
in
connection_key_list
])
mapping_dict
=
{
"token"
:
connection_string
}
context
.
TrialRequest_sendMailMessage
(
person
,
context
.
getDefaultEmailText
(),
'slapos-free.trial.destroy'
,
mapping_dict
)
context
.
invalidate
()
master/bt5/slapos_trial_request/SkinTemplateItem/portal_skins/slapos_trial/TrialRequest_processNotify.py
View file @
246d37c8
...
...
@@ -10,18 +10,13 @@ if person is None:
return
"Free Trial Person not Found"
connection_key_list
=
context
.
getSubjectList
()
instance
=
context
.
getAggregateValue
()
email
=
context
.
getDefaultEmailText
()
connection_dict
=
instance
.
getConnectionXmlAsDict
()
state
=
instance
.
getSlapState
()
if
context
.
getValidationState
()
in
[
"validated"
,
"invalidated"
]:
return
"Already Valid Skip"
return
if
state
!=
"destroy_requested"
:
if
instance
.
getSlapState
()
!=
"destroy_requested"
:
connection_dict
=
instance
.
getConnectionXmlAsDict
()
if
connection_dict
:
if
len
([
x
for
x
,
y
in
connection_dict
.
items
()
if
x
in
connection_key_list
])
!=
len
(
connection_key_list
):
...
...
@@ -31,50 +26,14 @@ if state != "destroy_requested":
if
x
in
connection_key_list
and
y
in
[
'None'
,
None
,
'http://'
,
''
]:
return
"key %s has invalid value %s"
%
(
x
,
y
)
connection_string
=
'
\
n
'
.
join
([
'%s: %s'
%
(
x
,
y
)
for
x
,
y
in
connection_dict
.
items
()
if
x
in
connection_key_list
])
notification_message_reference
=
'slapos-free.trial.token'
notification_message
=
portal
.
portal_notifications
.
getDocumentValue
(
reference
=
notification_message_reference
)
subject
=
notification_message
.
getTitle
()
connection_string
=
'
\
n
'
.
join
(
[
'%s: %s'
%
(
x
,
y
)
for
x
,
y
in
connection_dict
.
items
()
if
x
in
connection_key_list
])
mapping_dict
=
{
"token"
:
connection_string
}
message
=
message
=
notification_message
.
asText
(
substitution_method_parameter_dict
=
{
'mapping_dict'
:
mapping_dict
})
person_title
=
"%s FREE TRIAL"
%
email
free_trial_destination
=
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
"Person"
,
title
=
person_title
,
reference
=
None
)
if
free_trial_destination
is
None
:
free_trial_destination
=
portal
.
person_module
.
newContent
(
portal_type
=
"Person"
,
title
=
person_title
)
free_trial_destination
.
setDefaultEmailText
(
email
)
event
=
portal
.
event_module
.
newContent
(
portal_type
=
"Mail Message"
,
start_date
=
DateTime
(),
destination
=
free_trial_destination
.
getRelativeUrl
(),
follow_up
=
context
.
getRelativeUrl
(),
source
=
person
.
getRelativeUrl
(),
title
=
subject
,
resource
=
"service_module/slapos_crm_information"
,
text_content
=
message
,
)
portal
.
portal_workflow
.
doActionFor
(
event
,
'start_action'
,
send_mail
=
True
)
event
.
stop
()
event
.
deliver
()
event
.
reindexObject
()
context
.
TrialRequest_sendMailMessage
(
person
,
context
.
getDefaultEmailText
(),
'slapos-free.trial.token'
,
mapping_dict
)
context
.
validate
()
master/bt5/slapos_trial_request/SkinTemplateItem/portal_skins/slapos_trial/TrialRequest_sendMailMessage.py
0 → 100644
View file @
246d37c8
portal
=
context
.
getPortalObject
()
notification_message
=
portal
.
portal_notifications
.
getDocumentValue
(
reference
=
notification_message_reference
)
subject
=
notification_message
.
getTitle
()
message
=
notification_message
.
asText
(
substitution_method_parameter_dict
=
{
'mapping_dict'
:
mapping_dict
})
person_title
=
"%s FREE TRIAL"
%
email
free_trial_destination
=
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
"Person"
,
title
=
person_title
,
reference
=
None
)
if
free_trial_destination
is
None
:
free_trial_destination
=
portal
.
person_module
.
newContent
(
portal_type
=
"Person"
,
title
=
person_title
)
free_trial_destination
.
setDefaultEmailText
(
email
)
event
=
portal
.
event_module
.
newContent
(
portal_type
=
"Mail Message"
,
start_date
=
DateTime
(),
destination
=
free_trial_destination
.
getRelativeUrl
(),
follow_up
=
context
.
getRelativeUrl
(),
source
=
sender
.
getRelativeUrl
(),
title
=
subject
,
resource
=
"service_module/slapos_crm_information"
,
text_content
=
message
,
)
portal
.
portal_workflow
.
doActionFor
(
event
,
'start_action'
,
send_mail
=
True
)
event
.
stop
()
event
.
deliver
()
event
.
reindexObject
()
return
event
master/bt5/slapos_trial_request/SkinTemplateItem/portal_skins/slapos_trial/TrialRequest_sendMailMessage.xml
0 → 100644
View file @
246d37c8
<?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>
sender, email, notification_message_reference, mapping_dict
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
TrialRequest_sendMailMessage
</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