SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit 15256960 authored by Jean-Sébastien Caux's avatar Jean-Sébastien Caux
Browse files

Improve presentation: hyperlink to comments and replies, lists in personal page

parent 99b1afa6
No related branches found
No related tags found
No related merge requests found
...@@ -86,7 +86,6 @@ ...@@ -86,7 +86,6 @@
<div class="row"> <div class="row">
<div class="col-1"></div> <div class="col-1"></div>
<div class="col-10"> <div class="col-10">
<h3>Comment text:</h3>
<p>{{ comment.comment_text|linebreaks }}</p> <p>{{ comment.comment_text|linebreaks }}</p>
</div> </div>
</div> </div>
...@@ -98,7 +97,7 @@ ...@@ -98,7 +97,7 @@
<div class="col-1"></div> <div class="col-1"></div>
<hr style="border-style: dotted;" /> <hr style="border-style: dotted;" />
<div class="col-3"> <div class="col-3">
<h3>Author reply ({{ reply.date_submitted }}):</h3> {{ reply.print_identifier|safe }}
</div> </div>
</div> </div>
<div class="row"> <div class="row">
......
...@@ -26,6 +26,15 @@ COMMENT_CATEGORIES = ( ...@@ -26,6 +26,15 @@ COMMENT_CATEGORIES = (
('SUG', 'suggestion for further work'), ('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): 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. """ """ A Comment is an unsollicited note, submitted by a Contributor, on a particular publication or in reply to an earlier Comment. """
# status: # status:
...@@ -60,22 +69,33 @@ class Comment(models.Model): ...@@ -60,22 +69,33 @@ class Comment(models.Model):
def print_identifier (self): def print_identifier (self):
output = '<div class="commentid">\n' 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: if not self.anonymous:
output += ' by ' + self.author.user.first_name + ' ' + self.author.user.last_name output += ' by ' + self.author.user.first_name + ' ' + self.author.user.last_name
output += '</h3>'
if self.in_reply_to: if self.in_reply_to:
output += ' in reply to ' + str(self.in_reply_to.id) + '</h3>\n' output += '<h4>in reply to ' + str(self.in_reply_to.id) + '</h4>\n'
output += '<h4>Date: ' + self.date_submitted.strftime("%Y-%m-%d") + '</h4>\n</div>\n' output += '<h4>' + self.date_submitted.strftime("%Y-%m-%d") + '</h4>\n</div>\n'
return output return output
def header_as_li (self): def header_as_li (self):
header = '<li><div class="flex-container">' 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: 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: 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>' 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: 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 += ' 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>' header += '</div></li>'
return header return header
...@@ -103,3 +123,36 @@ class AuthorReply(models.Model): ...@@ -103,3 +123,36 @@ class AuthorReply(models.Model):
def __str__ (self): def __str__ (self):
return self.reply_text 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
...@@ -4,6 +4,17 @@ ...@@ -4,6 +4,17 @@
{% block headsup %} {% block headsup %}
<script>
$(document).ready(function(){
$("#mycommentsbutton").click(function(){
$("#mycommentslist").toggle();
});
$("#myauthorrepliesbutton").click(function(){
$("#myauthorreplieslist").toggle();
});
});
</script>
{% endblock headsup %} {% endblock headsup %}
{% block bodysup %} {% block bodysup %}
...@@ -106,12 +117,32 @@ ...@@ -106,12 +117,32 @@
<hr class="hr12"> <hr class="hr12">
<div class="flex-greybox"> <div class="flex-greybox">
<h1>Your Comments</h1> <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> </div>
<ul>
{% for own_comment in own_comments %}
{{ own_comment.header_as_li|safe }}
{% endfor %}
</ul>
</section> </section>
{% endif %} {% endif %}
......
...@@ -212,7 +212,8 @@ def personal_page(request): ...@@ -212,7 +212,8 @@ def personal_page(request):
nr_reports_to_vet = Report.objects.filter(status=0).count() nr_reports_to_vet = Report.objects.filter(status=0).count()
nr_thesislink_requests_to_vet = ThesisLink.objects.filter(vetted=False).count() nr_thesislink_requests_to_vet = ThesisLink.objects.filter(vetted=False).count()
own_comments = Comment.objects.filter(author=contributor).order_by('-date_submitted') 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) return render(request, 'scipost/personal_page.html', context)
else: else:
form = AuthenticationForm() form = AuthenticationForm()
......
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
<div class="col-1"></div> <div class="col-1"></div>
<hr style="border-style: dotted;" /> <hr style="border-style: dotted;" />
<div class="col-3"> <div class="col-3">
<h3>Author reply ({{ reply.date_submitted }}):</h3> {{ reply.print_identifier|safe }}
</div> </div>
</div> </div>
...@@ -151,10 +151,7 @@ ...@@ -151,10 +151,7 @@
<div class="row"> <div class="row">
<div class="col-3"> <div class="col-3">
<div class="commentid"> {{ comment.print_identifier|safe }}
<h3>{{ comment.id }} &nbsp; {% if comment.in_reply_to %} (in reply to {{ comment.in_reply_to.id }}) {% endif %}</h3>
<h4>Date: {{ comment.date_submitted }}</h4>
</div>
</div> </div>
<div class="col-9"> <div class="col-9">
...@@ -187,7 +184,7 @@ ...@@ -187,7 +184,7 @@
<div class="col-1"></div> <div class="col-1"></div>
<hr style="border-style: dotted;" /> <hr style="border-style: dotted;" />
<div class="col-3"> <div class="col-3">
<h3>Author reply ({{ reply.date_submitted }}):</h3> {{ reply.print_identifier|safe }}
</div> </div>
</div> </div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment