Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Email templates #1783

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5c5dc7e
Email notification templates draft
anishTP Apr 25, 2023
01daacc
macro for hero image wip
anishTP Apr 26, 2023
b24db1e
Implemented macro for header image, button and footer
anishTP Apr 27, 2023
cd252c5
Implemented macros across all templates
anishTP Apr 28, 2023
0b2eaac
Changes to update template and macro. Bug fix to layout template for …
anishTP May 3, 2023
b69c310
removed redundant code
anishTP May 3, 2023
e7bb6eb
Modified the main layout template and added new attributes to view
anishTP May 4, 2023
12b5676
Merge branch 'main' into email-templates
jace May 11, 2023
dd678f9
Translation markup should be for static text, not for variable insertion
jace May 11, 2023
83c0fc2
Removed trans tags from dynamic content
anishTP May 12, 2023
fb19792
Merge branch 'main' into email-templates
jace May 23, 2023
db873e5
Merge branch 'main' into email-templates
vidya-ram May 25, 2023
abd20d4
Fixed minor bugs in the code
anishTP May 25, 2023
3173252
Merge branch 'email-templates' of https://github.com/hasgeek/funnel i…
anishTP May 25, 2023
f190125
removed redundant comments
anishTP May 25, 2023
1050975
Added button macro to account verify and account reset templates
anishTP May 26, 2023
4387c9b
Merge branch 'main' into email-templates
jace May 28, 2023
2162087
Merge branch 'main' into email-templates
jace Jun 12, 2023
096e958
Merge branch 'main' into email-templates
jace Jun 21, 2023
da688bd
Merge branch 'main' into email-templates
jace Jun 21, 2023
2a474f7
Email template bug fixes
anishTP Jun 22, 2023
e221815
Merge branch 'main' into email-templates
jace Jun 22, 2023
ee97f22
Update email template footer
jace Jun 22, 2023
1195935
Merge branch 'main' into email-templates
jace Jun 23, 2023
e31a31f
Fix for image rendering in dark mode, OTP email layout and update/com…
anishTP Jun 26, 2023
d38b833
Update update_notification.py
anishTP Jun 26, 2023
5aa8181
View for triggering project published notification
anishTP Jul 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions funnel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from email.utils import parseaddr

import geoip2.database
import phonenumbers
from flask import Flask
from flask_babel import get_locale
from flask_executor import Executor
Expand Down Expand Up @@ -120,6 +121,10 @@
each_app.config['MAIL_DEFAULT_SENDER_ADDR'] = parseaddr(
app.config['MAIL_DEFAULT_SENDER']
)[1]
each_app.config['SITE_SUPPORT_PHONE_FORMATTED'] = phonenumbers.format_number(
phonenumbers.parse(each_app.config['SITE_SUPPORT_PHONE']),
phonenumbers.PhoneNumberFormat.INTERNATIONAL,
)
proxies.init_app(each_app)
manifest.init_app(each_app)
db.init_app(each_app)
Expand Down
17 changes: 17 additions & 0 deletions funnel/models/notification_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
'RegistrationCancellationNotification',
'RegistrationConfirmationNotification',
'ProjectStartingNotification',
'ProjectPublishedNotification',
'OrganizationAdminMembershipNotification',
'OrganizationAdminMembershipRevokedNotification',
]
Expand Down Expand Up @@ -154,6 +155,22 @@ class ProjectStartingNotification(
# This is a notification triggered without an actor


class ProjectPublishedNotification(
DocumentHasProfile, Notification, type='project_published'
):
"""Notifications of a newly published project."""

category = notification_categories.participant
title = __("When a project is published")
description = __(
"Notifies all members of a profile when a new project is published"
)

document_model = Project
roles = ['project_crew', 'project_participant', 'account_participant']
exclude_actor = False # Send to everyone including the actor


# --- Comment notifications ------------------------------------------------------------


Expand Down
42 changes: 29 additions & 13 deletions funnel/templates/email_account_reset.html.jinja2
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
{% extends "notifications/layout_email.html.jinja2" %}
{% block content -%}

<p>{% trans %}Hello {{ fullname }},{% endtrans %}</p>

<p>{% trans %}You – or someone claiming to be you – asked for your password to be reset. This OTP is valid for 15 minutes.{% endtrans %}</p>

<p><big>{% trans %}OTP:{% endtrans %} <strong>{{ otp }}</strong></big></p>

<p>{% trans %}You can also use this link:{% endtrans %}</p>

<p class="btn-bar"><a class="btn" href="{{ url }}">{% trans %}Reset your password{% endtrans %}</a></p>

<p>{% trans %}If you did not ask for this, you may safely ignore this email.{% endtrans %}</p>
{%- from "notifications/macros_email.html.jinja2" import cta_button -%}

{% block content -%}
<tr>
<td align="center"><br>
<p class="otp"><b>{{ otp }}</b></p>
<br>
<p>{% trans %}You – or someone claiming to be you – asked for your password to be reset. This OTP is valid for 15 minutes.{% endtrans %}</p>
</td>
</tr>
<br>
<tr>
<td align="center">
<p>{% trans %}You can also use this link:{% endtrans %}</p>
</td>
</tr>
{# Button : BEGIN #}
{{ cta_button(url, gettext("Reset your password") )}}
{# Button : END #}
<tr>
<td class="spacer-16px"></td>
</tr>
<tr>
<td class="line-separator"></td>
</tr>
<tr>
<td class="footer-text footer-align">
<p>{% trans %}If you did not ask for this, you may safely ignore this email.{% endtrans %}</p>
</td>
</tr>
{%- endblock content %}
28 changes: 21 additions & 7 deletions funnel/templates/email_account_verify.html.jinja2
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
{% extends "notifications/layout_email.html.jinja2" %}
{% block content -%}

<p>{% trans %}Hello {{ fullname }},{% endtrans %}</p>

<p class="btn-bar"><a class="btn" href="{{ url }}">{% trans %}Confirm your email address{% endtrans %}</a></p>

<p>{% trans %}If you did not ask for this, you may safely ignore this email.{% endtrans %}</p>
{%- from "notifications/macros_email.html.jinja2" import cta_button -%}

{% block content -%}
<tr>
<td align="center">
<p>{% trans %}Hello {{ fullname }}{% endtrans %}</p><br>
</td>
</tr>
{# Button : BEGIN #}
{{ cta_button(url, gettext("Confirm your email address") )}}
{# Button : END #}
<tr>
<td class="spacer-16px"></td>
</tr>
<tr>
<td class="line-separator"></td>
</tr>
<tr>
<td class="footer-text footer-align">
<p>{% trans %}If you did not ask for this, you may safely ignore this email.{% endtrans %}</p>
</td>
</tr>
{%- endblock %}
26 changes: 15 additions & 11 deletions funnel/templates/email_login_otp.html.jinja2
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
{% extends "notifications/layout_email.html.jinja2" %}
{% block content -%}

{%- if fullname %}
<p>{% trans %}Hello {{ fullname }},{% endtrans %}</p>
{%- else %}
<p>{% trans %}Hello!{% endtrans %}</p>
{%- endif %}
<p>{% trans %}This login OTP is valid for 15 minutes.{% endtrans %}</p>

<p><big>{% trans %}OTP:{% endtrans %} <strong>{{ otp }}</strong></big></p>

<p>{% trans %}If you did not ask for this, you may safely ignore this email.{% endtrans %}</p>

<tr>
<td><br>
<p class="otp"><b>{{ otp }}</b></p>
<br>
<p align="center">{% trans %}This login OTP is valid for 15 minutes.{% endtrans %}</p>
</td>
</tr>
<tr>
<td class="line-separator"></td>
</tr>
<tr>
<td>
<p class="footer-text footer-align">{% trans %}If you did not ask for this, you may safely ignore this email.{% endtrans %}</p>
</td>
</tr>
{%- endblock %}
14 changes: 7 additions & 7 deletions funnel/templates/email_sudo_otp.html.jinja2
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{% extends "notifications/layout_email.html.jinja2" %}
{% block content -%}

<p>{% trans %}Hello {{ fullname }},{% endtrans %}</p>

<p>{% trans %}You are about to perform a critical action. This OTP serves as your confirmation to proceed and is valid for 15 minutes.{% endtrans %}</p>

<p><big>{% trans %}OTP:{% endtrans %} <strong>{{ otp }}</strong></big></p>

<tr>
<td><br>
<p class="otp"><b>{{ otp }}</b></p>
<br>
<p align="center">{% trans %}You are about to perform a critical action. This OTP serves as your confirmation to proceed and is valid for 15 minutes.{% endtrans %}</p>
</td>
</tr>
{%- endblock %}
35 changes: 23 additions & 12 deletions funnel/templates/notifications/comment_received_email.html.jinja2
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
{%- extends "notifications/layout_email.html.jinja2" -%}
{%- from "notifications/macros_email.html.jinja2" import cta_button -%}
{%- block content -%}

{%- if view.notification.document_type == 'project' -%}
<h2><a href="{{ view.document.url_for(_external=true, **view.tracking_tags()) }}">{{ view.document.joined_title }}</a></h2>
{%- elif view.notification.document_type == 'proposal' -%}
<h2><a href="{{ view.document.url_for(_external=true, **view.tracking_tags()) }}">{{ view.document.title }}</a></h2>
{%- elif view.notification.document_type == 'comment' -%}
<p>{% trans %}You wrote:{% endtrans %}</p>
<blockquote type="cite">{{ view.document.message }}</blockquote>
{%- endif %}
<tr align="center">
<td class="text-content">
{%- if view.notification.document_type == 'project' -%}
<h3><a href="{{ view.document.url_for(_external=true, **view.tracking_tags()) }}">{{ view.document.joined_title }}</a></h3>
{%- elif view.notification.document_type == 'proposal' -%}
<h3><a href="{{ view.document.url_for(_external=true, **view.tracking_tags()) }}">{{ view.document.title }}</a></h3>
{%- elif view.notification.document_type == 'comment' -%}
<p>{% trans %}You wrote:{% endtrans %}</p>
<blockquote type="cite">{{ view.document.message }}</blockquote>
{%- endif %}

<p>{{ view.activity_html() }}</p>
<p>{{ view.activity_html() }}</p>
</td>
</tr>
<tr>
<td align="left">
<blockquote type="cite">{{ view.comment.message }}</blockquote>
</td>
</tr>
<br/>

<blockquote type="cite">{{ view.comment.message }}</blockquote>

<p class="btn-bar"><a class="btn" href="{{ view.comment.url_for(_external=true, **view.tracking_tags()) }}">{% trans %}View comment{% endtrans %}</a></p>
{# Button : BEGIN #}
{{ cta_button(view.comment.url_for(_external=true, **view.tracking_tags()), gettext("View comment") )}}
{# Button : END #}

{%- endblock content -%}
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
{%- extends "notifications/layout_email.html.jinja2" %}
{%- extends "notifications/layout_email.html.jinja2" -%}
{%- from "notifications/macros_email.html.jinja2" import cta_button -%}
{%- block content -%}

<p>
{%- trans %}A comment has been reported as spam{% endtrans -%}
</p>
<tr align="center">
<td class="text-content">
<p class="body-content">{%- trans %}A comment has been reported as spam{% endtrans -%}</p>
</td>
</tr>
<br>

<p class="btn-bar">
<a class="btn" href="{{ url_for('siteadmin_review_comment', report=view.report.uuid_b58) }}">
{%- trans %}Review comment{% endtrans -%}
</a>
</p>
{# Button : BEGIN #}
{{ cta_button(url_for('siteadmin_review_comment', report=view.report.uuid_b58), gettext("Review comment") )}}
{# Button : END #}

{%- endblock content -%}
Loading