Repository navigation
Preprint authors use the journal FrozenAuthor system; updates are moderated drafts - #5612
Conversation
5b7866d to
c134e67
Compare
c134e67 to
84eb6d5
Compare
| copy = FrozenAuthor.objects.get(pk=self.pk) | ||
| copy.pk = None |
There was a problem hiding this comment.
This copying pattern in django can be a bit dangerous, as it is mutating an object in memory (even tho it does the trick). It would be safer to use django.forms.models.model_to_dict. e.g, if we add a new m2m relationship to this model, tests will fail when using model_to_dict whilst the mutation done here would silently drop those relations.
There was a problem hiding this comment.
Thanks, switched to model_to_dict in d7b9674. There is a new core.model_utils.copy_instance(instance, **fields) that builds the copy from model_to_dict, so a many-to-many field added later raises a TypeError instead of being dropped. FrozenAuthor.copy() and RepositoryFieldAnswer.copy() both use it, with a test for each case.
| for affiliation in affiliations: | ||
| affiliation.pk = None | ||
| affiliation.frozen_author = copy | ||
| # bulk_create skips save(), which would make the first copy primary. | ||
| core_models.ControlledAffiliation.objects.bulk_create(affiliations) | ||
| for credit in credits: | ||
| credit.pk = None | ||
| credit.frozen_author = copy | ||
| credit.save() | ||
| return copy |
There was a problem hiding this comment.
I believe these might be easier to do with the model_to_dict too, since they become a list of pks
There was a problem hiding this comment.
Done in the same commit: affiliations and CRediT records are built with copy_instance too. Affiliations still go through bulk_create, as ControlledAffiliation.save() would make the first copy primary. Also rebased on r-v1.9.x with #5618 in; the repository migrations are now 0060–0062.
84eb6d5 to
d7b9674
Compare
Moves preprint authors from
PreprintAuthor(one row per linked account) to the journalFrozenAuthormodel, and makes author-submitted updates moderated drafts.What changed
Authors
FrozenAuthorrows on the preprint, with ROR affiliations (ControlledAffiliation) and CRediT roles, as for articles. Authors no longer need an account.Moderated updates
select_for_update) so concurrent changes can't be lost.API
authorsread and write FrozenAuthors. Field names are unchanged;pkis the linked account's ID, if any.version_queueacceptsauthorsandadditional_field_answersand reports the changed sections.?search=on the manager preprint API works again and stays within the current repository.Upgrading
repository0060–0062,submission0093–0094,core0116.repository0061 copies everyPreprintAuthoronto its preprint as a FrozenAuthor, with affiliations, CRediT records and order.repository0062 then deletesPreprintAuthor.Follow-ups