dfdf
This commit is contained in:
parent
1d44292f64
commit
7cfa9506df
3 changed files with 27 additions and 53 deletions
|
@ -365,50 +365,6 @@ class User(Base, Stndrd, Age_times):
|
||||||
secondrange = firstrange + 26
|
secondrange = firstrange + 26
|
||||||
return comments[firstrange:secondrange]
|
return comments[firstrange:secondrange]
|
||||||
|
|
||||||
|
|
||||||
def notification_subscriptions(self, page=1):
|
|
||||||
|
|
||||||
notifications = self.notifications.join(Notification.comment).filter(Comment.author_id == AUTOJANNY_ACCOUNT)
|
|
||||||
|
|
||||||
notifications = notifications.options(
|
|
||||||
contains_eager(Notification.comment)
|
|
||||||
)
|
|
||||||
|
|
||||||
notifications = notifications.order_by(Notification.id.desc()).offset(25 * (page - 1)).limit(26)
|
|
||||||
|
|
||||||
output = []
|
|
||||||
for x in notifications:
|
|
||||||
x.read = True
|
|
||||||
g.db.add(x)
|
|
||||||
output.append(x.comment_id)
|
|
||||||
|
|
||||||
return output
|
|
||||||
|
|
||||||
def notification_commentlisting(self, page=1):
|
|
||||||
|
|
||||||
notifications = self.notifications.join(Notification.comment).filter(
|
|
||||||
Comment.is_banned == False,
|
|
||||||
Comment.deleted_utc == 0,
|
|
||||||
Comment.author_id != AUTOJANNY_ACCOUNT,
|
|
||||||
)
|
|
||||||
|
|
||||||
if not all_:
|
|
||||||
notifications = notifications.filter(Notification.read == False)
|
|
||||||
|
|
||||||
notifications = notifications.options(
|
|
||||||
contains_eager(Notification.comment)
|
|
||||||
)
|
|
||||||
|
|
||||||
notifications = notifications.order_by(
|
|
||||||
Notification.id.desc()).offset(25 * (page - 1)).limit(26)
|
|
||||||
|
|
||||||
output = []
|
|
||||||
for x in notifications:
|
|
||||||
x.read = True
|
|
||||||
g.db.add(x)
|
|
||||||
output.append(x.comment_id)
|
|
||||||
return output
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
def notifications_count(self):
|
def notifications_count(self):
|
||||||
|
|
|
@ -26,15 +26,33 @@ def notifications(v):
|
||||||
cids = cids[:25]
|
cids = cids[:25]
|
||||||
comments = get_comments(cids, v=v)
|
comments = get_comments(cids, v=v)
|
||||||
elif posts:
|
elif posts:
|
||||||
cids = v.notification_subscriptions(page=page)
|
notifications = v.notifications.join(Notification.comment).filter(Comment.author_id == AUTOJANNY_ACCOUNT).order_by(Notification.id.desc()).offset(25 * (page - 1)).limit(26)
|
||||||
next_exists = (len(cids) == 26)
|
|
||||||
cids = cids[:25]
|
comments = []
|
||||||
comments = get_comments(cids, v=v)
|
for x in notifications:
|
||||||
|
c = x.comment
|
||||||
|
if not x.read: c.unread = True
|
||||||
|
x.read = True
|
||||||
|
g.db.add(x)
|
||||||
|
comments.append(c)
|
||||||
|
next_exists = (len(comments) == 26)
|
||||||
|
comments = comments[:25]
|
||||||
else:
|
else:
|
||||||
cids = v.notification_commentlisting(page=page)
|
notifications = v.notifications.join(Notification.comment).filter(
|
||||||
next_exists = (len(cids) == 26)
|
Comment.is_banned == False,
|
||||||
cids = cids[:25]
|
Comment.deleted_utc == 0,
|
||||||
comments = get_comments(cids, v=v, load_parent=True)
|
Comment.author_id != AUTOJANNY_ACCOUNT,
|
||||||
|
).order_by(Notification.id.desc()).offset(25 * (page - 1)).limit(26)
|
||||||
|
|
||||||
|
comments = []
|
||||||
|
for x in notifications:
|
||||||
|
c = x.comment
|
||||||
|
if not x.read: c.unread = True
|
||||||
|
x.read = True
|
||||||
|
g.db.add(x)
|
||||||
|
comments.append(c)
|
||||||
|
next_exists = (len(comments) == 26)
|
||||||
|
comments = comments[:25]
|
||||||
|
|
||||||
listing = []
|
listing = []
|
||||||
for c in comments:
|
for c in comments:
|
||||||
|
|
|
@ -105,7 +105,7 @@
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<div id="comment-{{c.id}}" class="comment {% if standalone and level==1 %} mt-0{% endif %}{% if c.collapse_for_user(v) or (standalone and c.over_18 and not (v and v.over_18)) %} collapsed{% endif %}" style="border-left: 2px solid #{{c.author.namecolor}};">
|
<div id="comment-{{c.id}}" class="comment {% if standalone and level==1 %} mt-0{% endif %}{% if c.collapse_for_user(v) or (standalone and c.over_18 and not (v and v.over_18)) %} collapsed{% endif %}" style="border-left: 2px solid #{{c.author.namecolor}};{% if c.unread %}padding: 10px; border: 2px solid $primary;{% endif %}">
|
||||||
|
|
||||||
<span class="comment-collapse-desktop d-none d-md-block" style="border-left: 2px solid #{{c.author.namecolor}};" onclick="collapse_comment('{{c.id}}')"></span>
|
<span class="comment-collapse-desktop d-none d-md-block" style="border-left: 2px solid #{{c.author.namecolor}};" onclick="collapse_comment('{{c.id}}')"></span>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue