SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit 2a88b52e authored by Jean-Sébastien Caux's avatar Jean-Sébastien Caux
Browse files

Improve again

parent 9164e092
No related branches found
No related tags found
No related merge requests found
...@@ -44,7 +44,7 @@ class ProfileForm(forms.ModelForm): ...@@ -44,7 +44,7 @@ class ProfileForm(forms.ModelForm):
Check that only recognized types are used. Check that only recognized types are used.
""" """
cleaned_instance_from_type = self.cleaned_data['instance_from_type'] 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']: 'refereeinvitation', 'registrationinvitation']:
raise forms.ValidationError('The from_type hidden field is inconsistent.') raise forms.ValidationError('The from_type hidden field is inconsistent.')
return cleaned_instance_from_type return cleaned_instance_from_type
...@@ -62,7 +62,7 @@ class ProfileForm(forms.ModelForm): ...@@ -62,7 +62,7 @@ class ProfileForm(forms.ModelForm):
contributor = get_object_or_404(Contributor, pk=instance_pk) contributor = get_object_or_404(Contributor, pk=instance_pk)
contributor.profile = profile contributor.profile = profile
contributor.save() 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 = get_object_or_404(UnregisteredAuthor, pk=instance_pk)
unreg_auth.profile = profile unreg_auth.profile = profile
unreg_auth.save() unreg_auth.save()
......
...@@ -37,6 +37,9 @@ ...@@ -37,6 +37,9 @@
{% if next_contributor_wo_profile %} {% 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> <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 %} {% 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 %} {% 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> <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 %} {% endif %}
......
...@@ -59,7 +59,7 @@ class ProfileCreateView(PermissionsMixin, CreateView): ...@@ -59,7 +59,7 @@ class ProfileCreateView(PermissionsMixin, CreateView):
'webpage': contributor.personalwebpage, 'webpage': contributor.personalwebpage,
'accepts_SciPost_emails': contributor.accepts_SciPost_emails, '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) unreg_auth = get_object_or_404(UnregisteredAuthor, pk=pk)
initial.update({ initial.update({
'first_name': unreg_auth.first_name, 'first_name': unreg_auth.first_name,
...@@ -138,6 +138,7 @@ class ProfileListView(PermissionsMixin, PaginationMixin, ListView): ...@@ -138,6 +138,7 @@ class ProfileListView(PermissionsMixin, PaginationMixin, ListView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)
contributors_wo_profile = Contributor.objects.filter(profile__isnull=True) 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) refinv_wo_profile = RefereeInvitation.objects.filter(profile__isnull=True)
reginv_wo_profile = RegistrationInvitation.objects.filter(profile__isnull=True) reginv_wo_profile = RegistrationInvitation.objects.filter(profile__isnull=True)
...@@ -147,6 +148,8 @@ class ProfileListView(PermissionsMixin, PaginationMixin, ListView): ...@@ -147,6 +148,8 @@ class ProfileListView(PermissionsMixin, PaginationMixin, ListView):
'contributors_w_duplicate_email': Contributor.objects.have_duplicate_email(), 'contributors_w_duplicate_email': Contributor.objects.have_duplicate_email(),
'nr_contributors_wo_profile': contributors_wo_profile.count(), 'nr_contributors_wo_profile': contributors_wo_profile.count(),
'next_contributor_wo_profile': contributors_wo_profile.first(), '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(), 'nr_refinv_wo_profile': refinv_wo_profile.count(),
'next_refinv_wo_profile': refinv_wo_profile.first(), 'next_refinv_wo_profile': refinv_wo_profile.first(),
'nr_reginv_wo_profile': reginv_wo_profile.count(), 'nr_reginv_wo_profile': reginv_wo_profile.count(),
......
...@@ -15,7 +15,7 @@ from .models import Contributor ...@@ -15,7 +15,7 @@ from .models import Contributor
def link_created_profile_to_contributor(sender, instance, created, **kwargs): def link_created_profile_to_contributor(sender, instance, created, **kwargs):
""" """
When a new Profile is created, it is linked to a corresponding 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 it is not unique, no action is taken.
""" """
if created: if created:
......
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