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)
|
||||
|
||||
if '/comments/' in url and "sort=" not in url:
|
||||
if "?" in url: url += "&context=9"
|
||||
else: url += "?context=8"
|
||||
if "?" in url: url += f"&context={RENDER_DEPTH_LIMIT}"
|
||||
else: url += f"?context={RENDER_DEPTH_LIMIT - 1}"
|
||||
if v.controversial: url += "&sort=controversial"
|
||||
return url
|
||||
elif self.url:
|
||||
|
|
|
@ -55,6 +55,10 @@ ERROR_MESSAGES = {
|
|||
}
|
||||
|
||||
LOGGEDIN_ACTIVE_TIME = 15 * 60
|
||||
RENDER_DEPTH_LIMIT = 9
|
||||
'''
|
||||
The maximum depth at which a comment tree is rendered
|
||||
'''
|
||||
|
||||
WERKZEUG_ERROR_DESCRIPTIONS = {
|
||||
400: "The browser (or proxy) sent a request that this server could not understand.",
|
||||
|
|
|
@ -84,6 +84,7 @@ def inject_constants():
|
|||
"COLORS":COLORS,
|
||||
"THEMES":THEMES,
|
||||
"PERMS":PERMS,
|
||||
"RENDER_DEPTH_LIMIT":RENDER_DEPTH_LIMIT,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -259,7 +259,7 @@ def morecomments(v, cid):
|
|||
votes.c.vote_type,
|
||||
blocking.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.c.comment_id == Comment.id,
|
||||
isouter=True
|
||||
|
|
|
@ -72,20 +72,15 @@
|
|||
</div>
|
||||
|
||||
<div class="comment-user-info">
|
||||
{% if standalone and c.over_18 %}<span class="badge badge-danger">+18</span> {% endif %}
|
||||
{% if standalone and c.over_18 %}<span class="badge badge-danger">+18</span>{% endif %}
|
||||
{% if c.is_banned %}removed by @{{c.ban_reason}}{% elif c.deleted_utc %}Deleted by author{% elif c.is_blocking %}You are blocking @{{c.author_name}}{% endif %}
|
||||
</div>
|
||||
|
||||
<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 level<9 %}
|
||||
{% if level <= RENDER_DEPTH_LIMIT - 1 %}
|
||||
<div id="replies-of-{{c.id}}" class="">
|
||||
{% set standalone=False %}
|
||||
{% for reply in replies %}
|
||||
|
@ -541,7 +536,7 @@
|
|||
|
||||
|
||||
{% 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}}">
|
||||
{% for reply in replies %}
|
||||
{{single_comment(reply, level=level+1)}}
|
||||
|
@ -712,15 +707,6 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
{% endif %}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
from files.helpers.const import RENDER_DEPTH_LIMIT
|
||||
from . import fixture_accounts
|
||||
from . import fixture_submissions
|
||||
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
|
||||
view_post_response = alice_client.get(f'/post/{post.id}')
|
||||
assert 200 == view_post_response.status_code
|
||||
if i <= 8:
|
||||
assert f'More comments ({i - 8})' not in view_post_response.text
|
||||
if i <= RENDER_DEPTH_LIMIT - 1:
|
||||
assert f'More comments ({i - RENDER_DEPTH_LIMIT + 1})' not in view_post_response.text
|
||||
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
|
||||
def test_bulk_update_descendant_count_quick(accounts, submissions, comments):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue