diff --git a/comments/models.py b/comments/models.py index 9f52ca8d076f678dac5ebf7ad686960205dc22f8..6a36fa0556ba0c6c08eece9dd9d0b73c9ea36e47 100644 --- a/comments/models.py +++ b/comments/models.py @@ -233,3 +233,20 @@ class Comment(TimeStampedModel): return relation return None + + + @property + def citation(self): + if self.doi_string: + citation = '' + if self.anonymous: + citation += 'Anonymous, ' + else: + citation += '%s %s, ' % (self.author.user.first_name, self.author.user.last_name) + if self.is_authorreply: + citation += 'SciPost Author Replies ' + else: + citation += 'SciPost Comments ' + citation += '(%s), doi:' % self.date_submitted.strftime('%Y') + citation += self.doi_string + return None diff --git a/comments/templates/comments/_comment_identifier.html b/comments/templates/comments/_comment_identifier.html index 2d518ecedeea4fe7dd83cdf87755bd40e115d019..5eb681610a2fd2e657a5d71fcea0a9d1656e16f3 100644 --- a/comments/templates/comments/_comment_identifier.html +++ b/comments/templates/comments/_comment_identifier.html @@ -17,7 +17,7 @@ <a href="{{comment.author.get_absolute_url}}">{{comment.author.user.first_name}} {{comment.author.user.last_name}}</a> on {{comment.date_submitted|date:'Y-m-d'}} {% endif %} - {% if comment.doi_string %} <small>doi: {{ comment.doi_string }}</small>{% endif %} + {% if comment.doi_string %} <small>{{ comment|citation }}</small>{% endif %} </h3> diff --git a/submissions/models.py b/submissions/models.py index 14408d47ceb109d9a4f0304cfb144de369f16191..88d66aace86b7b12e5be232a5e388e4c017e89cd 100644 --- a/submissions/models.py +++ b/submissions/models.py @@ -523,6 +523,19 @@ class Report(SubmissionRelatedObjectMixin, models.Model): return None + @property + def citation(self): + if self.doi_string: + citation = '' + if self.anonymous: + citation += 'Anonymous, ' + else: + citation += '%s %s, ' % (self.author.user.first_name, self.author.user.last_name) + citation += 'Report on %s, ' % self.submission.arxiv_identifier_w_vn_nr + citation += 'SciPost Reports (%s), doi:' % self.date_submitted.strftime('%Y') + citation += self.doi_string + return None + ########################## # EditorialCommunication # diff --git a/submissions/templates/submissions/_single_public_report_without_comments.html b/submissions/templates/submissions/_single_public_report_without_comments.html index 5f0a3cf451b00d72550a7e9da77a25270fbf617c..0e438c4ca53d6fe7d9415cc18fa098150f5f8348 100644 --- a/submissions/templates/submissions/_single_public_report_without_comments.html +++ b/submissions/templates/submissions/_single_public_report_without_comments.html @@ -11,7 +11,7 @@ on {{ report.date_submitted|date:'Y-n-j' }} </h3> <ul class="publicationClickables"> - {% if report.doi_string %}<li>doi: {{ report.doi_string }}</li>{% endif %} + {% if report.doi_string %}<li>{{ report|citation }}</li>{% endif %} {% if report.pdf_report %} <li><a href="{% url 'submissions:report_detail_pdf' report.submission.arxiv_identifier_w_vn_nr report.report_nr %}" target="_blank">Download as PDF</a></li> {% endif %} @@ -53,7 +53,7 @@ on {{ report.date_submitted|date:'Y-n-j' }}</h3> </h3> <ul class="publicationClickables"> - {% if report.doi_string %}<li>doi: {{ report.doi_string }}</li>{% endif %} + {% if report.doi_string %}<li>{{ report|citation }}</li>{% endif %} {% if report.pdf_report %} <li><a href="{% url 'submissions:report_detail_pdf' report.submission.arxiv_identifier_w_vn_nr report.report_nr %}" target="_blank">Download as PDF</a></li> {% endif %} diff --git a/submissions/templatetags/submissions_extras.py b/submissions/templatetags/submissions_extras.py index 97943119c4c443baf69fdaf9b1a477d53a550475..f7e9990c255e0e38b5840880cbcd6a9dcf840e16 100644 --- a/submissions/templatetags/submissions_extras.py +++ b/submissions/templatetags/submissions_extras.py @@ -30,3 +30,8 @@ def user_is_referee(submission, user): @register.filter def is_voting_fellow(submission, user): return submission.voting_fellows.filter(contributor__user=user).exists() + + +@register.filter +def citation(citable): + return citable.citation