diff --git a/commentaries/templates/commentaries/commentary_detail.html b/commentaries/templates/commentaries/commentary_detail.html index 2a907bbffb5cd7d220d1e2b0ac51ec80c5918504..f4af2c987b372f976b6a4ba00575c1695bd2e25f 100644 --- a/commentaries/templates/commentaries/commentary_detail.html +++ b/commentaries/templates/commentaries/commentary_detail.html @@ -86,7 +86,6 @@ <div class="row"> <div class="col-1"></div> <div class="col-10"> - <h3>Comment text:</h3> <p>{{ comment.comment_text|linebreaks }}</p> </div> </div> @@ -98,7 +97,7 @@ <div class="col-1"></div> <hr style="border-style: dotted;" /> <div class="col-3"> - <h3>Author reply ({{ reply.date_submitted }}):</h3> + {{ reply.print_identifier|safe }} </div> </div> <div class="row"> diff --git a/comments/models.py b/comments/models.py index 43238a20cd437da081ca6e870ccb0f2da00530ae..39e44a3ac0c1b0ba57a72f18c9891284aab99712 100644 --- a/comments/models.py +++ b/comments/models.py @@ -26,6 +26,15 @@ COMMENT_CATEGORIES = ( ('SUG', 'suggestion for further work'), ) +COMMENT_STATUS = ( + (1, 'vetted'), + (0, 'not yet vetted (pending)'), + (-1, 'rejected (unclear)'), + (-2, 'rejected (incorrect)'), + (-3, 'rejected (not useful)'), +) +comment_status_dict = dict(COMMENT_STATUS) + class Comment(models.Model): """ A Comment is an unsollicited note, submitted by a Contributor, on a particular publication or in reply to an earlier Comment. """ # status: @@ -60,22 +69,33 @@ class Comment(models.Model): def print_identifier (self): output = '<div class="commentid">\n' - output += '<h3>' + str(self.id) + output += '<h3><a id="comment_id' + str(self.id) + '">' + str(self.id) + '</a>' if not self.anonymous: output += ' by ' + self.author.user.first_name + ' ' + self.author.user.last_name + output += '</h3>' if self.in_reply_to: - output += ' in reply to ' + str(self.in_reply_to.id) + '</h3>\n' - output += '<h4>Date: ' + self.date_submitted.strftime("%Y-%m-%d") + '</h4>\n</div>\n' + output += '<h4>in reply to ' + str(self.in_reply_to.id) + '</h4>\n' + output += '<h4>' + self.date_submitted.strftime("%Y-%m-%d") + '</h4>\n</div>\n' return output def header_as_li (self): header = '<li><div class="flex-container">' - header += '<div class="flex-whitebox0"><p> \"' + self.comment_text[:50] + '\"</p><p>submitted on ' + self.date_submitted.strftime("%Y-%m-%d") + header += '<div class="flex-whitebox0">' + header += 'Nr ' + str(self.id) + if self.status <= 0: + header += ', status: <span style="color:red">' + comment_status_dict[self.status] + '</span>' + text_cut = self.comment_text[:50] + if len(self.comment_text) > 50: + text_cut += '...' + header += ': ' if self.submission is not None: - header += ' in submission on <a href="/submission/submission/' + str(self.submission.id) + '" class="pubtitleli">' + self.submission.title + '</a> by ' + self.submission.author_list + '</p></div>' + header += '<a href="/submissions/submission/' + str(self.submission.id) + '#comment_id' + str(self.id) + '"> \"' + text_cut + '\"</a><p>submitted on ' + self.date_submitted.strftime("%Y-%m-%d") + header += ' in submission on <a href="/submissions/submission/' + str(self.submission.id) + '" class="pubtitleli">' + self.submission.title + '</a> by ' + self.submission.author_list + '</p></div>' if self.commentary is not None: + header += '<a href="/commentaries/commentary/' + str(self.commentary.id) + '#comment_id' + str(self.id) + '"> \"' + text_cut + '\"</a><p>submitted on ' + self.date_submitted.strftime("%Y-%m-%d") header += ' in commentary on <a href="/commentaries/commentary/' + str(self.commentary.id) + '" class="pubtitleli">' + self.commentary.pub_title + '</a> by ' + self.commentary.author_list + '</p></div>' if self.thesislink is not None: + header += '<a href="/theses/thesis/' + str(self.thesislink.id) + '#comment_id' + str(self.id) + '"> \"' + text_cut + '\"</a><p>submitted on ' + self.date_submitted.strftime("%Y-%m-%d") header += ' in thesislink on <a href="/theses/thesis/' + str(self.thesislink.id) + '" class="pubtitleli">' + self.thesislink.pub_title + '</a> by ' + self.thesislink.author_list + '</p></div>' header += '</div></li>' return header @@ -103,3 +123,36 @@ class AuthorReply(models.Model): def __str__ (self): return self.reply_text + def print_identifier (self): + output = '<div class="commentid">\n' + output += '<h3><a id="authorreply_id' + str(self.id) + '">A' + str(self.id) + '</a>' + output += ' by ' + self.author.user.first_name + ' ' + self.author.user.last_name + '</h3>' + if self.in_reply_to_comment: + output += '<p>in reply to <a id="comment_id' + str(self.in_reply_to_comment.id) + '">' + str(self.in_reply_to_comment.id) + '</a></p>\n' + if self.in_reply_to_report: + output += '<h4>in reply to ' + str(self.in_reply_to_report.id) + '</h4>\n' + output += '<h4>Date: ' + self.date_submitted.strftime("%Y-%m-%d") + '</h4>\n</div>\n' + return output + + def header_as_li (self): + header = '<li><div class="flex-container">' + header += '<div class="flex-whitebox0">' + header += 'Nr A' + str(self.id) + if self.status <= 0: + header += ', status: <span style="color:red">' + comment_status_dict[self.status] + '</span>' + text_cut = self.reply_text[:50] + if len(self.reply_text) > 50: + text_cut += '...' + header += ': ' + if self.submission is not None: + header += '<a href="/submissions/submission/' + str(self.submission.id) + '#authorreply_id' + str(self.id) + '"> \"' + text_cut + '\"</a><p>submitted on ' + self.date_submitted.strftime("%Y-%m-%d") + header += ' in submission on <a href="/submissions/submission/' + str(self.submission.id) + '" class="pubtitleli">' + self.submission.title + '</a> by ' + self.submission.author_list + '</p></div>' + if self.commentary is not None: + header += '<a href="/commentaries/commentary/' + str(self.commentary.id) + '#authorreply_id' + str(self.id) + '"> \"' + text_cut + '\"</a><p>submitted on ' + self.date_submitted.strftime("%Y-%m-%d") + header += ' in commentary on <a href="/commentaries/commentary/' + str(self.commentary.id) + '" class="pubtitleli">' + self.commentary.pub_title + '</a> by ' + self.commentary.author_list + '</p></div>' + if self.thesislink is not None: + header += '<a href="/theses/thesis/' + str(self.thesislink.id) + '#authorreply_id' + str(self.id) + '"> \"' + text_cut + '\"</a><p>submitted on ' + self.date_submitted.strftime("%Y-%m-%d") + header += ' in thesislink on <a href="/theses/thesis/' + str(self.thesislink.id) + '" class="pubtitleli">' + self.thesislink.pub_title + '</a> by ' + self.thesislink.author_list + '</p></div>' + header += '</div></li>' + return header + diff --git a/scipost/templates/scipost/personal_page.html b/scipost/templates/scipost/personal_page.html index 4af7a3d89076f531a128cb8dff9e32768fdaa400..8b1f5f161fa5e18c85bc46d6bf074c20fe0256c1 100644 --- a/scipost/templates/scipost/personal_page.html +++ b/scipost/templates/scipost/personal_page.html @@ -4,6 +4,17 @@ {% block headsup %} +<script> + $(document).ready(function(){ + $("#mycommentsbutton").click(function(){ + $("#mycommentslist").toggle(); + }); + $("#myauthorrepliesbutton").click(function(){ + $("#myauthorreplieslist").toggle(); + }); + }); +</script> + {% endblock headsup %} {% block bodysup %} @@ -106,12 +117,32 @@ <hr class="hr12"> <div class="flex-greybox"> <h1>Your Comments</h1> + <button id="mycommentsbutton">View/hide your comments</button> + </div> + <div id="mycommentslist"> + <ul> + {% for own_comment in own_comments %} + {{ own_comment.header_as_li|safe }} + {% endfor %} + </ul> + </div> +</section> +{% endif %} + +{% if own_authorreplies %} +<section> + <hr class="hr12"> + <div class="flex-greybox"> + <h1>Your Author Replies</h1> + <button id="myauthorrepliesbutton">View/hide your author replies</button> + </div> + <div id="myauthorreplieslist"> + <ul> + {% for own_reply in own_authorreplies %} + {{ own_reply.header_as_li|safe }} + {% endfor %} + </ul> </div> - <ul> - {% for own_comment in own_comments %} - {{ own_comment.header_as_li|safe }} - {% endfor %} - </ul> </section> {% endif %} diff --git a/scipost/views.py b/scipost/views.py index 12533d29ac482d88402e855922ee3bc0a4dd2683..50c2b77cc7209d9c3d1b913ce425aa5f698c9cc7 100644 --- a/scipost/views.py +++ b/scipost/views.py @@ -212,7 +212,8 @@ def personal_page(request): nr_reports_to_vet = Report.objects.filter(status=0).count() nr_thesislink_requests_to_vet = ThesisLink.objects.filter(vetted=False).count() own_comments = Comment.objects.filter(author=contributor).order_by('-date_submitted') - context = {'contributor': contributor, 'nr_reg_to_vet': nr_reg_to_vet, 'nr_reg_awaiting_validation': nr_reg_awaiting_validation, 'nr_commentary_page_requests_to_vet': nr_commentary_page_requests_to_vet, 'nr_comments_to_vet': nr_comments_to_vet, 'nr_author_replies_to_vet': nr_author_replies_to_vet, 'nr_reports_to_vet': nr_reports_to_vet, 'nr_submissions_to_process': nr_submissions_to_process, 'nr_thesislink_requests_to_vet': nr_thesislink_requests_to_vet, 'own_comments': own_comments} + own_authorreplies = AuthorReply.objects.filter(author=contributor).order_by('-date_submitted') + context = {'contributor': contributor, 'nr_reg_to_vet': nr_reg_to_vet, 'nr_reg_awaiting_validation': nr_reg_awaiting_validation, 'nr_commentary_page_requests_to_vet': nr_commentary_page_requests_to_vet, 'nr_comments_to_vet': nr_comments_to_vet, 'nr_author_replies_to_vet': nr_author_replies_to_vet, 'nr_reports_to_vet': nr_reports_to_vet, 'nr_submissions_to_process': nr_submissions_to_process, 'nr_thesislink_requests_to_vet': nr_thesislink_requests_to_vet, 'own_comments': own_comments, 'own_authorreplies': own_authorreplies} return render(request, 'scipost/personal_page.html', context) else: form = AuthenticationForm() diff --git a/submissions/templates/submissions/submission_detail.html b/submissions/templates/submissions/submission_detail.html index a4c2ba5ddabad97c809afa5d01b008e4b24710e2..0ec0f44eb568059cb8b305fb06649a3b36372444 100644 --- a/submissions/templates/submissions/submission_detail.html +++ b/submissions/templates/submissions/submission_detail.html @@ -91,7 +91,7 @@ <div class="col-1"></div> <hr style="border-style: dotted;" /> <div class="col-3"> - <h3>Author reply ({{ reply.date_submitted }}):</h3> + {{ reply.print_identifier|safe }} </div> </div> @@ -151,10 +151,7 @@ <div class="row"> <div class="col-3"> - <div class="commentid"> - <h3>{{ comment.id }} {% if comment.in_reply_to %} (in reply to {{ comment.in_reply_to.id }}) {% endif %}</h3> - <h4>Date: {{ comment.date_submitted }}</h4> - </div> + {{ comment.print_identifier|safe }} </div> <div class="col-9"> @@ -187,7 +184,7 @@ <div class="col-1"></div> <hr style="border-style: dotted;" /> <div class="col-3"> - <h3>Author reply ({{ reply.date_submitted }}):</h3> + {{ reply.print_identifier|safe }} </div> </div>