SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit a1d58577 authored by George Katsikas's avatar George Katsikas :goat:
Browse files

add typehints to profile

fix crash on profile merge
parent 6e1ac2e4
No related branches found
No related tags found
No related merge requests found
...@@ -194,8 +194,8 @@ class ProfileMergeForm(forms.Form): ...@@ -194,8 +194,8 @@ class ProfileMergeForm(forms.Form):
Perform the actual merge: save all data from to-be-deleted profile Perform the actual merge: save all data from to-be-deleted profile
into the one to be kept. into the one to be kept.
""" """
profile = self.cleaned_data["to_merge_into"] profile: "Profile" = self.cleaned_data["to_merge_into"]
profile_old = self.cleaned_data["to_merge"] profile_old: "Profile" = self.cleaned_data["to_merge"]
# Merge information from old to new Profile. # Merge information from old to new Profile.
if profile.orcid_id is None: if profile.orcid_id is None:
...@@ -226,11 +226,7 @@ class ProfileMergeForm(forms.Form): ...@@ -226,11 +226,7 @@ class ProfileMergeForm(forms.Form):
profile_old.publicationauthorstable_set.all().update(profile=profile) profile_old.publicationauthorstable_set.all().update(profile=profile)
# Move all invitations to the "new" profile # Move all invitations to the "new" profile
profile_old.referee_invitations.all().update( profile_old.referee_invitations.all().update(referee=profile)
profile=profile,
referee=getattr(profile, "contributor", None)
or getattr(profile_old, "contributor", None),
)
profile_old.registrationinvitation_set.all().update(profile=profile) profile_old.registrationinvitation_set.all().update(profile=profile)
# Move all PotentialFellowships to the "new" profile # Move all PotentialFellowships to the "new" profile
......
...@@ -63,9 +63,20 @@ class Profile(models.Model): ...@@ -63,9 +63,20 @@ class Profile(models.Model):
""" """
if TYPE_CHECKING: if TYPE_CHECKING:
from submissions.models.submission import SubmissionAuthorProfile
from invitations.models import RegistrationInvitation
from colleges.models import FellowshipNomination, PotentialFellowship
id: int id: int
contributor: Contributor | None contributor: Contributor | None
referee_invitations: "RelatedManager[RefereeInvitation]" 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) title = models.CharField(max_length=4, choices=TITLE_CHOICES, default=TITLE_DR)
first_name = models.CharField(max_length=64) first_name = models.CharField(max_length=64)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment