Commit 5718ebfc authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_crm: Include name and proper language on Notification

    On  Regularisation Requests context.
parent 777dc230
...@@ -63,22 +63,36 @@ if int(outstanding_amount) > 0: ...@@ -63,22 +63,36 @@ if int(outstanding_amount) > 0:
ticket.reindexObject(activate_kw={'tag': tag}) ticket.reindexObject(activate_kw={'tag': tag})
# Notify using user's language
language = context.getLanguage("en")
notification_message = context.getPortalObject().portal_notifications.getDocumentValue( notification_message = context.getPortalObject().portal_notifications.getDocumentValue(
reference="slapos-crm.create.regularisation.request") reference="slapos-crm.create.regularisation.request",
language=language)
if notification_message is None: if notification_message is None:
subject = 'Invoice payment requested' subject = 'Invoice payment requested'
body = """Dear user, body = """Dear %s,
A new invoice has been generated. A new invoice has been generated.
You can access it in your invoice section at %s. You can access it in your invoice section at %s.
Regards, Regards,
The slapos team The slapos team
""" % portal.portal_preferences.getPreferredSlaposWebSiteUrl() """ % (context.getTitle(), portal.portal_preferences.getPreferredSlaposWebSiteUrl())
else: else:
notification_mapping_dict = {
'user_name': context.getTitle()}
subject = notification_message.getTitle() subject = notification_message.getTitle()
body = notification_message.convert(format='text')[1]
# Preserve HTML else convert to text
if notification_message.getContentType() == "text/html":
body = notification_message.asEntireHTML(
substitution_method_parameter_dict={'mapping_dict':notification_mapping_dict})
else:
body = notification_message.asText(
substitution_method_parameter_dict={'mapping_dict':notification_mapping_dict})
mail_message = ticket.RegularisationRequest_checkToSendUniqEvent( mail_message = ticket.RegularisationRequest_checkToSendUniqEvent(
portal.portal_preferences.getPreferredRegularisationRequestResource(), portal.portal_preferences.getPreferredRegularisationRequestResource(),
......
...@@ -2,7 +2,15 @@ from zExceptions import Unauthorized ...@@ -2,7 +2,15 @@ from zExceptions import Unauthorized
if REQUEST is not None: if REQUEST is not None:
raise Unauthorized raise Unauthorized
notification_message = context.getPortalObject().portal_notifications.getDocumentValue(reference="slapos-crm.acknowledgment.escalation") portal = context.getPortalObject()
language = "en"
recipient = context.getDestinationSectionValue()
if recipient is not None:
language = recipient.getLanguage("en")
notification_message = portal.portal_notifications.getDocumentValue(
language=language, reference="slapos-crm.acknowledgment.escalation")
if notification_message is None: if notification_message is None:
subject = 'Reminder: invoice payment requested' subject = 'Reminder: invoice payment requested'
body = """Dear user, body = """Dear user,
...@@ -15,8 +23,18 @@ The slapos team ...@@ -15,8 +23,18 @@ The slapos team
""" % context.getPortalObject().portal_preferences.getPreferredSlaposWebSiteUrl() """ % context.getPortalObject().portal_preferences.getPreferredSlaposWebSiteUrl()
else: else:
notification_mapping_dict = {
'user_name': context.getDestinationSectionTitle()}
subject = notification_message.getTitle() subject = notification_message.getTitle()
body = notification_message.convert(format='text')[1]
# Preserve HTML else convert to text
if notification_message.getContentType() == "text/html":
body = notification_message.asEntireHTML(
substitution_method_parameter_dict={'mapping_dict':notification_mapping_dict})
else:
body = notification_message.asText(
substitution_method_parameter_dict={'mapping_dict':notification_mapping_dict})
return context.RegularisationRequest_checkToTriggerNextEscalationStep( return context.RegularisationRequest_checkToTriggerNextEscalationStep(
delay_period_in_days=15, delay_period_in_days=15,
......
...@@ -2,7 +2,15 @@ from zExceptions import Unauthorized ...@@ -2,7 +2,15 @@ from zExceptions import Unauthorized
if REQUEST is not None: if REQUEST is not None:
raise Unauthorized raise Unauthorized
notification_message = context.getPortalObject().portal_notifications.getDocumentValue(reference="slapos-crm.delete.reminder.escalation") portal = context.getPortalObject()
language = "en"
recipient = context.getDestinationSectionValue()
if recipient is not None:
language = recipient.getLanguage("en")
notification_message = portal.portal_notifications.getDocumentValue(
language=language, reference="slapos-crm.delete.reminder.escalation")
if notification_message is None: if notification_message is None:
subject = 'Acknowledgment: instances deleted' subject = 'Acknowledgment: instances deleted'
body = """Dear user, body = """Dear user,
...@@ -14,8 +22,18 @@ Regards, ...@@ -14,8 +22,18 @@ Regards,
The slapos team The slapos team
""" % context.getPortalObject().portal_preferences.getPreferredSlaposWebSiteUrl() """ % context.getPortalObject().portal_preferences.getPreferredSlaposWebSiteUrl()
else: else:
notification_mapping_dict = {
'user_name': context.getDestinationSectionTitle()}
subject = notification_message.getTitle() subject = notification_message.getTitle()
body = notification_message.convert(format='text')[1]
# Preserve HTML else convert to text
if notification_message.getContentType() == "text/html":
body = notification_message.asEntireHTML(
substitution_method_parameter_dict={'mapping_dict':notification_mapping_dict})
else:
body = notification_message.asText(
substitution_method_parameter_dict={'mapping_dict':notification_mapping_dict})
return context.RegularisationRequest_checkToTriggerNextEscalationStep( return context.RegularisationRequest_checkToTriggerNextEscalationStep(
delay_period_in_days=10, delay_period_in_days=10,
......
...@@ -2,7 +2,15 @@ from zExceptions import Unauthorized ...@@ -2,7 +2,15 @@ from zExceptions import Unauthorized
if REQUEST is not None: if REQUEST is not None:
raise Unauthorized raise Unauthorized
notification_message = context.getPortalObject().portal_notifications.getDocumentValue(reference="slapos-crm.stop.acknowledgment.escalation") portal = context.getPortalObject()
language = "en"
recipient = context.getDestinationSectionValue()
if recipient is not None:
language = recipient.getLanguage("en")
notification_message = portal.portal_notifications.getDocumentValue(
language=language, reference="slapos-crm.stop.acknowledgment.escalation")
if notification_message is None: if notification_message is None:
subject = 'Last reminder: invoice payment requested' subject = 'Last reminder: invoice payment requested'
body = """Dear user, body = """Dear user,
...@@ -14,8 +22,18 @@ Regards, ...@@ -14,8 +22,18 @@ Regards,
The slapos team The slapos team
""" % context.getPortalObject().portal_preferences.getPreferredSlaposWebSiteUrl() """ % context.getPortalObject().portal_preferences.getPreferredSlaposWebSiteUrl()
else: else:
notification_mapping_dict = {
'user_name': context.getDestinationSectionTitle()}
subject = notification_message.getTitle() subject = notification_message.getTitle()
body = notification_message.convert(format='text')[1]
# Preserve HTML else convert to text
if notification_message.getContentType() == "text/html":
body = notification_message.asEntireHTML(
substitution_method_parameter_dict={'mapping_dict':notification_mapping_dict})
else:
body = notification_message.asText(
substitution_method_parameter_dict={'mapping_dict':notification_mapping_dict})
return context.RegularisationRequest_checkToTriggerNextEscalationStep( return context.RegularisationRequest_checkToTriggerNextEscalationStep(
delay_period_in_days=7, delay_period_in_days=7,
......
...@@ -2,7 +2,15 @@ from zExceptions import Unauthorized ...@@ -2,7 +2,15 @@ from zExceptions import Unauthorized
if REQUEST is not None: if REQUEST is not None:
raise Unauthorized raise Unauthorized
notification_message = context.getPortalObject().portal_notifications.getDocumentValue(reference="slapos-crm.stop.reminder.escalation") portal = context.getPortalObject()
language = "en"
recipient = context.getDestinationSectionValue()
if recipient is not None:
language = recipient.getLanguage("en")
notification_message = portal.portal_notifications.getDocumentValue(
language=language, reference="slapos-crm.stop.reminder.escalation")
if notification_message is None: if notification_message is None:
subject = 'Acknowledgment: instances stopped' subject = 'Acknowledgment: instances stopped'
body = """Dear user, body = """Dear user,
...@@ -14,8 +22,18 @@ Regards, ...@@ -14,8 +22,18 @@ Regards,
The slapos team The slapos team
""" % context.getPortalObject().portal_preferences.getPreferredSlaposWebSiteUrl() """ % context.getPortalObject().portal_preferences.getPreferredSlaposWebSiteUrl()
else: else:
notification_mapping_dict = {
'user_name': context.getDestinationSectionTitle()}
subject = notification_message.getTitle() subject = notification_message.getTitle()
body = notification_message.convert(format='text')[1]
# Preserve HTML else convert to text
if notification_message.getContentType() == "text/html":
body = notification_message.asEntireHTML(
substitution_method_parameter_dict={'mapping_dict':notification_mapping_dict})
else:
body = notification_message.asText(
substitution_method_parameter_dict={'mapping_dict':notification_mapping_dict})
return context.RegularisationRequest_checkToTriggerNextEscalationStep( return context.RegularisationRequest_checkToTriggerNextEscalationStep(
delay_period_in_days=7, delay_period_in_days=7,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment