diff --git a/comments/models.py b/comments/models.py index 6a36fa0556ba0c6c08eece9dd9d0b73c9ea36e47..afec36f918dcdd36218190beacde71b5017f47b5 100644 --- a/comments/models.py +++ b/comments/models.py @@ -234,19 +234,19 @@ class Comment(TimeStampedModel): return None - @property def citation(self): + citation = '' 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 + return citation diff --git a/submissions/admin.py b/submissions/admin.py index 0f52fe45e9c9a0c93e0579f4b2e6f1ce8ca05596..0466fba0ced8fc05b6e32063d5ef07e9deb1ed97 100644 --- a/submissions/admin.py +++ b/submissions/admin.py @@ -184,7 +184,7 @@ class ReportAdminForm(forms.ModelForm): class ReportAdmin(admin.ModelAdmin): search_fields = ['author__user__last_name', 'submission'] - list_display = ('author', 'status', submission_short_title, 'date_submitted', ) + list_display = ('author', 'status', 'doi_label', submission_short_title, 'date_submitted', ) list_display_links = ('author',) date_hierarchy = 'date_submitted' list_filter = ('status',) diff --git a/submissions/models.py b/submissions/models.py index 88d66aace86b7b12e5be232a5e388e4c017e89cd..6f951322dfe161d31d58d03aa89c191727ae2f53 100644 --- a/submissions/models.py +++ b/submissions/models.py @@ -452,16 +452,6 @@ class Report(SubmissionRelatedObjectMixin, models.Model): return (self.author.user.first_name + ' ' + self.author.user.last_name + ' on ' + self.submission.title[:50] + ' by ' + self.submission.author_list[:50]) - def save(self, *args, **kwargs): - # Control Report count per Submission. - if not self.report_nr: - self.report_nr = self.submission.reports.count() + 1 - return super().save(*args, **kwargs) - - def create_doi_label(self): - self.doi_label = 'SciPost.Report.' + str(self.id) - self.save() - def get_absolute_url(self): return self.submission.get_absolute_url() + '#report_' + str(self.report_nr) @@ -473,8 +463,7 @@ class Report(SubmissionRelatedObjectMixin, models.Model): def doi_string(self): if self.doi_label: return '10.21468/' + self.doi_label - else: - return None + return '' @cached_property def title(self): @@ -484,7 +473,7 @@ class Report(SubmissionRelatedObjectMixin, models.Model): """ return self.submission.title - @cached_property + @property def is_followup_report(self): """ Check if current Report is a `FollowupReport`. A Report is a `FollowupReport` if the @@ -494,6 +483,16 @@ class Report(SubmissionRelatedObjectMixin, models.Model): submission__arxiv_identifier_wo_vn_nr=self.submission.arxiv_identifier_wo_vn_nr, submission__arxiv_vn_nr__lt=self.submission.arxiv_vn_nr).exists()) + def save(self, *args, **kwargs): + # Control Report count per Submission. + if not self.report_nr: + self.report_nr = self.submission.reports.count() + 1 + return super().save(*args, **kwargs) + + def create_doi_label(self): + self.doi_label = 'SciPost.Report.' + str(self.id) + self.save() + def latest_report_from_series(self): """ Get latest Report from the same author for the Submission series. @@ -525,8 +524,8 @@ class Report(SubmissionRelatedObjectMixin, models.Model): @property def citation(self): + citation = '' if self.doi_string: - citation = '' if self.anonymous: citation += 'Anonymous, ' else: @@ -534,7 +533,7 @@ class Report(SubmissionRelatedObjectMixin, models.Model): 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 + return citation ########################## diff --git a/submissions/templatetags/submissions_extras.py b/submissions/templatetags/submissions_extras.py index f7e9990c255e0e38b5840880cbcd6a9dcf840e16..f63b5843f7d9be03df5dda65ef157acd102588cd 100644 --- a/submissions/templatetags/submissions_extras.py +++ b/submissions/templatetags/submissions_extras.py @@ -24,11 +24,15 @@ def is_viewable_by_authors(recommendation): @register.filter def user_is_referee(submission, user): + if not user.is_authenticated: + return False return submission.referee_invitations.filter(referee__user=user).exists() @register.filter def is_voting_fellow(submission, user): + if not user.is_authenticated: + return False return submission.voting_fellows.filter(contributor__user=user).exists()