forked from rDrama/rDrama
parent
bcb663a72f
commit
49ce8617f2
|
@ -1,7 +1,6 @@
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from sqlalchemy.sql.expression import not_, and_, or_
|
from sqlalchemy.sql.expression import not_, and_, or_
|
||||||
from sqlalchemy.orm import load_only, defer
|
|
||||||
|
|
||||||
from files.classes.mod_logs import ModAction
|
from files.classes.mod_logs import ModAction
|
||||||
from files.classes.sub_logs import SubAction
|
from files.classes.sub_logs import SubAction
|
||||||
|
@ -299,12 +298,12 @@ def notifications(v:User):
|
||||||
Comment.is_banned != False,
|
Comment.is_banned != False,
|
||||||
Comment.deleted_utc != 0,
|
Comment.deleted_utc != 0,
|
||||||
)
|
)
|
||||||
).options(defer('*')).all()
|
).all()
|
||||||
for n in unread_and_inaccessible:
|
for n in unread_and_inaccessible:
|
||||||
n.read = True
|
n.read = True
|
||||||
g.db.add(n)
|
g.db.add(n)
|
||||||
|
|
||||||
comments = g.db.query(Comment, Notification).options(load_only(Comment.id)).join(Notification.comment).filter(
|
comments = g.db.query(Comment, Notification).join(Notification.comment).filter(
|
||||||
Notification.user_id == v.id,
|
Notification.user_id == v.id,
|
||||||
or_(Comment.sentto == None, Comment.sentto != v.id),
|
or_(Comment.sentto == None, Comment.sentto != v.id),
|
||||||
)
|
)
|
||||||
|
@ -321,9 +320,10 @@ def notifications(v:User):
|
||||||
)
|
)
|
||||||
|
|
||||||
comments = comments.order_by(Notification.created_utc.desc(), Comment.id.desc())
|
comments = comments.order_by(Notification.created_utc.desc(), Comment.id.desc())
|
||||||
next_exists = comments.count()
|
comments = comments.offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE+1).all()
|
||||||
comments = comments.offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE).all()
|
|
||||||
|
|
||||||
|
next_exists = (len(comments) > PAGE_SIZE)
|
||||||
|
comments = comments[:PAGE_SIZE]
|
||||||
cids = [x[0].id for x in comments]
|
cids = [x[0].id for x in comments]
|
||||||
|
|
||||||
listing = []
|
listing = []
|
||||||
|
@ -413,5 +413,4 @@ def notifications(v:User):
|
||||||
page=page,
|
page=page,
|
||||||
standalone=True,
|
standalone=True,
|
||||||
render_replies=True,
|
render_replies=True,
|
||||||
size=PAGE_SIZE,
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -131,7 +131,25 @@
|
||||||
|
|
||||||
{% block pagenav %}
|
{% block pagenav %}
|
||||||
{% if notifications %}
|
{% if notifications %}
|
||||||
{% include "pagination.html" %}
|
<nav>
|
||||||
|
<ul class="pagination pagination-sm mb-0 mt-4">
|
||||||
|
{% if page>1 %}
|
||||||
|
<li class="page-item">
|
||||||
|
<small><a class="page-link" href="{{request.path}}?page={{page-1}}">Previous</a></small>
|
||||||
|
</li>
|
||||||
|
{% else %}
|
||||||
|
<li class="page-item disabled"><span class="page-link">Prev</span></li>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if next_exists %}
|
||||||
|
<li class="page-item">
|
||||||
|
<small><a class="page-link" href="{{request.path}}?page={{page+1}}">Next</a></small>
|
||||||
|
</li>
|
||||||
|
{% else %}
|
||||||
|
<li class="page-item disabled"><span class="page-link">Next</span></li>
|
||||||
|
{% endif %}
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<link rel="stylesheet" href="{{('css/notifications.css') | asset}}">
|
<link rel="stylesheet" href="{{('css/notifications.css') | asset}}">
|
||||||
|
|
Loading…
Reference in New Issue