Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/repository/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,12 @@ def submit_preprint(self):
self.current_step = 5
self.save()

# The most recently uploaded submission file automatically becomes
# version 1, so managers do not have to select it manually before
# starting their review.
if self.submission_file and not self.has_version():
self.make_new_version(self.submission_file)

def subject_editors(self):
editors = []
for subject in self.subject.all():
Expand Down
17 changes: 17 additions & 0 deletions src/repository/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,23 @@ def test_create_article_force(self):
article_two,
)

def test_submit_preprint_creates_first_version(self):
self.preprint_one.submit_preprint()
self.assertEqual(self.preprint_one.preprintversion_set.count(), 1)
version = self.preprint_one.current_version
self.assertEqual(version.version, 1)
self.assertEqual(version.file, self.preprint_one.submission_file)

def test_submit_preprint_does_not_duplicate_existing_version(self):
self.preprint_one.make_new_version(self.preprint_one.submission_file)
self.preprint_one.submit_preprint()
self.assertEqual(self.preprint_one.preprintversion_set.count(), 1)

def test_submit_preprint_without_file_creates_no_version(self):
self.preprint_one.submission_file = None
self.preprint_one.submit_preprint()
self.assertEqual(self.preprint_one.preprintversion_set.count(), 0)


class TestRepositoryOrganisationUnit(TestCase):
"""Tests for the RepositoryOrganisationUnit model introduced in iowa-and-isolinear."""
Expand Down
Loading