diff --git a/profiles/forms.py b/profiles/forms.py index ab2a6ebe9dcdcea54c9cd3cc9f073db6446f71de..11181e99d7bf1ea11bfb002ac3a27173c600f72b 100644 --- a/profiles/forms.py +++ b/profiles/forms.py @@ -44,7 +44,7 @@ class ProfileForm(forms.ModelForm): Check that only recognized types are used. """ cleaned_instance_from_type = self.cleaned_data['instance_from_type'] - if cleaned_instance_from_type not in ['', 'contributor', 'unregistered_author', + if cleaned_instance_from_type not in ['', 'contributor', 'unregisteredauthor', 'refereeinvitation', 'registrationinvitation']: raise forms.ValidationError('The from_type hidden field is inconsistent.') return cleaned_instance_from_type @@ -62,7 +62,7 @@ class ProfileForm(forms.ModelForm): contributor = get_object_or_404(Contributor, pk=instance_pk) contributor.profile = profile contributor.save() - elif self.cleaned_data['instance_from_type'] == 'unregistered_author': + elif self.cleaned_data['instance_from_type'] == 'unregisteredauthor': unreg_auth = get_object_or_404(UnregisteredAuthor, pk=instance_pk) unreg_auth.profile = profile unreg_auth.save() diff --git a/profiles/templates/profiles/profile_list.html b/profiles/templates/profiles/profile_list.html index 9a9bb702428b67827e26d6997e2d6b9401709c74..500b79c016ae6f6337c8cb06ad3c7c9d0e6b8fde 100644 --- a/profiles/templates/profiles/profile_list.html +++ b/profiles/templates/profiles/profile_list.html @@ -37,6 +37,9 @@ {% if next_contributor_wo_profile %} <li>Create a Profile for <a href="{% url 'profiles:profile_create' from_type='contributor' pk=next_contributor_wo_profile.id %}">the next</a> Contributor without one ({{ nr_contributors_wo_profile }} to handle)</li> {% endif %} + {% if next_unreg_auth_wo_profile %} + <li>Create a Profile for <a href="{% url 'profiles:profile_create' from_type='unregisteredauthor' pk=next_unreg_auth_wo_profile.id %}">the next</a> UnregisteredAuthor without one ({{ nr_unreg_auth_wo_profile }} to handle)</li> + {% endif %} {% if next_refinv_wo_profile %} <li>Create a Profile for <a href="{% url 'profiles:profile_create' from_type='refereeinvitation' pk=next_refinv_wo_profile.id %}">the next</a> Referee Invitation without one ({{ nr_refinv_wo_profile }} to handle)</li> {% endif %} diff --git a/profiles/views.py b/profiles/views.py index 0453943c4079ed2d545d70499da82e5ec8457f26..fe4766baf725f60a6666e34ac4fbf701689efdab 100644 --- a/profiles/views.py +++ b/profiles/views.py @@ -59,7 +59,7 @@ class ProfileCreateView(PermissionsMixin, CreateView): 'webpage': contributor.personalwebpage, 'accepts_SciPost_emails': contributor.accepts_SciPost_emails, }) - elif from_type == 'unregistered_author': + elif from_type == 'unregisteredauthor': unreg_auth = get_object_or_404(UnregisteredAuthor, pk=pk) initial.update({ 'first_name': unreg_auth.first_name, @@ -138,6 +138,7 @@ class ProfileListView(PermissionsMixin, PaginationMixin, ListView): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) contributors_wo_profile = Contributor.objects.filter(profile__isnull=True) + unreg_auth_wo_profile = UnregisteredAuthor.objects.filter(profile__isnull=True) refinv_wo_profile = RefereeInvitation.objects.filter(profile__isnull=True) reginv_wo_profile = RegistrationInvitation.objects.filter(profile__isnull=True) @@ -147,6 +148,8 @@ class ProfileListView(PermissionsMixin, PaginationMixin, ListView): 'contributors_w_duplicate_email': Contributor.objects.have_duplicate_email(), 'nr_contributors_wo_profile': contributors_wo_profile.count(), 'next_contributor_wo_profile': contributors_wo_profile.first(), + 'nr_unreg_auth_wo_profile': unreg_auth_wo_profile.count(), + 'next_unreg_auth_wo_profile': unreg_auth_wo_profile.first(), 'nr_refinv_wo_profile': refinv_wo_profile.count(), 'next_refinv_wo_profile': refinv_wo_profile.first(), 'nr_reginv_wo_profile': reginv_wo_profile.count(), diff --git a/scipost/signals.py b/scipost/signals.py index d8caf4c3dbfd73d282a1db908ebb6bb0c6c6fa77..d169108e790dd247a7ac450e4b7eaec1a2577229 100644 --- a/scipost/signals.py +++ b/scipost/signals.py @@ -15,7 +15,7 @@ from .models import Contributor def link_created_profile_to_contributor(sender, instance, created, **kwargs): """ When a new Profile is created, it is linked to a corresponding - existing Contributor object, provided it is unique (as defined by the email). + existing Contributor object, provided it is unique (as defined by the name and email). If it is not unique, no action is taken. """ if created: