From baa6b1fa4dcafc1c8f9be28658d3e1446619b88c Mon Sep 17 00:00:00 2001
From: "J.-S. Caux" <J.S.Caux@uva.nl>
Date: Mon, 22 Jan 2018 17:48:18 +0100
Subject: [PATCH] Change display of report metadata manage page

---
 .../journals/manage_report_metadata.html      |  6 ++-
 submissions/models.py                         | 40 +++++++++++++------
 2 files changed, 32 insertions(+), 14 deletions(-)

diff --git a/journals/templates/journals/manage_report_metadata.html b/journals/templates/journals/manage_report_metadata.html
index cd2dce24d..ace5d7333 100644
--- a/journals/templates/journals/manage_report_metadata.html
+++ b/journals/templates/journals/manage_report_metadata.html
@@ -26,8 +26,9 @@ event: "focusin"
   <thead class="thead-default">
     <tr>
       <th>Submission</th>
+      <th>Associated doi</th>
       <th>Report nr</th>
-      <th>Needs doi</th>
+      <th>Needs own doi</th>
       <th>Latest successful Crossref deposit</th>
       <th>Deposit needs updating?</th>
     </tr>
@@ -37,13 +38,14 @@ event: "focusin"
     {% for report in reports %}
     <tr data-toggle="collapse" data-parent="#accordion" href="#collapse{{ report.id }}" aria-expanded="true" aria-controls="collapse{{ report.id }}" style="cursor: pointer;">
       <td>{{ report.submission.arxiv_identifier_w_vn_nr }}</td>
+      <td>{{ report.associated_published_doi }}</td>
       <td>{{ report.report_nr }}</td>
       <td>{{ report.needs_doi }}</td>
       <td>{{ report|latest_successful_crossref_deposit_report }}</td>
       <td>{{ report.doideposit_needs_updating }}</td>
     </tr>
     <tr id="collapse{{ report.id }}" class="collapse" role="tabpanel" aria-labelledby="heading{{ report.id }}" style="background-color: #fff;">
-      <td colspan="5">
+      <td colspan="6">
 	<p><a href="{{ report.submission.get_absolute_url }}">{{ report.submission.arxiv_identifier_w_vn_nr }}</a>, <a href="{{ report.get_absolute_url }}">{{ report.report_nr }}</a></p>
 
 	<h2 class="ml-3">Actions</h2>
diff --git a/submissions/models.py b/submissions/models.py
index 14408d47c..7c580c31e 100644
--- a/submissions/models.py
+++ b/submissions/models.py
@@ -502,6 +502,21 @@ class Report(SubmissionRelatedObjectMixin, models.Model):
             submission__arxiv_identifier_wo_vn_nr=self.submission.arxiv_identifier_wo_vn_nr)
                 .order_by('submission__arxiv_identifier_wo_vn_nr').last())
 
+
+    @property
+    def associated_published_doi(self):
+        """
+        Check if the Report relates to a SciPost-published object.
+        If it is, return the doi of the published object.
+        """
+        try:
+            publication = Publication.objects.get(
+                accepted_submission__arxiv_identifier_wo_vn_nr=self.submission.arxiv_identifier_wo_vn_nr)
+        except Publication.DoesNotExist:
+            return None
+        return publication.doi_string
+
+
     @property
     def relation_to_published(self):
         """
@@ -509,19 +524,20 @@ class Report(SubmissionRelatedObjectMixin, models.Model):
         If it is, return a dict with info on relation to the published object,
         based on Crossref's peer review content type.
         """
-        publication = Publication.objects.get(
-            accepted_submission__arxiv_identifier_wo_vn_nr=self.submission.arxiv_identifier_wo_vn_nr)
-        if publication:
-            relation = {
-                'isReviewOfDOI': publication.doi_string,
-                'stage': 'pre-publication',
-                'type': 'referee-report',
-                'title': 'Report on ' + self.submission.arxiv_identifier_w_vn_nr,
-                'contributor_role': 'reviewer',
-            }
-            return relation
+        try:
+            publication = Publication.objects.get(
+                accepted_submission__arxiv_identifier_wo_vn_nr=self.submission.arxiv_identifier_wo_vn_nr)
+        except Publication.DoesNotExist:
+            return None
 
-        return None
+        relation = {
+            'isReviewOfDOI': publication.doi_string,
+            'stage': 'pre-publication',
+            'type': 'referee-report',
+            'title': 'Report on ' + self.submission.arxiv_identifier_w_vn_nr,
+            'contributor_role': 'reviewer',
+        }
+        return relation
 
 
 ##########################
-- 
GitLab