diff --git a/perma_web/perma/forms.py b/perma_web/perma/forms.py index cde11af79..b7fb664fb 100755 --- a/perma_web/perma/forms.py +++ b/perma_web/perma/forms.py @@ -531,18 +531,19 @@ def clean_csv_file(self): def save(self, commit=True): expires_at = self.cleaned_data['expires_at'] organization = self.cleaned_data['organizations'] - affiliations_to_create = [] all_emails = set(self.user_data.keys()) - existing_users = LinkUser.objects.filter(email__in=all_emails) + affiliations_to_create = [] + # find any existing users, and exclude any that are ineligible to become org users + existing_users = LinkUser.objects.filter(email__in=all_emails) for user in existing_users: if user.is_staff or user.is_registrar_user(): self.ineligible_users[user.email] = user else: self.updated_users[user.email] = user - # update the expiration date of any affiliations that already exist + # update the affiliation expiration date for any already-affiliated users preexisting_affiliations = UserOrganizationAffiliation.objects.filter( user__in=self.updated_users.values(), organization=organization