From 6b4261365307083b2cc94394e77a6c3412ac76fc Mon Sep 17 00:00:00 2001 From: Benjamin Moody Date: Wed, 3 Jul 2024 17:30:56 -0400 Subject: [PATCH] NewProjectVersionForm: set order field for references. Reference (and PublishedReference) objects have an "order" field which is supposed to determine the order the references are displayed. This field is not set or used consistently. Try to make the situation less bad for new active projects, by creating references in order (so that the order of their "id" will match the order of their "order") and also copy the "order" from the published project. --- physionet-django/project/forms.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/physionet-django/project/forms.py b/physionet-django/project/forms.py index 89804bd803..82283d0d98 100644 --- a/physionet-django/project/forms.py +++ b/physionet-django/project/forms.py @@ -493,10 +493,12 @@ def save(self): author=author) # Other related objects - for p_reference in self.latest_project.references.all(): + for p_reference in self.latest_project.references.order_by('order'): reference = Reference.objects.create( description=p_reference.description, - project=project) + order=p_reference.order, + project=project, + ) for p_publication in self.latest_project.publications.all(): publication = Publication.objects.create(