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

Can't delete duplicate FrozenAuthor object due to logic around AuthorOrder #2736

Closed
joemull opened this issue Jan 28, 2022 · 1 comment · Fixed by #2883
Closed

Can't delete duplicate FrozenAuthor object due to logic around AuthorOrder #2736

joemull opened this issue Jan 28, 2022 · 1 comment · Fixed by #2883
Assignees
Labels
bug Something's not working
Milestone

Comments

@joemull
Copy link
Member

joemull commented Jan 28, 2022

Describe the bug
A production editor merged a duplicate author's accounts, but there were still duplicate FrozenAuthor records on the Edit Metadata page for the article. So he tried to click Delete to remove the spare entries, but he get a Server Error screen.

This happened because submission.models.remove_author_from_article expects to find only one ArticleAuthorOrder object for a given unique pair author+article.

    try:
        ArticleAuthorOrder.objects.get(
            author=instance.author,
            article=instance.article,
        ).delete()
    except ArticleAuthorOrder.DoesNotExist:
        pass

Expected behavior
The function would ideally only remove the ArticleAuthorOrder object corresponding to the duplicate FrozenAuthor.

Janeway version
1.4.0

@joemull joemull added the bug Something's not working label Jan 28, 2022
@joemull joemull self-assigned this Jan 28, 2022
@joemull joemull added this to v1.4.2 Jan 28, 2022
@joemull joemull changed the title Can't delete duplicate FrozenAuthor object due to syntax around AuthorOrder Can't delete duplicate FrozenAuthor object due to logic around AuthorOrder Jan 28, 2022
@mauromsl
Copy link
Member

For this to happen, it means the article already had both accounts listed as authors with the article prior to merging the acounts.

We need a unique constraint ArticleAuthorOrder.article and ArticleAuthorOrder.author. When a constraint is present, the logic for merging will only preserve the relationship existing on the account that is being preserved and discard the child object of the account to be deleted.
The same constraint would also be needed on the FrozenAuthor model.

@ajrbyers ajrbyers added this to the 1.4.2 milestone Jan 31, 2022
@joemull joemull moved this to Todo in v1.4.2 Feb 3, 2022
@joemull joemull removed their assignment Mar 30, 2022
@mauromsl mauromsl self-assigned this May 19, 2022
@mauromsl mauromsl moved this from Todo to In Progress in v1.4.2 May 19, 2022
@mauromsl mauromsl moved this from In Progress to PR Submitted in v1.4.2 May 20, 2022
Repository owner moved this from PR Submitted to Done in v1.4.2 May 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something's not working
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants