From 8fe65afa052a331697fd82c0bdf4fb6b64b824cd Mon Sep 17 00:00:00 2001 From: Andrew Shu Date: Tue, 19 Aug 2025 13:26:37 -0700 Subject: [PATCH 1/2] Remove is_ prefix from API schema property names Keep "is_new" because "new" is a reserved keyword in many programming languages. --- tildes/openapi_beta.yaml | 12 ++++++------ tildes/tildes/views/api/beta/comment.py | 18 +++++++++--------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tildes/openapi_beta.yaml b/tildes/openapi_beta.yaml index 8f4de6e..5b7bf78 100644 --- a/tildes/openapi_beta.yaml +++ b/tildes/openapi_beta.yaml @@ -343,8 +343,8 @@ components: - created_at - edited_at - votes - - is_removed - - is_deleted + - removed + - deleted - exemplary - voted - bookmarked @@ -366,9 +366,9 @@ components: nullable: true votes: type: integer - is_removed: + removed: type: boolean - is_deleted: + deleted: type: boolean exemplary: type: boolean @@ -379,10 +379,10 @@ components: collapsed_individual: type: boolean nullable: true - is_op: + by_op: type: boolean nullable: true - is_me: + by_me: type: boolean nullable: true is_new: diff --git a/tildes/tildes/views/api/beta/comment.py b/tildes/tildes/views/api/beta/comment.py index ee8da1b..f539693 100644 --- a/tildes/tildes/views/api/beta/comment.py +++ b/tildes/tildes/views/api/beta/comment.py @@ -15,22 +15,22 @@ def comment_to_dict(request: Request, comment: Comment) -> dict: author = None rendered_html = None exemplary = None - is_op = None - is_me = None + by_op = None + by_me = None is_new = None if request.has_permission("view", comment): author = comment.user.username rendered_html = comment.rendered_html exemplary = comment.is_label_active("exemplary") - is_me = request.user == comment.user if request.user else False + by_me = request.user == comment.user if request.user else False if request.has_permission("view_author", comment.topic): - is_op = comment.user == comment.topic.user + by_op = comment.user == comment.topic.user is_new = ( (comment.created_time > comment.topic.last_visit_time) if ( hasattr(comment.topic, "last_visit_time") and comment.topic.last_visit_time - and not is_me + and not by_me ) else False ) @@ -45,8 +45,8 @@ def comment_to_dict(request: Request, comment: Comment) -> dict: comment.last_edited_time.isoformat() if comment.last_edited_time else None ), "votes": comment.num_votes, - "is_removed": comment.is_removed, - "is_deleted": comment.is_deleted, + "removed": comment.is_removed, + "deleted": comment.is_deleted, "exemplary": exemplary, "collapsed": ( (comment.collapsed_state == "full") @@ -58,8 +58,8 @@ def comment_to_dict(request: Request, comment: Comment) -> dict: if hasattr(comment, "collapsed_state") else None ), - "is_op": is_op, - "is_me": is_me, + "by_op": by_op, + "by_me": by_me, "is_new": is_new, "voted": comment.user_voted, "bookmarked": comment.user_bookmarked, From d2fd058be78497414c4c459b854f11c724f3f58d Mon Sep 17 00:00:00 2001 From: Andrew Shu Date: Tue, 19 Aug 2025 15:12:59 -0700 Subject: [PATCH 2/2] Rename is_new to new_comment in API --- tildes/openapi_beta.yaml | 2 +- tildes/tildes/views/api/beta/comment.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tildes/openapi_beta.yaml b/tildes/openapi_beta.yaml index 5b7bf78..5204d74 100644 --- a/tildes/openapi_beta.yaml +++ b/tildes/openapi_beta.yaml @@ -385,7 +385,7 @@ components: by_me: type: boolean nullable: true - is_new: + new_comment: type: boolean nullable: true voted: diff --git a/tildes/tildes/views/api/beta/comment.py b/tildes/tildes/views/api/beta/comment.py index f539693..e57b355 100644 --- a/tildes/tildes/views/api/beta/comment.py +++ b/tildes/tildes/views/api/beta/comment.py @@ -17,7 +17,7 @@ def comment_to_dict(request: Request, comment: Comment) -> dict: exemplary = None by_op = None by_me = None - is_new = None + is_new_comment = None if request.has_permission("view", comment): author = comment.user.username rendered_html = comment.rendered_html @@ -25,7 +25,7 @@ def comment_to_dict(request: Request, comment: Comment) -> dict: by_me = request.user == comment.user if request.user else False if request.has_permission("view_author", comment.topic): by_op = comment.user == comment.topic.user - is_new = ( + is_new_comment = ( (comment.created_time > comment.topic.last_visit_time) if ( hasattr(comment.topic, "last_visit_time") @@ -60,7 +60,7 @@ def comment_to_dict(request: Request, comment: Comment) -> dict: ), "by_op": by_op, "by_me": by_me, - "is_new": is_new, + "new_comment": is_new_comment, "voted": comment.user_voted, "bookmarked": comment.user_bookmarked, }