-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ReferenceFormSet: Allow fixing invalid reference order.
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.)
- Loading branch information
Benjamin Moody
committed
Sep 20, 2024
1 parent
b281917
commit e3c752d
Showing
4 changed files
with
62 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
physionet-django/project/templates/project/confirm_reference_order_form.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{% comment %} | ||
Past bugs in the project editing forms can result in references having | ||
'order' set to None, or the order of 'order' not matching the order | ||
displayed in the content/copyedit page. It is impractical to repair | ||
all existing projects automatically since that requires guessing the | ||
author's intent. | ||
|
||
Therefore, if a project's reference order is undefined or | ||
inconsistent, the message below should be displayed on the content | ||
page (when the project is author-editable) or copyedit page (when the | ||
project is copyeditable.) | ||
|
||
The "confirm_reference_order" checkbox will be handled by | ||
ReferenceFormSet (see project/forms.py). | ||
{% endcomment %} | ||
{% if not project.has_valid_reference_order %} | ||
<div class="alert alert-form alert-warning"> | ||
<div> | ||
The References list may be incorrect due to a server error. | ||
Please verify that the list shown above corresponds to the | ||
correct numbered citations in the project text. | ||
</div> | ||
<label> | ||
<input type="checkbox" name="confirm_reference_order" value="1"> | ||
Order of references is correct | ||
</label> | ||
</div> | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters