diff --git a/emails/base.html b/emails/base.html index 00a89e51d..08c43e79d 100644 --- a/emails/base.html +++ b/emails/base.html @@ -11,7 +11,7 @@ {% endif %} - - +
-
- +
{{ app_title }}
{{ app_title }}
-
+
+
{% block content %}{% endblock %} + +
+
+ + +
If you have any questions, respond to this email and we’ll be happy to help!
+ {% if hosted %} + + + + +
Quay [ builds, analyzes, distributes ] your container images
+ + + + + + +
Your AccountDocumentationQuay.io
+ {% endif %} diff --git a/emails/changeemail.html b/emails/changeemail.html index ee9b909fc..ee239f3fb 100644 --- a/emails/changeemail.html +++ b/emails/changeemail.html @@ -2,12 +2,25 @@ {% block content %} -

E-mail Address Change Requested

+

E-mail Address Change Requested

+
+This email address was added to the {{ app_title }} account {{ username }}. -This email address was recently asked to become the new e-mail address for user {{ username | user_reference }}. + + + + +
Confirm Email
+ + + + +
If you did not add this address to {{ username }}, you can safely ignore this message.
+Best Regards, +
+The {{ app_title }} Team

-To confirm this change, please click the following link:
-{{ app_link('confirm?code=' + token) }} + {% endblock %} diff --git a/emails/confirmemail.html b/emails/confirmemail.html index de94372cd..55b1db157 100644 --- a/emails/confirmemail.html +++ b/emails/confirmemail.html @@ -2,12 +2,29 @@ {% block content %} -

Please Confirm E-mail Address

+

Confirm email for new user: {{ username }}

+
-This email address was recently used to register user {{ username | user_reference }}. -
-
-To confirm this email address, please click the following link:
-{{ app_link('confirm?code=' + token) }} + + + + +
This email address was user to register user {{ username }}.
+ + + + + +
Once you confirm this email you’ll be able to access your {{ app_title }} account.
+ + + + + +
Confirm Email
+ + +Welcome!
+The {{ app_title }} Team
{% endblock %} diff --git a/emails/email-template-viewer.html b/emails/email-template-viewer.html new file mode 100644 index 000000000..f3f6f9a38 --- /dev/null +++ b/emails/email-template-viewer.html @@ -0,0 +1,17 @@ + + + + Email Template Viewer + + +

Email Template Viewer

+ Here is a list of the templates available: + + + \ No newline at end of file diff --git a/emails/emailchanged.html b/emails/emailchanged.html index ce6de5565..f5e628d73 100644 --- a/emails/emailchanged.html +++ b/emails/emailchanged.html @@ -2,11 +2,28 @@ {% block content %} -

Account E-mail Address Changed

+

Account password changed: {{ username }}

+
-The email address for user {{ username | user_reference }} has been changed from this e-mail address to {{ new_email }}. -
-
-If this change was not expected, please immediately log into your {{ username | admin_reference }} and reset your email address. + + + + +
The password for user {{ username }} has been changed.
+ + + + + +
No action is required if you made this change.
+ + + + + +
If you did not make this change, please contact support
+ +Best wishes,
+The {{ app_title }} Team
{% endblock %} diff --git a/emails/orgrecovery.html b/emails/orgrecovery.html index cda1d17e0..8d5cd3072 100644 --- a/emails/orgrecovery.html +++ b/emails/orgrecovery.html @@ -2,19 +2,44 @@ {% block content %} -

Organization {{ organization }} recovery

+

Organization recovery: {{ organization }}

+
-A user at {{ app_link() }} has attempted to recover organization {{ organization | user_reference }} via this email address. -
-
-Please login with one of the following user accounts to access this organization: - -
-If you did not make this request, your organization has not been compromised and the user was -not given access. Please disregard this email. + + + + +
A user at {{ app_link() }} has attempted to recover access to organization {{ organization }} via this email address.
+ + + + + +
Please login with one of the following user accounts to access this organization:
+ + + + +
+ + + + + +
Login to Recover
+ + + + + +
If you did not make this request, your organization has not been compromised and the user was not given access. You can safely ignore this message.
+ + +Best Wishes,
+The {{ app_title }} Team
{% endblock %} diff --git a/emails/passwordchanged.html b/emails/passwordchanged.html index 07c6232cc..42edd6f92 100644 --- a/emails/passwordchanged.html +++ b/emails/passwordchanged.html @@ -2,12 +2,29 @@ {% block content %} -

