forked from rDrama/rDrama
master
parent
8c22d05d8d
commit
aac7e56c29
|
@ -181,47 +181,6 @@ class User(Base, Stndrd, Age_times):
|
|||
def strid(self):
|
||||
return str(self.id)
|
||||
|
||||
@cache.memoize(timeout=86400)
|
||||
def userpagelisting(self, v=None, page=1, sort="new", t="all"):
|
||||
|
||||
submissions = g.db.query(Submission).options(lazyload('*')).filter_by(author_id=self.id, is_pinned=False)
|
||||
|
||||
if not (v and (v.admin_level >= 3 or v.id == self.id)):
|
||||
submissions = submissions.filter_by(deleted_utc=0, is_banned=False, private=False)
|
||||
|
||||
now = int(time.time())
|
||||
if t == 'hour':
|
||||
cutoff = now - 3600
|
||||
elif t == 'day':
|
||||
cutoff = now - 86400
|
||||
elif t == 'week':
|
||||
cutoff = now - 604800
|
||||
elif t == 'month':
|
||||
cutoff = now - 2592000
|
||||
elif t == 'year':
|
||||
cutoff = now - 31536000
|
||||
else:
|
||||
cutoff = 0
|
||||
submissions = submissions.filter(Submission.created_utc >= cutoff)
|
||||
|
||||
if sort == "new":
|
||||
submissions = submissions.order_by(Submission.created_utc.desc()).all()
|
||||
elif sort == "old":
|
||||
submissions = submissions.order_by(Submission.created_utc.asc()).all()
|
||||
elif sort == "controversial":
|
||||
submissions = sorted(submissions.all(), key=lambda x: x.score_disputed, reverse=True)
|
||||
elif sort == "top":
|
||||
submissions = sorted(submissions.all(), key=lambda x: x.score, reverse=True)
|
||||
elif sort == "bottom":
|
||||
submissions = sorted(submissions.all(), key=lambda x: x.score)
|
||||
elif sort == "comments":
|
||||
submissions = submissions.order_by(Submission.comment_count.desc()).all()
|
||||
|
||||
firstrange = 25 * (page - 1)
|
||||
secondrange = firstrange + 26
|
||||
listing = [x.id for x in submissions[firstrange:secondrange]]
|
||||
return listing
|
||||
|
||||
@property
|
||||
def fullname(self):
|
||||
return f"t1_{self.id}"
|
||||
|
|
|
@ -414,7 +414,43 @@ def u_username(username, v=None):
|
|||
page = int(request.args.get("page", "1"))
|
||||
page = max(page, 1)
|
||||
|
||||
ids = u.userpagelisting(v=v, page=page, sort=sort, t=t)
|
||||
|
||||
submissions = u.submissions.filter_by(is_pinned=False)
|
||||
|
||||
if not (v and (v.admin_level >= 3 or v.id == u.id)):
|
||||
submissions = submissions.filter_by(deleted_utc=0, is_banned=False, private=False)
|
||||
|
||||
now = int(time.time())
|
||||
if t == 'hour':
|
||||
cutoff = now - 3600
|
||||
elif t == 'day':
|
||||
cutoff = now - 86400
|
||||
elif t == 'week':
|
||||
cutoff = now - 604800
|
||||
elif t == 'month':
|
||||
cutoff = now - 2592000
|
||||
elif t == 'year':
|
||||
cutoff = now - 31536000
|
||||
else:
|
||||
cutoff = 0
|
||||
submissions = submissions.filter(Submission.created_utc >= cutoff)
|
||||
|
||||
if sort == "new":
|
||||
submissions = submissions.order_by(Submission.created_utc.desc()).all()
|
||||
elif sort == "old":
|
||||
submissions = submissions.order_by(Submission.created_utc.asc()).all()
|
||||
elif sort == "controversial":
|
||||
submissions = sorted(submissions.all(), key=lambda x: x.score_disputed, reverse=True)
|
||||
elif sort == "top":
|
||||
submissions = sorted(submissions.all(), key=lambda x: x.score, reverse=True)
|
||||
elif sort == "bottom":
|
||||
submissions = sorted(submissions.all(), key=lambda x: x.score)
|
||||
elif sort == "comments":
|
||||
submissions = submissions.order_by(Submission.comment_count.desc()).all()
|
||||
|
||||
firstrange = 25 * (page - 1)
|
||||
secondrange = firstrange + 26
|
||||
ids = [x.id for x in submissions[firstrange:secondrange]]
|
||||
|
||||
# we got 26 items just to see if a next page exists
|
||||
next_exists = (len(ids) > 25)
|
||||
|
|
|
@ -266,8 +266,6 @@
|
|||
<li class="list-inline-item text-muted d-none d-md-inline-block"><a href="/votes?link={{c.fullname}}"><i class="fas fa-arrows-v"></i>Votes</a></li>
|
||||
|
||||
{% if v %}
|
||||
<li class="list-inline-item text-muted"><a href="javascript:void(0)" onclick="document.getElementById('reply-to-{{c.id}}').classList.remove('d-none')"><i class="fas fa-reply" aria-hidden="true"></i><span class="d-none d-md-inline-block">Reply</span></a></li>
|
||||
|
||||
<li id="unsave-{{c.id}}" class="{% if c in v.saved_comment_idlist() %}d-md-inline-block{% endif %} list-inline-item text-muted d-none"><a href="javascript:void(0)" onclick="post_toast3('/unsave_comment/{{c.id}}','save-{{c.id}}','unsave-{{c.id}}')"><i class="fas fa-save"></i>Unsave</a></li>
|
||||
|
||||
<li id="save-{{c.id}}" class="{% if not c in v.saved_comment_idlist() %}d-md-inline-block{% endif %} list-inline-item text-muted d-none"><a href="javascript:void(0)" onclick="post_toast3('/save_comment/{{c.id}}','save-{{c.id}}','unsave-{{c.id}}')"><i class="fas fa-save"></i>Save</a></li>
|
||||
|
@ -276,6 +274,8 @@
|
|||
<li class="list-inline-item text-muted"><a href="javascript:void(0)" data-toggle="modal" data-target="#awardModal" onclick="awardModal('/comment/{{c.id}}/awards')"><i class="fas fa-gift"
|
||||
aria-hidden="true"></i><span class="d-none d-md-inline-block">Give Award</span></a></li>
|
||||
{% endif %}
|
||||
|
||||
<li class="list-inline-item text-muted"><a href="javascript:void(0)" onclick="document.getElementById('reply-to-{{c.id}}').classList.remove('d-none')"><i class="fas fa-reply" aria-hidden="true"></i><span class="d-none d-md-inline-block">Reply</span></a></li>
|
||||
{% endif %}
|
||||
|
||||
<li class="list-inline-item text-muted d-none d-md-inline-block"><a {% if v %}href="{{c.permalink}}?context=5#context"{% else %}href="/logged_out{{c.permalink}}?context=5#context"{% endif %}><i class="fas fa-book-open"></i>Context</a></li>
|
||||
|
|
Loading…
Reference in New Issue