Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require valid reference order for submission/publication #2300

Merged
merged 4 commits into from
Sep 21, 2024

Conversation

bemoody
Copy link
Collaborator

@bemoody bemoody commented Sep 20, 2024

Many existing projects have an invalid order of entries in their References section, due to issue #2137. "Invalid" means:

(a) One or more references have order=None, typically because it was copied from a past published version.

(b) Two references have the same order value, typically because a reference was deleted from the middle of the list and then a new one was added.

(c) order is distinct but doesn't match id order, typically because two references were deleted from the middle of the list and then a new one was added.

Whatever the reason for having an invalid order of references, it is not feasible to fix the order automatically, so we want to require the author/editor to review and fix it by hand before the project is published.

The demo project "MIMIC-III Clinical Database" currently has order=None for its three references. With these changes, you should see:

  • If you open the preview page, there is an error message "Order of references may be incorrect".

  • If you open the Project Content page, there is a warning at the bottom of the page.

  • If you add or edit references, and click "Save Description" (without checking the checkbox), the references should be saved but the warning should still be present.

  • If you check the checkbox and then click "Save Description", the warning should go away.

  • Alternatively, if you delete all three of the original references and then refresh the page, the warning should go away.

@tompollard
Copy link
Member

@bemoody sorry, conflict with #2301. Please could you rebase on dev (or just fix in a new commit if you prefer)?

Benjamin Moody added 4 commits September 20, 2024 16:25
Checkbox and radio elements should (almost always) be displayed inline
with the text according to the browser default style, and should not
be subject to a general rule that all input elements are block
elements.

(On the other hand, the invisible checkbox used in navbar.html should
be invisible, so its selector needs to be made more specific.)
Past bugs in the project editing forms have allowed project references
to be created with 'order=None', or with two references having the
same 'order'.  If this is the case, it should not be possible to
submit or publish the project until the author or editor addresses the
issue.
If a project has an invalid order of references, we must provide a way
for the author or editor to review and fix the order.

The past behavior of the "project content" and "copyedit" pages was
that ReferenceFormSet would set the 'order' field for every form in
the formset.  The effect of that, however, was that 'order' would be
set for:
  (a) newly added references
  (b) existing references whose 'description' was changed
References that already existed, and whose 'description' field was
unchanged, would not have been saved (because their form.changed_data
was False.)

Since many existing projects may have scrambled lists of references
and can't be fixed automatically, we want broken projects to be
"flagged", and we want that flag to persist until someone is able to
review the project and check that it's fixed.  In particular, simply
opening the "project content" page and submitting it, without making
any changes, should not cause the flag to be cleared.

Therefore: if the project has an invalid reference order, then display
a warning message with a checkbox (at the bottom of the page, below
the reference list and above the submit button.)

By default, that checkbox isn't checked, and in that situation,
ReferenceFormSet should not alter any existing reference 'order'.
Newly-added references should have a correct 'order', but if existing
references were "invalid", they should remain "invalid".

If the checkbox is checked, then ReferenceFormSet should set all
reference 'order' to match the current form order (which is what the
old code was trying to do, and didn't work because it didn't set
changed_data.)
Past bugs in the project editing forms have allowed project references to
be created with 'order=None', or with two references having the same
'order'.  Either situation should now prevent the project from being
submitted; check that this is the case.

ReferenceFormSet should allow these situations to be fixed manually:
if the confirm_reference_order checkbox is checked, then the 'order'
of all references should be updated; and if that box is not checked,
the 'order' of existing references should be untouched.  Check that
this works as expected.
@bemoody
Copy link
Collaborator Author

bemoody commented Sep 20, 2024

oops - should be fixed!

@tompollard
Copy link
Member

Nice, thanks!

@tompollard tompollard merged commit bea5f64 into dev Sep 21, 2024
8 checks passed
@tompollard tompollard deleted the bm/require-ref-order branch September 21, 2024 02:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants