SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit 7c7dc9c7 authored by Jorran de Wit's avatar Jorran de Wit
Browse files

Fix citation always returns None

parent 78b4fae9
No related branches found
No related tags found
No related merge requests found
...@@ -234,19 +234,19 @@ class Comment(TimeStampedModel): ...@@ -234,19 +234,19 @@ class Comment(TimeStampedModel):
return None return None
@property @property
def citation(self): def citation(self):
citation = ''
if self.doi_string: if self.doi_string:
citation = ''
if self.anonymous: if self.anonymous:
citation += 'Anonymous, ' citation += 'Anonymous, '
else: else:
citation += '%s %s, ' % (self.author.user.first_name, self.author.user.last_name) citation += '%s %s, ' % (self.author.user.first_name, self.author.user.last_name)
if self.is_authorreply: if self.is_authorreply:
citation += 'SciPost Author Replies ' citation += 'SciPost Author Replies '
else: else:
citation += 'SciPost Comments ' citation += 'SciPost Comments '
citation += '(%s), doi:' % self.date_submitted.strftime('%Y') citation += '(%s), doi:' % self.date_submitted.strftime('%Y')
citation += self.doi_string citation += self.doi_string
return None return citation
...@@ -184,7 +184,7 @@ class ReportAdminForm(forms.ModelForm): ...@@ -184,7 +184,7 @@ class ReportAdminForm(forms.ModelForm):
class ReportAdmin(admin.ModelAdmin): class ReportAdmin(admin.ModelAdmin):
search_fields = ['author__user__last_name', 'submission'] 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',) list_display_links = ('author',)
date_hierarchy = 'date_submitted' date_hierarchy = 'date_submitted'
list_filter = ('status',) list_filter = ('status',)
......
...@@ -452,16 +452,6 @@ class Report(SubmissionRelatedObjectMixin, models.Model): ...@@ -452,16 +452,6 @@ class Report(SubmissionRelatedObjectMixin, models.Model):
return (self.author.user.first_name + ' ' + self.author.user.last_name + ' on ' + return (self.author.user.first_name + ' ' + self.author.user.last_name + ' on ' +
self.submission.title[:50] + ' by ' + self.submission.author_list[:50]) 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): def get_absolute_url(self):
return self.submission.get_absolute_url() + '#report_' + str(self.report_nr) return self.submission.get_absolute_url() + '#report_' + str(self.report_nr)
...@@ -473,8 +463,7 @@ class Report(SubmissionRelatedObjectMixin, models.Model): ...@@ -473,8 +463,7 @@ class Report(SubmissionRelatedObjectMixin, models.Model):
def doi_string(self): def doi_string(self):
if self.doi_label: if self.doi_label:
return '10.21468/' + self.doi_label return '10.21468/' + self.doi_label
else: return ''
return None
@cached_property @cached_property
def title(self): def title(self):
...@@ -484,7 +473,7 @@ class Report(SubmissionRelatedObjectMixin, models.Model): ...@@ -484,7 +473,7 @@ class Report(SubmissionRelatedObjectMixin, models.Model):
""" """
return self.submission.title return self.submission.title
@cached_property @property
def is_followup_report(self): def is_followup_report(self):
""" """
Check if current Report is a `FollowupReport`. A Report is a `FollowupReport` if the Check if current Report is a `FollowupReport`. A Report is a `FollowupReport` if the
...@@ -494,6 +483,16 @@ class Report(SubmissionRelatedObjectMixin, models.Model): ...@@ -494,6 +483,16 @@ class Report(SubmissionRelatedObjectMixin, models.Model):
submission__arxiv_identifier_wo_vn_nr=self.submission.arxiv_identifier_wo_vn_nr, submission__arxiv_identifier_wo_vn_nr=self.submission.arxiv_identifier_wo_vn_nr,
submission__arxiv_vn_nr__lt=self.submission.arxiv_vn_nr).exists()) 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): def latest_report_from_series(self):
""" """
Get latest Report from the same author for the Submission series. Get latest Report from the same author for the Submission series.
...@@ -525,8 +524,8 @@ class Report(SubmissionRelatedObjectMixin, models.Model): ...@@ -525,8 +524,8 @@ class Report(SubmissionRelatedObjectMixin, models.Model):
@property @property
def citation(self): def citation(self):
citation = ''
if self.doi_string: if self.doi_string:
citation = ''
if self.anonymous: if self.anonymous:
citation += 'Anonymous, ' citation += 'Anonymous, '
else: else:
...@@ -534,7 +533,7 @@ class Report(SubmissionRelatedObjectMixin, models.Model): ...@@ -534,7 +533,7 @@ class Report(SubmissionRelatedObjectMixin, models.Model):
citation += 'Report on %s, ' % self.submission.arxiv_identifier_w_vn_nr citation += 'Report on %s, ' % self.submission.arxiv_identifier_w_vn_nr
citation += 'SciPost Reports (%s), doi:' % self.date_submitted.strftime('%Y') citation += 'SciPost Reports (%s), doi:' % self.date_submitted.strftime('%Y')
citation += self.doi_string citation += self.doi_string
return None return citation
########################## ##########################
......
...@@ -24,11 +24,15 @@ def is_viewable_by_authors(recommendation): ...@@ -24,11 +24,15 @@ def is_viewable_by_authors(recommendation):
@register.filter @register.filter
def user_is_referee(submission, user): def user_is_referee(submission, user):
if not user.is_authenticated:
return False
return submission.referee_invitations.filter(referee__user=user).exists() return submission.referee_invitations.filter(referee__user=user).exists()
@register.filter @register.filter
def is_voting_fellow(submission, user): def is_voting_fellow(submission, user):
if not user.is_authenticated:
return False
return submission.voting_fellows.filter(contributor__user=user).exists() return submission.voting_fellows.filter(contributor__user=user).exists()
......
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