remotes/1693045480750635534/spooky-22
parent
28f1fdaee4
commit
bc0e608b4f
|
@ -369,15 +369,6 @@ class User(Base, Stndrd, Age_times):
|
||||||
return self.notifications.filter(Notification.read == False).join(Notification.comment).filter(
|
return self.notifications.filter(Notification.read == False).join(Notification.comment).filter(
|
||||||
Comment.author_id == AUTOJANNY_ACCOUNT).count()
|
Comment.author_id == AUTOJANNY_ACCOUNT).count()
|
||||||
|
|
||||||
|
|
||||||
def notification_messages(self, page=1):
|
|
||||||
comments = g.db.query(Comment).filter(or_(Comment.author_id==self.id, Comment.sentto==self.id), Comment.parent_submission == None).order_by(Comment.created_utc.desc(), not_(Comment.child_comments.any())).offset(25*(page-1)).limit(26).all()
|
|
||||||
|
|
||||||
for c in comments:
|
|
||||||
print(c.child_comments)
|
|
||||||
|
|
||||||
return [c[0] for c in comments]
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
def notifications_count(self):
|
def notifications_count(self):
|
||||||
|
|
|
@ -190,4 +190,3 @@ def send_admin(vid, text):
|
||||||
for admin in admins:
|
for admin in admins:
|
||||||
notif = Notification(comment_id=new_comment.id, user_id=admin.id)
|
notif = Notification(comment_id=new_comment.id, user_id=admin.id)
|
||||||
g.db.add(notif)
|
g.db.add(notif)
|
||||||
cache.delete_memoized(User.notification_messages, admin)
|
|
||||||
|
|
|
@ -21,17 +21,13 @@ def notifications(v):
|
||||||
modmail = request.args.get('modmail', False)
|
modmail = request.args.get('modmail', False)
|
||||||
posts = request.args.get('posts', False)
|
posts = request.args.get('posts', False)
|
||||||
if modmail and v.admin_level == 6:
|
if modmail and v.admin_level == 6:
|
||||||
comments = g.db.query(Comment).filter(Comment.sentto==0).order_by(Comment.created_utc.desc()).all()
|
comments = g.db.query(Comment).filter(Comment.sentto==0).order_by(Comment.created_utc.desc()).offset(25*(page-1)).limit(26).all()
|
||||||
firstrange = 100 * (page - 1)
|
next_exists = (len(comments) > 25)
|
||||||
secondrange = firstrange + 101
|
comments = comments[:25]
|
||||||
comments = comments[firstrange:secondrange]
|
|
||||||
next_exists = (len(comments) > 100)
|
|
||||||
comments = comments[:100]
|
|
||||||
elif messages:
|
elif messages:
|
||||||
cids = v.notification_messages(page=page)
|
comments = g.db.query(Comment).filter(or_(Comment.author_id==v.id, Comment.sentto==v.id), Comment.parent_submission == None).order_by(Comment.created_utc.desc(), not_(Comment.child_comments.any())).offset(25*(page-1)).limit(26).all()
|
||||||
next_exists = (len(cids) > 25)
|
next_exists = (len(comments) > 25)
|
||||||
cids = cids[:25]
|
comments = comments[:25]
|
||||||
comments = get_comments(cids, v=v)
|
|
||||||
elif posts:
|
elif posts:
|
||||||
notifications = v.notifications.join(Notification.comment).filter(Comment.author_id == AUTOJANNY_ACCOUNT).order_by(Notification.id.desc()).offset(25 * (page - 1)).all()
|
notifications = v.notifications.join(Notification.comment).filter(Comment.author_id == AUTOJANNY_ACCOUNT).order_by(Notification.id.desc()).offset(25 * (page - 1)).all()
|
||||||
|
|
||||||
|
|
|
@ -216,8 +216,6 @@ def message2(v, username):
|
||||||
|
|
||||||
send_pm(v.id, user, message)
|
send_pm(v.id, user, message)
|
||||||
|
|
||||||
cache.delete_memoized(User.notification_messages, user)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
beams_client.publish_to_interests(
|
beams_client.publish_to_interests(
|
||||||
interests=[str(user.id)],
|
interests=[str(user.id)],
|
||||||
|
@ -270,7 +268,6 @@ def messagereply(v):
|
||||||
g.db.add(new_aux)
|
g.db.add(new_aux)
|
||||||
notif = Notification(comment_id=new_comment.id, user_id=user.id)
|
notif = Notification(comment_id=new_comment.id, user_id=user.id)
|
||||||
g.db.add(notif)
|
g.db.add(notif)
|
||||||
cache.delete_memoized(User.notification_messages, user)
|
|
||||||
|
|
||||||
return jsonify({"html": render_template("comments.html",
|
return jsonify({"html": render_template("comments.html",
|
||||||
v=v,
|
v=v,
|
||||||
|
|
Loading…
Reference in New Issue