Account Password Changed

+

Account password changed: {{ username }}

+
-The password for user {{ username | user_reference }} has been updated. -
-
-If this change was not expected, please immediately log into your account settings and reset your email address, -or contact support. + + + + +
The password for user {{ username }} has been changed
+ + + + + +
No action is required if you made this change
+ + + + + +
If you did not make this change, please contact support
+ + +Best Wishes,
+The {{ app_title }} Team
{% endblock %} diff --git a/emails/paymentfailure.html b/emails/paymentfailure.html index 790f590b4..64fb3bfcd 100644 --- a/emails/paymentfailure.html +++ b/emails/paymentfailure.html @@ -2,12 +2,29 @@ {% block content %} -

Subscription Payment Failure

+

Subscription payment failure: {{ username }}

+
-Your recent payment for account {{ username | user_reference }} failed, which usually results in our payments processor canceling -your subscription automatically. If you would like to continue to use {{ app_title }} without interruption, -please add a new card to {{ app_title }} and re-subscribe to your plan.
-
-You can find the card and subscription management features under your {{ username | admin_reference }}
+ + + + +
A recent payment for account {{ username }} failed.
+ + + + + +
If you would like to continue to use the account {{ username }} without interruption, update your payment information.
+ + + + + + +
Log in to update payment info
+ +Thank you,
+The {{ app_title }} Team
{% endblock %} diff --git a/emails/recovery.html b/emails/recovery.html index 6f0267e39..cab230521 100644 --- a/emails/recovery.html +++ b/emails/recovery.html @@ -2,17 +2,29 @@ {% block content %} -

Account recovery

+

Account recovery

+
-A user at {{ app_link() }} has attempted to recover their account -using this email address. -
-
-If you made this request, please click the following link to recover your account and -change your password: -{{ app_link('recovery?code=' + token) }} -

-If you did not make this request, your account has not been compromised and the user was -not given access. Please disregard this email. + + + + +
A user at {{ app_title }} has attempted to recover their access to the account registered to this email address
+ + + + + +
Recover Account
+ + + + + +
If you did not request this password reset, you can safely ignore this message and the account password and access will not change.
+ + +Best Wishes,
+The {{ app_title }} Team
{% endblock %} diff --git a/emails/repoauthorizeemail.html b/emails/repoauthorizeemail.html index 7ae33975c..a98534f4d 100644 --- a/emails/repoauthorizeemail.html +++ b/emails/repoauthorizeemail.html @@ -2,12 +2,29 @@ {% block content %} -

Verify e-mail to receive repository notifications

+

Verify e-mail to recieve {{namespace}}/{{repository}} notifications

+
-A request has been made to send notifications to this email address for repository {{ (namespace, repository) | repository_reference }} + + + + +
A request has been made to send notifications to this email address for the repository {{namespace}}/{{repository}}
-

-To verify this email address, please click the following link:
-{{ app_link('authrepoemail?code=' + token) }} + + + + +
Confirm Email
+ + + + + +
If you do not wish to receive notifications for {{namespace}}/{{repository}}, you can ignore this message.
+ + +Thank you,
+The {{ app_title }} Team
{% endblock %} diff --git a/emails/teaminvite.html b/emails/teaminvite.html index 128bbe00f..0e4f11198 100644 --- a/emails/teaminvite.html +++ b/emails/teaminvite.html @@ -2,16 +2,29 @@ {% block content %} -

Invitation to join team: {{ teamname }}

+

Invitation to join team: {{ organization }}/{{ teamname }}

+
-{{ inviter | user_reference }} has invited you to join the team {{ teamname | team_reference }} under organization {{ organization | user_reference }}. + + + + +
You’ve been invited to join the team {{ teamname }} in the organization {{ organization }} by user {{ inviter | user_reference }}.
-

+ + + + +
Join Team
-To join the team, please click the following link:
-{{ app_link('confirminvite?code=' + token) }} + + + + +
If you were not expecting this invitation, you can safely ignore this email.
-

