Skip to content

Commit

Permalink
If no version, return current paper
Browse files Browse the repository at this point in the history
  • Loading branch information
koutst committed Oct 30, 2024
1 parent 191137d commit 710a8d4
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/paper/serializers/paper_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,20 @@ def get_version(self, paper):
paper_version = PaperVersion.objects.get(paper=paper)
return paper_version.version
except PaperVersion.DoesNotExist:
return None
return 1

def get_version_list(self, paper) -> list:
try:
paper_version = PaperVersion.objects.get(paper=paper)
except PaperVersion.DoesNotExist:
return []
return [
{
"version": 1,
"paper_id": paper.id,
"published_date": paper.paper_publish_date,
"is_latest": True,
}
]

paper_versions = PaperVersion.objects.filter(
base_doi=paper_version.base_doi
Expand Down Expand Up @@ -1071,13 +1078,20 @@ def get_version(self, paper):
paper_version = PaperVersion.objects.get(paper=paper)
return paper_version.version
except PaperVersion.DoesNotExist:
return None
return 1

def get_version_list(self, paper) -> list:
try:
paper_version = PaperVersion.objects.get(paper=paper)
except PaperVersion.DoesNotExist:
return []
return [
{
"version": 1,
"paper_id": paper.id,
"published_date": paper.paper_publish_date,
"is_latest": True,
}
]

paper_versions = PaperVersion.objects.filter(
base_doi=paper_version.base_doi
Expand Down

0 comments on commit 710a8d4

Please sign in to comment.