mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-23 06:22:24 +01:00
Partition Editor notifications away from normal notifications in the notifications list
This commit is contained in:
parent
b3bd7ac615
commit
4944463f56
@ -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"])
|
||||
|
@ -10,6 +10,9 @@ Notifications
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
|
||||
<input type="submit" class="btn btn-primary" value="Clear All" />
|
||||
</form>
|
||||
<a href="{{ url_for('users.email_notifications', username=current_user.username) }}" class="btn btn-secondary float-right mr-3">
|
||||
{{ _("Edit email notification settings") }}
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
<h1>Notifications</h1>
|
||||
@ -20,8 +23,12 @@ Notifications
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
{% if editor_notifications %}
|
||||
<h2>Your Notifications</h2>
|
||||
{% endif %}
|
||||
|
||||
<div class="list-group mt-3">
|
||||
{% for n in current_user.notifications %}
|
||||
{% for n in notifications %}
|
||||
<a class="list-group-item list-group-item-action" href="{{ n.url }}">
|
||||
<div class="row">
|
||||
{% if n.package %}
|
||||
@ -54,5 +61,44 @@ Notifications
|
||||
{% else %}
|
||||
<p class="list-group-item"><i>No notifications</i></p>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
{% if editor_notifications %}
|
||||
<h2>Editor Notifications</h2>
|
||||
|
||||
<div class="list-group mt-3">
|
||||
{% for n in editor_notifications %}
|
||||
<a class="list-group-item list-group-item-action" href="{{ n.url }}">
|
||||
<div class="row">
|
||||
{% if n.package %}
|
||||
<div class="col-sm-auto text-muted">
|
||||
<img
|
||||
class="img-fluid"
|
||||
style="max-height: 22px; max-width: 22px;"
|
||||
src="{{ n.package.getThumbnailURL(1) }}" />
|
||||
|
||||
<span class="pl-2">
|
||||
{{ n.package.title }}
|
||||
</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="col-sm">
|
||||
{{ n.title}}
|
||||
</div>
|
||||
|
||||
<div class="col-sm-auto text-muted text-right">
|
||||
<span class="pr-2">{{ n.causer.display_name }}</span>
|
||||
<img
|
||||
class="img-fluid user-photo img-thumbnail img-thumbnail-1"
|
||||
style="max-height: 22px;"
|
||||
src="{{ n.causer.getProfilePicURL() }}" />
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
{% else %}
|
||||
<p class="list-group-item"><i>No notifications</i></p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
Loading…
Reference in New Issue
Block a user