rename fullnames

This commit is contained in:
justcool393 2023-04-03 04:34:02 -05:00
parent 77af24a5b1
commit dc36c568bb
10 changed files with 18 additions and 18 deletions

View file

@ -138,7 +138,7 @@ class Comment(CreatedBase):
@property @property
@lazy @lazy
def fullname(self): def fullname(self):
return f"t3_{self.id}" return f"comment_{self.id}"
@property @property
@lazy @lazy
@ -150,8 +150,8 @@ class Comment(CreatedBase):
@property @property
@lazy @lazy
def parent_fullname(self): def parent_fullname(self):
if self.parent_comment_id: return f"t3_{self.parent_comment_id}" if self.parent_comment_id: return f"comment_{self.parent_comment_id}"
elif self.parent_submission: return f"t2_{self.parent_submission}" elif self.parent_submission: return f"post_{self.parent_submission}"
def replies(self, user): def replies(self, user):
if self.replies2 != None: return [x for x in self.replies2 if not x.author.shadowbanned] if self.replies2 != None: return [x for x in self.replies2 if not x.author.shadowbanned]

View file

@ -164,7 +164,7 @@ class Submission(CreatedBase):
@property @property
@lazy @lazy
def fullname(self): def fullname(self):
return f"t2_{self.id}" return f"post_{self.id}"
@property @property
@lazy @lazy

View file

@ -243,7 +243,7 @@ class User(CreatedBase):
@property @property
@lazy @lazy
def fullname(self): def fullname(self):
return f"t1_{self.id}" return f"user_{self.id}"
@property @property
@lazy @lazy

View file

@ -114,10 +114,10 @@ def api_comment(v):
parent_post = None parent_post = None
parent_comment_id = None parent_comment_id = None
if parent_fullname.startswith("t2_"): if parent_fullname.startswith("post_"):
parent = get_post(id, v=v) parent = get_post(id, v=v)
parent_post = parent parent_post = parent
elif parent_fullname.startswith("t3_"): elif parent_fullname.startswith("comment_"):
parent = get_comment(id, v=v) parent = get_comment(id, v=v)
parent_post = get_post(parent.parent_submission, v=v) if parent.parent_submission else None parent_post = get_post(parent.parent_submission, v=v) if parent.parent_submission else None
parent_comment_id = parent.id parent_comment_id = parent.id

View file

@ -17,8 +17,8 @@ def admin_vote_info_get(v):
if not link: return render_template("votes.html", v=v) if not link: return render_template("votes.html", v=v)
try: try:
if "t2_" in link: thing = get_post(link.split("t2_")[1], v=v) if "post_" in link: thing = get_post(link.split("post_")[1], v=v)
elif "t3_" in link: thing = get_comment(link.split("t3_")[1], v=v) elif "comment_" in link: thing = get_comment(link.split("comment_")[1], v=v)
else: abort(400) else: abort(400)
except: abort(400) except: abort(400)

View file

@ -426,7 +426,7 @@
<div id="comment-form-space-{{p.fullname}}" class="comment-write mb-3"> <div id="comment-form-space-{{p.fullname}}" class="comment-write mb-3">
<form id="reply-to-{{p.fullname}}" action="/comment" method="post"> <form id="reply-to-{{p.fullname}}" action="/comment" method="post">
{{forms.formkey(v)}} {{forms.formkey(v)}}
<input type="hidden" name="parent_fullname" value="t2_{{p.id}}"> <input type="hidden" name="parent_fullname" value="{{p.fullname}}">
<input autocomplete="off" id="reply-form-submission-{{p.fullname}}" type="hidden" name="submission" value="{{p.id}}"> <input autocomplete="off" id="reply-form-submission-{{p.fullname}}" type="hidden" name="submission" value="{{p.id}}">
<textarea required autocomplete="off" minlength="1" maxlength="{{COMMENT_BODY_LENGTH_MAXIMUM}}" oninput="markdown('reply-form-body-{{p.fullname}}', 'form-preview-{{p.id}}');charLimit('reply-form-body-{{p.fullname}}','charcount-reply')" id="reply-form-body-{{p.fullname}}" data-fullname="{{p.fullname}}" class="comment-box form-control rounded" id="comment-form" name="body" form="reply-to-{{p.fullname}}" aria-label="With textarea" placeholder="Add your comment..." rows="3"></textarea> <textarea required autocomplete="off" minlength="1" maxlength="{{COMMENT_BODY_LENGTH_MAXIMUM}}" oninput="markdown('reply-form-body-{{p.fullname}}', 'form-preview-{{p.id}}');charLimit('reply-form-body-{{p.fullname}}','charcount-reply')" id="reply-form-body-{{p.fullname}}" data-fullname="{{p.fullname}}" class="comment-box form-control rounded" id="comment-form" name="body" form="reply-to-{{p.fullname}}" aria-label="With textarea" placeholder="Add your comment..." rows="3"></textarea>

View file

@ -15,7 +15,7 @@ class CommentsFixture:
assert submit_get_response.status_code == 200 assert submit_get_response.status_code == 200
comment_body = data.get('body', util.generate_text()) comment_body = data.get('body', util.generate_text())
submit_comment_response = client.post("/comment", data={ submit_comment_response = client.post("/comment", data={
"parent_fullname": f't2_{post_id}', "parent_fullname": f'post_{post_id}',
'parent_level': 1, 'parent_level': 1,
'submission': post_id, 'submission': post_id,
"body": comment_body, "body": comment_body,

View file

@ -24,7 +24,7 @@ class SubmissionsFixture:
assert post_body in submit_post_response.text assert post_body in submit_post_response.text
post_info = util.ItemData.from_html(submit_post_response.text) post_info = util.ItemData.from_html(submit_post_response.text)
post_id_full = post_info.id_full post_id_full = post_info.id_full
assert post_id_full.startswith('t2_') assert post_id_full.startswith('post_')
post_id = int(post_id_full[3:]) post_id = int(post_id_full[3:])

View file

@ -114,19 +114,19 @@ def test_comment_descendant_count(accounts, submissions, comments):
reply1 = comments.comment_for_client(alice_client, post.id, { reply1 = comments.comment_for_client(alice_client, post.id, {
'body': 'You\'re wrong, this isn\'t contentious', 'body': 'You\'re wrong, this isn\'t contentious',
'parent_fullname': f't3_{root.id}', 'parent_fullname': f'comment_{root.id}',
'parent_level': root.level, 'parent_level': root.level,
}) })
rereply1 = comments.comment_for_client(alice_client, post.id, { rereply1 = comments.comment_for_client(alice_client, post.id, {
'body': 'no u', 'body': 'no u',
'parent_fullname': f't3_{reply1.id}', 'parent_fullname': f'comment_{reply1.id}',
'parent_level': reply1.level, 'parent_level': reply1.level,
}) })
reply2 = comments.comment_for_client(alice_client, post.id, { reply2 = comments.comment_for_client(alice_client, post.id, {
'body': 'Good poast', 'body': 'Good poast',
'parent_fullname': f't3_{root.id}', 'parent_fullname': f'comment_{root.id}',
'parent_level': root.level, 'parent_level': root.level,
}) })
@ -152,7 +152,7 @@ def test_more_button_label_in_deep_threads(accounts, submissions, comments):
for i in range(1, 25 + 1): for i in range(1, 25 + 1):
c = comments.comment_for_client(alice_client, post.id, { c = comments.comment_for_client(alice_client, post.id, {
'body': str(i), 'body': str(i),
'parent_fullname': f't3_{c.id}', 'parent_fullname': f'comment_{c.id}',
'parent_level': c.level, 'parent_level': c.level,
}) })
if i % 5 == 0: if i % 5 == 0:

View file

@ -52,7 +52,7 @@ class ItemData:
result = ItemData() result = ItemData()
result.id = match.group(1) # this really should get yanked out of the JS, not the URL result.id = match.group(1) # this really should get yanked out of the JS, not the URL
result.id_full = f"t2_{result.id}" result.id_full = f"post_{result.id}"
result.url = url result.url = url
return result return result
@ -69,6 +69,6 @@ class ItemData:
result = ItemData() result = ItemData()
result.id = match.group(1) # this really should get yanked out of the JS, not the HTML result.id = match.group(1) # this really should get yanked out of the JS, not the HTML
result.id_full = f"t3_{result.id}" result.id_full = f"comment_{result.id}"
result.url = f"/comment/{result.id}" result.url = f"/comment/{result.id}"
return result return result