Skip to content

Commit

Permalink
Revoke incorrect fix: should fix Preprint.save() instead
Browse files Browse the repository at this point in the history
Test: test_preprint_contributor_signal_sent_on_creation
  • Loading branch information
cslzchen committed Jan 6, 2025
1 parent 33140fd commit d535d5e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions osf/models/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -1383,8 +1383,11 @@ def add_contributor(self, contributor, permissions=None, visible=True,
)
if save:
self.save()
Preprint = apps.get_model('osf.Preprint')
if (self._id and contrib_to_add) or (isinstance(self, Preprint) and contrib_to_add):
if self._id and contrib_to_add:
# TODO: remove the comment after `Preprint.save()` has been fixed.
# There is a bug for Preprint when the first `.save()` is called. It triggers a series of events which
# includes adding creator as the contributor. However, with versioned guid, there is a gap between preprint
# is saved and guid is updated, during which `self._id` is None and the signal can not be be sent.
project_signals.contributor_added.send(self,
contributor=contributor,
auth=auth, email_template=send_email, permissions=permissions)
Expand Down

0 comments on commit d535d5e

Please sign in to comment.