diff --git a/app/blueprints/notifications/__init__.py b/app/blueprints/notifications/__init__.py index f83d63f1..71de7d8a 100644 --- a/app/blueprints/notifications/__init__.py +++ b/app/blueprints/notifications/__init__.py @@ -17,7 +17,9 @@ from flask import Blueprint, render_template, redirect, url_for from flask_login import current_user, login_required -from app.models import db, Notification +from sqlalchemy import or_ + +from app.models import db, Notification, NotificationType bp = Blueprint("notifications", __name__) @@ -25,7 +27,14 @@ bp = Blueprint("notifications", __name__) @bp.route("/notifications/") @login_required def list_all(): - return render_template("notifications/list.html") + notifications = Notification.query.filter(Notification.user == current_user, + Notification.type != NotificationType.EDITOR_ALERT, Notification.type != NotificationType.EDITOR_MISC).all() + + editor_notifications = Notification.query.filter(Notification.user == current_user, + or_(Notification.type == NotificationType.EDITOR_ALERT, Notification.type == NotificationType.EDITOR_MISC)).all() + + return render_template("notifications/list.html", + notifications=notifications, editor_notifications=editor_notifications) @bp.route("/notifications/clear/", methods=["POST"]) diff --git a/app/templates/notifications/list.html b/app/templates/notifications/list.html index 85178742..d2f54901 100644 --- a/app/templates/notifications/list.html +++ b/app/templates/notifications/list.html @@ -10,6 +10,9 @@ Notifications + + {{ _("Edit email notification settings") }} + {% endif %}

Notifications

@@ -20,8 +23,12 @@ Notifications

{% endif %} + {% if editor_notifications %} +

Your Notifications

+ {% endif %} +
- {% for n in current_user.notifications %} + {% for n in notifications %}
{% if n.package %} @@ -54,5 +61,44 @@ Notifications {% else %}

No notifications

{% endfor %} - +
+ + {% if editor_notifications %} +

Editor Notifications

+ +
+ {% for n in editor_notifications %} + +
+ {% if n.package %} +
+ + + + {{ n.package.title }} + +
+ {% endif %} + +
+ {{ n.title}} +
+ +
+ {{ n.causer.display_name }} + +
+
+
+ {% else %} +

No notifications

+ {% endfor %} +
+ {% endif %} {% endblock %}