Add email notification prompt to post-login hook

This commit is contained in:
rubenwardy 2021-07-31 21:35:07 +01:00
parent aae546a08e
commit 6bbe2307e9
3 changed files with 21 additions and 8 deletions

@ -5,6 +5,15 @@
{% endblock %} {% endblock %}
{% block content %} {% block content %}
{% if user.notification_preferences is none %}
<h2>{{ _("Misc To do") }}</h2>
<div class="list-group mt-3 mb-5">
<a class="list-group-item list-group-item-action"
href="{{ url_for('users.email_notifications', username=user.username) }}">
{{ _("Enable email notifications") }}
</a>
</div>
{% endif %}
<h2>{{ _("Unapproved Packages Needing Action") }}</h2> <h2>{{ _("Unapproved Packages Needing Action") }}</h2>
<div class="list-group mt-3 mb-5"> <div class="list-group mt-3 mb-5">
{% for package in unapproved_packages %} {% for package in unapproved_packages %}

@ -49,6 +49,10 @@ def post_login(user: User, next_url):
flash("You have a lot of notifications, you should either read or clear them", "info") flash("You have a lot of notifications, you should either read or clear them", "info")
return redirect(url_for("notifications.list_all")) return redirect(url_for("notifications.list_all"))
if user.notification_preferences is None:
flash("Please consider enabling email notifications, you can customise how much is sent", "info")
return redirect(url_for("users.email_notifications", username=user.username))
return redirect(url_for("homepage.home")) return redirect(url_for("homepage.home"))