Skip to content

Archive and reopen projects that are in the copyedit and awaiting approval stages - #2913

Open
smlawer wants to merge 3 commits into
devfrom
sm/archive-copyedit
Open

smlawer wants to merge 3 commits into
devfrom
sm/archive-copyedit

Conversation

@smlawer

@smlawer smlawer commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Currently there is no way for editors to archive projects that are in the copyedit or awaiting author approval stage. This capability is needed for situations when authors request the withdrawal of their submission while it is undergoing copyedits or when projects get stuck in the awaiting approval stage for long period of time. This pull request give editors the ability to archive (and reopen if needed) these projects.

Changes made

Archving

  • Added project archiving for submissions awaiting editor copyedit or author approval, matching the existing archive workflow for author revisions.
  • Added Archive actions in editor home, submitted projects, and the submission information card, while preserving the existing handling-editor/managing-editor permission rules.
  • Expanded the archive validation to allow only the three intended workflow states: awaiting author revisions, copyedit, and author approval.
  • Added archive_submission_status to record the project’s workflow state before it is archived, with a database migration.

Reopening

  • Updated the reopen workflow because reopening previously always returned a project to author revisions. That would incorrectly move accepted/copyedited projects into NEEDS_RESUBMISSION. Projects now reopen to their original archived state:
    • revision projects return to author revisions and require a new deadline;
    • copyedit projects return to editor copyedit;
    • approval projects return to awaiting author approval.
  • Preserved compatibility for existing archived projects created before the new field: reopenable legacy archives continue to return to author revisions.
  • Added author notifications when an archived project is restored to author approval, reusing the existing approval-needed email flow. These notifications are unnecessary when returning to "awaiting copyedit" since the next action needs to be done by the editor.
  • Updated the email template for restored projects so it says the project has been reopened and is awaiting approval, rather than incorrectly stating that copyediting has just completed. The copyedit-change summary remains included.

Testing

  • Added tests for archive permissions, UI visibility, restoring each new workflow state, notification recipients/content, legacy revision reopening, and migration consistency.
  • Tested manually by archiving and reopening projects in both the awaiting editor copyedit and author approval stages. I was unable to test that the email sends properly when moving a project back to awaiting approval.

@smlawer
smlawer force-pushed the sm/archive-copyedit branch from e5949e6 to 61a9449 Compare November 19, 2026 21:51

@tompollard tompollard left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this, the restore-to-original-status approach looks right, and the legacy fallback is correct since only projects awaiting revisions could previously be archived as reopenable. Tests for the touched areas pass locally on this branch.

The one blocker is the migration number, which conflicts with 0119_s3_download_metrics on dev. The other comments are smaller: tidying reopen_for_revisions, centralising the reopen-status rule, a couple of test additions, and a race in archive() that could be a follow-up.

Comment thread physionet-django/console/views.py Resolved
Comment thread physionet-django/console/views.py Resolved
Comment thread physionet-django/console/views.py Resolved
Comment thread physionet-django/console/test_views.py Resolved
@smlawer
smlawer requested a review from tompollard November 23, 2026 19:26
@tompollard

Copy link
Copy Markdown
Member

Thanks for working through the comments so quickly. The migration, reopen_status(), the view split and the new tests all look good, and leaving copyedit reopen without an email makes sense. The tests for the touched areas pass locally on e84ca41a9.

There are two remaining issues I'd like to fix before merging, both related to the archive() race, and two smaller ones.

1. A stale approval can still undo an archive (project/modelcomponents/activeproject.py, approve_author)

The conditional update protects archive(), but approve_author() still does a full save() from its in-memory copy. If the final author's approval loads the project before the archive and saves after it, the archive is erased. I reproduced this with a stale instance:

approve returned True
status 60, archive_reason None, archive_datetime None

So a project an editor has just withdrawn ends up in Awaiting Publication. Could approve_author() take select_for_update() on the project inside a transaction and re-check NEEDS_APPROVAL before recording the approval?

2. Callers ignore archive() returning False

Only the editor archive view checks the new return value:

  • reject() drops it, so EditSubmissionForm.save() still saves the reject decision and the view sends the decision email, even though the project remains active.
  • The author delete path in project_overview redirects to the success page even though nothing was deleted.

I'd suggest having archive() raise a specific exception instead of returning False, then catching it in the editor archive and author delete views, and wherever the decision form is saved. For rejection, raising also rolls back the EditLog through the form's transaction.atomic(). The deadline command already locks and re-checks the row, so it should be fine.

3. Doubled punctuation in the reopen text (submission_info_card.html, console/views.py)

The status labels already end in a full stop, so we get:

You can reopen it to submission accepted; awaiting editor copyedits..
Reopened to submission accepted; awaiting editor copyedits. (archived: Archived by editor).

The confirm dialog has the same problem (copyedits.?), as does the success message. Stripping the trailing period in one place, or using dedicated labels, would fix all of them.

4. Archived projects stay in the on-hold queue (console/views.py, on_hold_projects)

Archiving a held project leaves is_on_hold=True, so it still appears under On Hold on Editor Home. This already applied to projects awaiting revisions, but this PR extends it to two more stages. Could we exclude ARCHIVED from both on_hold_projects queries? Keeping the flag itself seems right, since a reopened project then returns on hold.

This branch has not been deployed

No deployments
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