diff --git a/files/classes/comment.py b/files/classes/comment.py index ceafaffd5a..1194f6bfed 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -16,6 +16,7 @@ from files.helpers.lazy import lazy from files.helpers.regex import * from files.helpers.sorting_and_time import * +from .saves import CommentSaveRelationship def normalize_urls_runtime(body, v): if not v: return body @@ -462,3 +463,9 @@ class Comment(Base): body += '' return body + + + @property + @lazy + def num_savers(self): + return g.db.query(CommentSaveRelationship).filter_by(comment_id=self.id).count() diff --git a/files/classes/submission.py b/files/classes/submission.py index 87c32a7e60..96c7acec5e 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -17,6 +17,7 @@ from .comment import normalize_urls_runtime, add_options from .polls import * from .sub import * from .subscriptions import * +from .saves import SaveRelationship class Submission(Base): __tablename__ = "submissions" @@ -374,3 +375,8 @@ class Submission(Base): @lazy def num_subscribers(self): return g.db.query(Subscription).filter_by(submission_id=self.id).count() + + @property + @lazy + def num_savers(self): + return g.db.query(SaveRelationship).filter_by(submission_id=self.id).count() diff --git a/files/templates/comments.html b/files/templates/comments.html index 4ac8fe0f75..16f89b2218 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -401,9 +401,9 @@ {%- endif %} - + - + {% endif %} {% if c.parent_submission or c.wall_user_id %} @@ -602,9 +602,9 @@ {%- endif %} - + - + {% if c.author_id == v.id %} diff --git a/files/templates/post_actions.html b/files/templates/post_actions.html index b0b9e4cdd2..1ca195c4fb 100644 --- a/files/templates/post_actions.html +++ b/files/templates/post_actions.html @@ -20,8 +20,8 @@ - - + + {% endif %} diff --git a/files/templates/post_actions_mobile.html b/files/templates/post_actions_mobile.html index 9115be74b5..834b247c36 100644 --- a/files/templates/post_actions_mobile.html +++ b/files/templates/post_actions_mobile.html @@ -24,8 +24,8 @@ - - + + {% if v.id==p.author_id and request.path.startswith('/@') %}