-If you were not expecting this invitation, you can ignore this email. + +Thank you,
+The {{ app_title }} Team
{% endblock %} diff --git a/tools/email-viewer/emails.py b/tools/email-viewer/emails.py new file mode 100644 index 000000000..b8efe0c2a --- /dev/null +++ b/tools/email-viewer/emails.py @@ -0,0 +1,89 @@ +from flask import Flask, render_template +import datetime +import os + +tmpl_dir = '../../emails' + +app = Flask(__name__, template_folder=tmpl_dir) + +@app.template_filter() +def user_reference_filter(value): + return value + +@app.template_filter() +def admin_reference(value): + return value + +@app.template_filter() +def repository_reference(value): + return value + +@app.template_filter() +def team_reference(value): + return value + +app.jinja_env.filters['user_reference'] = user_reference_filter +app.jinja_env.filters['admin_reference'] = admin_reference +app.jinja_env.filters['repository_reference'] = repository_reference +app.jinja_env.filters['team_reference'] = team_reference + +app_title = 'Quay.io (local)' + +def app_link_handler(url=None, title=None): + """ Just because it is in the original email tempaltes """ + return 'http://example.com/example' + +def render_with_options(template=None): + """ Pass a bunch of common variables when rendering templates """ + return render_template(template, username="exampleuser", user_reference="testing", + app_logo="https://quay.io/static/img/quay-horizontal-color.svg", token="sdf8SdfKGRME9dse_dfdf", + app_link=app_link_handler, namespace="booboo", repository="foobar", organization="buynlarge", + admin_usernames=["lazercat", "booboocoreos"], teamname="creators", inviter="devtable", + hosted=False, app_title=app_title, app_url="https://quay.io") + +def get_templates(): + """ Return a list of the available templates """ + return [t.replace('.html', '') for t in os.listdir('../../emails')] + +@app.route("/") +def template_test(): + return render_template('email-template-viewer.html', templates=get_templates()) + +@app.route("/changeemail") +def changeemail(): + return render_with_options('changeemail.html'); + +@app.route("/confirmemail") +def confirmemail(): + return render_with_options('confirmemail.html'); + +@app.route("/emailchanged") +def emailchanged(): + return render_with_options('emailchanged.html'); + +@app.route("/orgrecovery") +def orgrecovery(): + return render_with_options('orgrecovery.html'); + +@app.route("/passwordchanged") +def passwordchanged(): + return render_with_options('passwordchanged.html'); + +@app.route("/paymentfailure") +def paymentfailure(): + return render_with_options('paymentfailure.html'); + +@app.route("/recovery") +def recovery(): + return render_with_options('recovery.html'); + +@app.route("/repoauthorizeemail") +def repoauthorizeemail(): + return render_with_options('repoauthorizeemail.html'); + +@app.route("/teaminvite") +def teaminvite(): + return render_with_options('teaminvite.html'); + +if __name__ == '__main__': + app.run(debug=True) diff --git a/tools/email-viewer/requirements.txt b/tools/email-viewer/requirements.txt new file mode 100644 index 000000000..145e30200 --- /dev/null +++ b/tools/email-viewer/requirements.txt @@ -0,0 +1,6 @@ +Flask==0.10.1 +Jinja2==2.7.2 +MarkupSafe==0.18 +Werkzeug==0.9.4 +itsdangerous==0.23 +wsgiref==0.1.2 diff --git a/util/jinjautil.py b/util/jinjautil.py index 1985f6aa4..82e50020a 100644 --- a/util/jinjautil.py +++ b/util/jinjautil.py @@ -74,7 +74,7 @@ def admin_reference(username): if user.organization: return """ - organization's admin setting + organization's admin setting """ % (get_app_url(), username) else: return """ diff --git a/util/useremails.py b/util/useremails.py index 7320c4155..26235b1ee 100644 --- a/util/useremails.py +++ b/util/useremails.py @@ -1,6 +1,7 @@ import logging import traceback import json +import features from flask.ext.mail import Message @@ -53,18 +54,15 @@ def send_email(recipient, subject, template_file, parameters, action=None): app_title = app.config['REGISTRY_TITLE_SHORT'] app_url = get_app_url() - def app_link_handler(url=None, title=None): - real_url = app_url + '/' + url if url else app_url - if not title: - title = real_url if url else app_title - - return '%s' % (real_url, title) + def app_link_handler(url=None): + return app_url + '/' + url if url else app_url parameters.update({ 'subject': subject, 'app_logo': 'https://quay.io/static/img/quay-logo.png', # TODO: make this pull from config 'app_url': app_url, 'app_title': app_title, + 'hosted': features.BILLING, 'app_link': app_link_handler, 'action_metadata': json.dumps(action.metadata) if action else None })