Skip to content

Commit

Permalink
templates: add email templates
Browse files Browse the repository at this point in the history
  • Loading branch information
jrcastro2 authored and kpsherva committed May 31, 2024
1 parent 45ce44e commit 0123813
Show file tree
Hide file tree
Showing 22 changed files with 1,900 additions and 167 deletions.
Original file line number Diff line number Diff line change
@@ -1,76 +1,92 @@
{% set _invenio_request = notification.context.request %}
{% set _invenio_request_event = notification.context.request_event %}
{% set invenio_request = notification.context.request %}
{% set invenio_request_event = notification.context.request_event %}

{# created_by is either a resolved user or an email (for guests) #}
{% set event_creator_name = invenio_request_event.created_by.username or invenio_request_event.created_by %}
{% set request_id = invenio_request.id %}
{% set request_event_content = invenio_request_event.payload.content | safe %}
{% set request_title = invenio_request.title | safe %}
{% if recipient.data.profile %}
{% set recipient_full_name = recipient.data.profile.full_name | safe %}
{% else %}
{% set recipient_full_name = recipient.data.email | safe %}
{% endif %}
{% set help_url = config.CDS_SERVICE_ELEMENT_URL %}
{% set recipient_full_name = recipient.data.profile.full_name %}
{% set event_creator_full_name = _invenio_request_event.created_by.profile.full_name %}
{% set request_id = _invenio_request.id %}
{% set request_event_content = _invenio_request_event.payload.content | safe %}
{% set request_title = _invenio_request.title | safe %}

{# TODO: use request.links.self_html when issue issue is resolved: https://github.com/inveniosoftware/invenio-rdm-records/issues/1327 #}
{% set request_link = "{ui}/me/requests/{id}".format(
ui=config.SITE_UI_URL, id=request_id
)
%}

{%- block subject -%}
[CDS] New comment on "{{ request_title }}"
{%- endblock subject -%}

{% set account_settings_link = "{ui}/account/settings/notifications".format(
ui=config.SITE_UI_URL
)
%}

{%- block html_body -%}
<p>Dear {{ recipient_full_name }},</p>

<p>{{ event_creator_full_name }} commented on &quot;{{ request_title }}&quot;:</p>

{{ request_event_content }}

<p>You can access the request here: <a href="{{ request_link }}">{{ request_link }}</a></p>

Best regards,<br>
--<br>
CERN Document Server <a href="{{ config.SITE_UI_URL }}">{{ config.SITE_UI_URL }}</a><br>
Need help? <a href="{{ help_url }}">{{ help_url }}</a></p>
{%- block subject -%}
[CDS] {{ _("💬 New comment on '{request_title}'").format(request_title=request_title) }}
{%- endblock subject -%}

--<br>
<p style="font-size:smaller">This is an auto-generated message. To manage notifications, visit your <a href="{{account_settings_link}}">account settings</a>.</p>
{%- endblock html_body -%}
{%- block html_body -%}
<table style="font-family:'Lato',Helvetica,Arial,sans-serif;border-spacing:15px">
<tr>
<td>{{ _("Dear {recipient}").format(recipient=recipient_full_name) }},
</td>
</tr>
<tr>
<td>{{ _("'@{user_name}' commented on '{request_title}':").format(user_name=event_creator_name, request_title=request_title) }}</td>
</tr>
<tr>
<td><em>{{ request_event_content }}</em></td>
</tr>
<tr>
<td><a href="{{ request_link }}" class="button">{{ _("Check out the request")}}</a></td>
</tr>
<tr>
<td>
{{ _("Best regards") }},<br>
--<br>
CERN Document Server <a href="{{ config.SITE_UI_URL }}">{{ config.SITE_UI_URL }}</a><br>
{{ _("Need help?") }} <a href="{{ help_url }}">{{ help_url }}</a>
</td>
</tr>
<tr>
<td style="font-size:smaller">{{ _("This is an auto-generated message. To manage notifications, visit your")}} <a href="{{account_settings_link}}">{{ _("account settings")}}</a>.</td>
</tr>
</table>
{%- endblock html_body %}

{%- block plain_body -%}
Dear {{ recipient_full_name }},
{{ _("Dear {recipient}").format(recipient=recipient_full_name) }},

{{ event_creator_full_name }} commented on "{{ request_title }}":
{{ _("@{user_name} commented on '{request_title}'").format(user_name=event_creator_name, request_title=request_title) }}.

{{ request_event_content }}

You can access the request here: <{{ request_link }}>
{{ _("Check out the request: {request_link}".format(request_link=request_link)) }}

Best regards,
{{ _("Best regards") }},
--
CERN Document Server <{{ config.SITE_UI_URL }}>
Need help? <{{ help_url }}>
CERN Document Server {{ _("{site_url}").format(site_url=config.SITE_UI_URL) }}
{{ _("Need help? {help_url}".format(help_url=help_url)) }}

This is an auto-generated message. To manage notifications, visit your account settings <{{ account_settings_link }}>.
{{ _("This is an auto-generated message. To manage notifications, visit your account settings {account_settings_link}.".format(account_settings_link=account_settings_link))}}
{%- endblock plain_body %}

{# Markdown for Slack/Mattermost/chat #}
{%- block md_body -%}
Dear {{ recipient_full_name }},
{{ _("Dear {recipient}").format(recipient=recipient_full_name) }},

{{ event_creator_full_name }} commented on *{{ request_title }}*:
{{ _("*@{user_name}* commented on *{request_title}*").format(user_name=event_creator_name, request_title=request_title) }}.

{{ request_event_content }}

You can access the request here: <{{ request_link }}>
[{{ _("Check out the request") }}]({{ request_link }})

Best regards,
{{ _("Best regards") }},
--
CERN Document Server <{{ config.SITE_UI_URL }}>
Need help? <{{ help_url }}>
CERN Document Server {{ _("{site_url}").format(site_url=config.SITE_UI_URL) }}
{{ _("Need help? {help_url}".format(help_url=help_url)) }}

This is an auto-generated message. To manage notifications, visit your account settings <{{ account_settings_link }}>.
{{ _("This is an auto-generated message. To manage notifications, visit your account settings {account_settings_link}.".format(account_settings_link=account_settings_link))}}
{%- endblock md_body -%}
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
{% set invitation_request = notification.context.request %}
{% set receiver = invitation_request.receiver %}
{% set community = invitation_request.created_by %}
{% set request_id = invitation_request.id %}
{% set message = notification.context.message | safe if notification.context.message else '' %}
{% set community_title = community.metadata.title %}
{% set receiver_name = receiver.username or receiver.profile.full_name %}
{% set recipient_full_name = recipient.data.profile.full_name %}
{% set help_url = config.CDS_SERVICE_ELEMENT_URL %}

{# TODO: use request.links.self_html when issue issue is resolved: https://github.com/inveniosoftware/invenio-rdm-records/issues/1327 #}
{% set request_link = "{ui}/me/requests/{id}".format(
ui=config.SITE_UI_URL, id=request_id
)
%}
{% set account_settings_link = "{ui}/account/settings/notifications".format(
ui=config.SITE_UI_URL
)
%}

{%- block subject -%}
[CDS] {{ _("✅ @{user_name} accepted the invitation to join community '{community_title}'.").format(user_name=receiver_name, community_title=community_title) }}
{%- endblock subject -%}

{%- block html_body -%}

<table style="font-family:'Lato',Helvetica,Arial,sans-serif;border-spacing:15px">
<tr>
<td>{{ _("Dear {recipient}").format(recipient=recipient_full_name) }},
</td>
</tr>
<tr>
<td>{{ _("'@{user_name}' accepted the invitation to join your community '{community_title}'").format(user_name=receiver_name,community_title=community_title) }}
{% if message %}
{{ _(" with the following message:")}}
{% endif %}
</td>
</tr>
{% if message %}
<tr>
<td><em>"{{message}}"</em></td>
</tr>
{% endif %}
<tr>
<td><a href="{{ request_link }}" class="button">{{ _("Check out the invitation")}}</a></td>
</tr>
<tr>
<td>
{{ _("Best regards") }},<br>
--<br>
CERN Document Server <a href="{{ config.SITE_UI_URL }}">{{ config.SITE_UI_URL }}</a><br>
{{ _("Need help?") }} <a href="{{ help_url }}">{{ help_url }}</a>
</td>
</tr>
<tr>
<td style="font-size:smaller">{{ _("This is an auto-generated message. To manage notifications, visit your")}} <a href="{{account_settings_link}}">{{ _("account settings")}}</a>.</td>
</tr>
</table>
{%- endblock html_body %}

{%- block plain_body -%}
{{ _("Dear {recipient}").format(recipient=recipient_full_name) }},

{{ _("@{user_name} accepted the invitation to join your community '{community_title}'").format(user_name=receiver_name,community_title=community_title) }}
{% if message %}

{{ _("with the following message:")}}
{{message}}

{% endif %}
{{ _("Check out the invitation: {request_link}".format(request_link=request_link)) }}

{{ _("Best regards") }},
--
CERN Document Server {{ _("<{site_url}>").format(site_url=config.SITE_UI_URL) }}
{{ _("Need help? <{help_url}>".format(help_url=help_url)) }}

{{ _("This is an auto-generated message. To manage notifications, visit your account settings {account_settings_link}.".format(account_settings_link=account_settings_link))}}
{%- endblock plain_body %}

{# Markdown for Slack/Mattermost/chat #}
{%- block md_body -%}
{{ _("Dear {recipient}").format(recipient=recipient_full_name) }},

{{ _("@{user_name} accepted the invitation to join your community '{community_title}'").format(user_name=receiver_name,community_title=community_title) }}
{% if message %}

{{ _("with the following message:")}}
{{message}}

{% endif %}
{{ _("Check out the invitation: {request_link}".format(request_link=request_link)) }}

{{ _("Best regards") }},
--
CERN Document Server {{ _("<{site_url}>").format(site_url=config.SITE_UI_URL) }}
{{ _("Need help? <{help_url}>".format(help_url=help_url)) }}

{{ _("This is an auto-generated message. To manage notifications, visit your account settings {account_settings_link}.".format(account_settings_link=account_settings_link))}}
{%- endblock md_body %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
{% set invitation_request = notification.context.request %}
{% set receiver = invitation_request.receiver %}
{% set community = invitation_request.created_by %}
{% set request_id = invitation_request.id %}
{% set message = notification.context.message | safe if notification.context.message else '' %}
{% set community_title = community.metadata.title %}
{% set receiver_name = receiver.username or receiver.profile.full_name %}
{% set recipient_full_name = recipient.data.profile.full_name %}
{% set help_url = config.CDS_SERVICE_ELEMENT_URL %}

{# TODO: use request.links.self_html when issue issue is resolved: https://github.com/inveniosoftware/invenio-rdm-records/issues/1327 #}
{% set request_link = "{ui}/me/requests/{id}".format(
ui=config.SITE_UI_URL, id=request_id
)
%}
{% set account_settings_link = "{ui}/account/settings/notifications".format(
ui=config.SITE_UI_URL
)
%}

{%- block subject -%}
[CDS] {{ _("❌ Community member invitation cancelled for @{user_name}").format(user_name=receiver_name) }}
{%- endblock subject -%}

{%- block html_body -%}
<table style="font-family:'Lato',Helvetica,Arial,sans-serif;border-spacing:15px">
<tr>
<td>{{ _("Dear {recipient}").format(recipient=recipient_full_name) }},
</td>
</tr>
<tr>
<td>{{ _("The invitation for '@{user_name}' to join community '{community_title}' was cancelled").format(user_name=receiver_name,community_title=community_title) }}
{% if message %}
{{ _(" with the following message:")}}
{% endif %}
</td>
</tr>
{% if message %}
<tr>
<td><em>"{{message}}"</em></td>
</tr>
{% endif %}
<tr>
<td><a href="{{ request_link }}" class="button">{{ _("Check out the invitation")}}</a></td>
</tr>
<tr>
<td>
{{ _("Best regards") }},<br>
--<br>
CERN Document Server <a href="{{ config.SITE_UI_URL }}">{{ config.SITE_UI_URL }}</a><br>
{{ _("Need help?") }} <a href="{{ help_url }}">{{ help_url }}</a>
</td>
</tr>
<tr>
<td style="font-size:smaller">{{ _("This is an auto-generated message. To manage notifications, visit your")}} <a href="{{account_settings_link}}">{{ _("account settings")}}</a>.</td>
</tr>
</table>
{%- endblock html_body %}

{%- block plain_body -%}
{{ _("Dear {recipient}").format(recipient=recipient_full_name) }},

{{ _("The invitation for @{user_name} to join your community '{community_title}' was cancelled").format(user_name=receiver_name,community_title=community_title) }}
{% if message %}

{{ _("with the following message:")}}
{{message}}

{% endif %}
{{ _("Check out the invitation: {request_link}".format(request_link=request_link)) }}

{{ _("Best regards") }},
--
CERN Document Server {{ _("<{site_url}>").format(site_url=config.SITE_UI_URL) }}
{{ _("Need help? <{help_url}>".format(help_url=help_url)) }}

{{ _("This is an auto-generated message. To manage notifications, visit your account settings {account_settings_link}.".format(account_settings_link=account_settings_link))}}
{%- endblock plain_body %}

{# Markdown for Slack/Mattermost/chat #}
{%- block md_body -%}
{{ _("Dear {recipient}").format(recipient=recipient_full_name) }},

{{ _("The invitation for *@{user_name}* to join your community *'{community_title}'* was cancelled").format(user_name=receiver_name,community_title=community_title) }}
{% if message %}

{{ _("with the following message:")}}
{{message}}

{% endif %}
{{ _("Check out the invitation: {request_link}".format(request_link=request_link)) }}

{{ _("Best regards") }},
--
CERN Document Server {{ _("<{site_url}>").format(site_url=config.SITE_UI_URL) }}
{{ _("Need help? <{help_url}>".format(help_url=help_url)) }}

{{ _("This is an auto-generated message. To manage notifications, visit your account settings {account_settings_link}.".format(account_settings_link=account_settings_link))}}
{%- endblock md_body %}
Loading

0 comments on commit 0123813

Please sign in to comment.