diff --git a/scipost_django/profiles/forms.py b/scipost_django/profiles/forms.py index a9daade84a9c8c5d16b792b17532eb0b7bbbc329..daa2f9b572642789eb312674fd57bbb51d1855a1 100644 --- a/scipost_django/profiles/forms.py +++ b/scipost_django/profiles/forms.py @@ -194,8 +194,8 @@ class ProfileMergeForm(forms.Form): Perform the actual merge: save all data from to-be-deleted profile into the one to be kept. """ - profile = self.cleaned_data["to_merge_into"] - profile_old = self.cleaned_data["to_merge"] + profile: "Profile" = self.cleaned_data["to_merge_into"] + profile_old: "Profile" = self.cleaned_data["to_merge"] # Merge information from old to new Profile. if profile.orcid_id is None: @@ -226,11 +226,7 @@ class ProfileMergeForm(forms.Form): profile_old.publicationauthorstable_set.all().update(profile=profile) # Move all invitations to the "new" profile - profile_old.referee_invitations.all().update( - profile=profile, - referee=getattr(profile, "contributor", None) - or getattr(profile_old, "contributor", None), - ) + profile_old.referee_invitations.all().update(referee=profile) profile_old.registrationinvitation_set.all().update(profile=profile) # Move all PotentialFellowships to the "new" profile diff --git a/scipost_django/profiles/models.py b/scipost_django/profiles/models.py index b240ea54f75e542ef0dc2ec6bdc8db33a522fcbe..7fd86184d388fe38d1143cfa869447c5b2202e76 100644 --- a/scipost_django/profiles/models.py +++ b/scipost_django/profiles/models.py @@ -63,9 +63,20 @@ class Profile(models.Model): """ if TYPE_CHECKING: + from submissions.models.submission import SubmissionAuthorProfile + from invitations.models import RegistrationInvitation + from colleges.models import FellowshipNomination, PotentialFellowship + id: int contributor: Contributor | None referee_invitations: "RelatedManager[RefereeInvitation]" + emails: "RelatedManager[ProfileEmail]" + affiliations: "RelatedManager[Affiliation]" + submissionauthorprofile_set: "RelatedManager[SubmissionAuthorProfile]" + publicationauthorstable_set: "RelatedManager[PublicationAuthorsTable]" + registrationinvitation_set: "RelatedManager[RegistrationInvitation]" + potentialfellowship_set: "RelatedManager[PotentialFellowship]" + fellowship_nominations: "RelatedManager[FellowshipNomination]" title = models.CharField(max_length=4, choices=TITLE_CHOICES, default=TITLE_DR) first_name = models.CharField(max_length=64)