diff --git a/app/email_utils.py b/app/email_utils.py index 31fc8f57..17ca4ba4 100644 --- a/app/email_utils.py +++ b/app/email_utils.py @@ -206,8 +206,16 @@ def send_test_email_alias(email, name): send_email( email, f"This email is sent to {email}", - render("transactional/test-email.txt", name=name, alias=email), - render("transactional/test-email.html", name=name, alias=email), + render( + "transactional/test-email.txt", + name=name, + alias=email, + ), + render( + "transactional/test-email.html", + name=name, + alias=email, + ), ) diff --git a/app/onboarding/__init__.py b/app/onboarding/__init__.py new file mode 100644 index 00000000..16b6263f --- /dev/null +++ b/app/onboarding/__init__.py @@ -0,0 +1,4 @@ +from .views import ( + index, + final, +) diff --git a/app/onboarding/base.py b/app/onboarding/base.py new file mode 100644 index 00000000..68b6e6bd --- /dev/null +++ b/app/onboarding/base.py @@ -0,0 +1,8 @@ +from flask import Blueprint + +onboarding_bp = Blueprint( + name="onboarding", + import_name=__name__, + url_prefix="/onboarding", + template_folder="templates", +) diff --git a/app/onboarding/views/final.py b/app/onboarding/views/final.py new file mode 100644 index 00000000..921daffe --- /dev/null +++ b/app/onboarding/views/final.py @@ -0,0 +1,26 @@ +from app.extensions import limiter +from app.onboarding.base import onboarding_bp +from app.email_utils import send_test_email_alias +from flask import render_template, request, flash +from flask_login import current_user, login_required +from flask_wtf import FlaskForm +from wtforms import StringField, validators + + +class SendEmailForm(FlaskForm): + email = StringField("Email", validators=[validators.DataRequired()]) + + +@onboarding_bp.route("/final", methods=["GET", "POST"]) +@login_required +@limiter.limit("10/minute") +def final(): + form = SendEmailForm(request.form) + if form.validate_on_submit(): + send_test_email_alias(form.email.data, current_user.name) + flash("We have sent a test e-mail to your alias", "success") + + return render_template( + "onboarding/final.html", + form=form, + ) diff --git a/app/onboarding/views/index.py b/app/onboarding/views/index.py new file mode 100644 index 00000000..41f04d79 --- /dev/null +++ b/app/onboarding/views/index.py @@ -0,0 +1,9 @@ +from app.onboarding.base import onboarding_bp +from flask import render_template + + +@onboarding_bp.route("/", methods=["GET"]) +def index(): + return render_template( + "onboarding/index.html", + ) diff --git a/server.py b/server.py index df17f837..ac91c684 100644 --- a/server.py +++ b/server.py @@ -95,6 +95,7 @@ from app.models import ( ) from app.monitor.base import monitor_bp from app.oauth.base import oauth_bp +from app.onboarding.base import onboarding_bp from app.phone.base import phone_bp from app.utils import random_string @@ -216,6 +217,7 @@ def register_blueprints(app: Flask): app.register_blueprint(oauth_bp, url_prefix="/oauth") app.register_blueprint(oauth_bp, url_prefix="/oauth2") + app.register_blueprint(onboarding_bp) app.register_blueprint(discover_bp) app.register_blueprint(api_bp) @@ -732,11 +734,12 @@ def register_custom_commands(app): @app.cli.command("dummy-data") def dummy_data(): - from init_app import add_sl_domains + from init_app import add_sl_domains, add_proton_partner LOG.w("reset db, add fake data") fake_data() add_sl_domains() + add_proton_partner() def setup_do_not_track(app): diff --git a/static/images/onboarding-click-icon.png b/static/images/onboarding-click-icon.png new file mode 100644 index 00000000..3a48d51f Binary files /dev/null and b/static/images/onboarding-click-icon.png differ diff --git a/static/images/onboarding-right-click.png b/static/images/onboarding-right-click.png new file mode 100644 index 00000000..210774f4 Binary files /dev/null and b/static/images/onboarding-right-click.png differ diff --git a/templates/emails/transactional/test-email.html b/templates/emails/transactional/test-email.html index 63c8f1dc..6ee70c2f 100644 --- a/templates/emails/transactional/test-email.html +++ b/templates/emails/transactional/test-email.html @@ -3,6 +3,5 @@ {% block content %} {{ render_text("Hi " + name) }} {{ render_text("This is a test to make sure that you receive emails sent to your alias " + alias + ".") }} - {{ render_text("If you have any questions, feel free to reply to this email.") }} {% endblock %} diff --git a/templates/emails/transactional/test-email.txt b/templates/emails/transactional/test-email.txt index 998ae3be..3f838639 100644 --- a/templates/emails/transactional/test-email.txt +++ b/templates/emails/transactional/test-email.txt @@ -5,7 +5,5 @@ Hi {{name}} This is a test to make sure that you receive emails sent to your alias {{alias}}. -If you have any questions, feel free to reply to this email. - {% endblock %} diff --git a/templates/onboarding/final.html b/templates/onboarding/final.html new file mode 100644 index 00000000..c7068d89 --- /dev/null +++ b/templates/onboarding/final.html @@ -0,0 +1,49 @@ +{% extends 'base.html' %} + +{% block content %} + +
For advanced options please use our web dashboard
+