diff --git a/comments/managers.py b/comments/managers.py index 37f5baef8c803436d56818518ac4549b85514756..70e6f20693fb1986569befa36a54852d8e130d1f 100644 --- a/comments/managers.py +++ b/comments/managers.py @@ -9,3 +9,9 @@ class CommentQuerySet(models.QuerySet): def awaiting_vetting(self): return self.filter(status=STATUS_PENDING) + + def regular_comments(self): + return self.filter(is_author_reply=False) + + def author_replies(self): + return self.filter(is_author_reply=True) diff --git a/comments/models.py b/comments/models.py index 5a2a4a6443366e04ccee9b8571f57ad837fd98e9..82ae4cf7bb8e43c962f9fdf99fd3ead00923e41d 100644 --- a/comments/models.py +++ b/comments/models.py @@ -57,7 +57,8 @@ class Comment(TimeStampedModel): # Author info is_author_reply = models.BooleanField(default=False) - author = models.ForeignKey('scipost.Contributor', on_delete=models.CASCADE) + author = models.ForeignKey('scipost.Contributor', on_delete=models.CASCADE, + related_name='comments') anonymous = models.BooleanField(default=False, verbose_name='Publish anonymously') # Categories: diff --git a/comments/templates/comments/_comment_card_content.html b/comments/templates/comments/_comment_card_content.html index 6a96446b418b5bc2b1559bbf4d39b9d042734417..c6788a79a355818dc3e31f711bdda0027efcdeaf 100644 --- a/comments/templates/comments/_comment_card_content.html +++ b/comments/templates/comments/_comment_card_content.html @@ -1,9 +1,7 @@ <div class="card-block card-comment"> {% block card_block_header %}{% endblock %} <p class="card-text"> - <span class="text-blue"> - <a href="{{comment.author.get_absolute_url}}">{{comment.author.user.first_name}} {{comment.author.user.last_name}}</a>: - </span> + <a href="{{comment.author.get_absolute_url}}">{{comment.author.user.first_name}} {{comment.author.user.last_name}}</a>: <a href="{{comment.get_absolute_url}"> "{{comment.comment_text|slice:'30'}}{% if comment.comment_text|length > 30 %}...{% endif %}" diff --git a/comments/templates/comments/_comment_card_extended_for_author.html b/comments/templates/comments/_comment_card_extended_for_author.html new file mode 100644 index 0000000000000000000000000000000000000000..aaac79e90846156ed8c28b7b195aad7bd4921aef --- /dev/null +++ b/comments/templates/comments/_comment_card_extended_for_author.html @@ -0,0 +1,16 @@ +<div class="card-block card-comment"> + <div class="mb-4 mt-2"> + <div class="d-inline-block mr-1">Nr {{comment.id}}</div> + {% include 'comments/_comment_voting_summary.html' with comment=comment class='small' %} + </div> + + <p>"{{comment.comment_text|linebreaksbr}}"</p> + <p class="card-text">by <a href="{{comment.author.get_absolute_url}}">{{comment.author.user.first_name}} {{comment.author.user.last_name}}</a> in {{comment.content_type|capfirst}} on <a href="{{comment.content_object.get_absolute_url}}" class="pubtitleli">{{comment.title}}</a> {% if comment.content_object.author_list %} <span class="text-muted">by {{comment.content_object.author_list}}</span>{% endif %}</p> + + {% comment %} + Using 'by xxx' on non-submission comments here would be ambigious. Does the `by xxx` apply to the + other object (eg. Report), or the Submission, the Comment, etc? + {% endcomment %} + <p class="card-text text-muted">Comment submitted {{comment.date_submitted}}</p> + <p class="card-text">Status: <span class="{% if comment.status == 1 %} text-success{% elif comment.status == 0 %} text-danger{% endif %}">{{comment.get_status_display}}</span></p> +</div> diff --git a/scipost/templates/scipost/personal_page.html b/scipost/templates/scipost/personal_page.html index ea97280d1bb268a694f3a499f4255677e3f2543b..c5534d31391d943a5dbcc8ab59c0de5c7415e9c9 100644 --- a/scipost/templates/scipost/personal_page.html +++ b/scipost/templates/scipost/personal_page.html @@ -58,10 +58,14 @@ <a class="nav-link" data-toggle="tab" href="#theses">Theses</a> </li> <li class="nav-item btn btn-secondary"> - <a class="nav-link" data-toggle="tab" href="#comments">Comments</a> + {% with request.user.contributor.comments.regular_comments.awaiting_vetting.count as count %} + <a class="nav-link" data-toggle="tab" href="#comments">Comments{% if count %} ({{count}} unvetted){% endif %}</a> + {% endwith %} </li> <li class="nav-item btn btn-secondary"> - <a class="nav-link" data-toggle="tab" href="#author-replies">Author Replies</a> + {% with request.user.contributor.comments.author_replies.awaiting_vetting.count as count %} + <a class="nav-link" data-toggle="tab" href="#author-replies">Author Replies{% if count %} ({{count}} unvetted){% endif %}</a> + {% endwith %} </li> </ul> </div> @@ -580,7 +584,7 @@ <ul class="list-group list-group-flush"> {% for own_comment in own_comments %} <li class="list-group-item"> - {% include 'comments/_comment_card_extended_content.html' with comment=own_comment %} + {% include 'comments/_comment_card_extended_for_author.html' with comment=own_comment %} </li> {% empty %} <li class="list-group-item"><em>You have not commented yet.</em></li> @@ -607,7 +611,7 @@ <ul class="list-group list-group-flush"> {% for own_reply in own_authorreplies %} <li class="list-group-item"> - {% include 'comments/_comment_card_extended_content.html' with comment=own_reply %} + {% include 'comments/_comment_card_extended_for_author.html' with comment=own_reply %} </li> {% empty %} <li class="list-group-item"><em>You do not have Author Replies yet.</em></li>