constantify render depth limit
This commit is contained in:
parent
4cecdef35a
commit
f8f55be8b0
6 changed files with 16 additions and 24 deletions
|
@ -345,8 +345,8 @@ class Submission(Base):
|
||||||
url = self.url.replace("old.reddit.com", v.reddit)
|
url = self.url.replace("old.reddit.com", v.reddit)
|
||||||
|
|
||||||
if '/comments/' in url and "sort=" not in url:
|
if '/comments/' in url and "sort=" not in url:
|
||||||
if "?" in url: url += "&context=9"
|
if "?" in url: url += f"&context={RENDER_DEPTH_LIMIT}"
|
||||||
else: url += "?context=8"
|
else: url += f"?context={RENDER_DEPTH_LIMIT - 1}"
|
||||||
if v.controversial: url += "&sort=controversial"
|
if v.controversial: url += "&sort=controversial"
|
||||||
return url
|
return url
|
||||||
elif self.url:
|
elif self.url:
|
||||||
|
|
|
@ -55,6 +55,10 @@ ERROR_MESSAGES = {
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGGEDIN_ACTIVE_TIME = 15 * 60
|
LOGGEDIN_ACTIVE_TIME = 15 * 60
|
||||||
|
RENDER_DEPTH_LIMIT = 9
|
||||||
|
'''
|
||||||
|
The maximum depth at which a comment tree is rendered
|
||||||
|
'''
|
||||||
|
|
||||||
WERKZEUG_ERROR_DESCRIPTIONS = {
|
WERKZEUG_ERROR_DESCRIPTIONS = {
|
||||||
400: "The browser (or proxy) sent a request that this server could not understand.",
|
400: "The browser (or proxy) sent a request that this server could not understand.",
|
||||||
|
|
|
@ -84,6 +84,7 @@ def inject_constants():
|
||||||
"COLORS":COLORS,
|
"COLORS":COLORS,
|
||||||
"THEMES":THEMES,
|
"THEMES":THEMES,
|
||||||
"PERMS":PERMS,
|
"PERMS":PERMS,
|
||||||
|
"RENDER_DEPTH_LIMIT":RENDER_DEPTH_LIMIT,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -259,7 +259,7 @@ def morecomments(v, cid):
|
||||||
votes.c.vote_type,
|
votes.c.vote_type,
|
||||||
blocking.c.target_id,
|
blocking.c.target_id,
|
||||||
blocked.c.target_id,
|
blocked.c.target_id,
|
||||||
).filter(Comment.top_comment_id == tcid, Comment.level > 9).join(
|
).filter(Comment.top_comment_id == tcid, Comment.level > RENDER_DEPTH_LIMIT).join(
|
||||||
votes,
|
votes,
|
||||||
votes.c.comment_id == Comment.id,
|
votes.c.comment_id == Comment.id,
|
||||||
isouter=True
|
isouter=True
|
||||||
|
|
|
@ -77,15 +77,10 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="comment-body">
|
<div class="comment-body">
|
||||||
|
<div id="comment-{{c.id}}-only" class="{% if c.award_count('glowie') %}glow{% endif %} comment-{{c.id}}-only"></div>
|
||||||
<div id="comment-{{c.id}}-only" class="{% if c.award_count('glowie') %}glow{% endif %} comment-{{c.id}}-only">
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% if render_replies %}
|
{% if render_replies %}
|
||||||
{% if level<9 %}
|
{% if level <= RENDER_DEPTH_LIMIT - 1 %}
|
||||||
<div id="replies-of-{{c.id}}" class="">
|
<div id="replies-of-{{c.id}}" class="">
|
||||||
{% set standalone=False %}
|
{% set standalone=False %}
|
||||||
{% for reply in replies %}
|
{% for reply in replies %}
|
||||||
|
@ -541,7 +536,7 @@
|
||||||
|
|
||||||
|
|
||||||
{% if render_replies %}
|
{% if render_replies %}
|
||||||
{% if level<9 or request.path == '/notifications' %}
|
{% if level <= RENDER_DEPTH_LIMIT - 1 or request.path == '/notifications' %}
|
||||||
<div id="replies-of-{{c.id}}">
|
<div id="replies-of-{{c.id}}">
|
||||||
{% for reply in replies %}
|
{% for reply in replies %}
|
||||||
{{single_comment(reply, level=level+1)}}
|
{{single_comment(reply, level=level+1)}}
|
||||||
|
@ -712,15 +707,6 @@
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from files.helpers.const import RENDER_DEPTH_LIMIT
|
||||||
from . import fixture_accounts
|
from . import fixture_accounts
|
||||||
from . import fixture_submissions
|
from . import fixture_submissions
|
||||||
from . import fixture_comments
|
from . import fixture_comments
|
||||||
|
@ -158,10 +159,10 @@ def test_more_button_label_in_deep_threads(accounts, submissions, comments):
|
||||||
# only look every 5 posts to make this test not _too_ unbearably slow
|
# only look every 5 posts to make this test not _too_ unbearably slow
|
||||||
view_post_response = alice_client.get(f'/post/{post.id}')
|
view_post_response = alice_client.get(f'/post/{post.id}')
|
||||||
assert 200 == view_post_response.status_code
|
assert 200 == view_post_response.status_code
|
||||||
if i <= 8:
|
if i <= RENDER_DEPTH_LIMIT - 1:
|
||||||
assert f'More comments ({i - 8})' not in view_post_response.text
|
assert f'More comments ({i - RENDER_DEPTH_LIMIT + 1})' not in view_post_response.text
|
||||||
else:
|
else:
|
||||||
assert f'More comments ({i - 8})' in view_post_response.text
|
assert f'More comments ({i - RENDER_DEPTH_LIMIT + 1})' in view_post_response.text
|
||||||
|
|
||||||
@util.no_rate_limit
|
@util.no_rate_limit
|
||||||
def test_bulk_update_descendant_count_quick(accounts, submissions, comments):
|
def test_bulk_update_descendant_count_quick(accounts, submissions, comments):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue