diff --git a/profiles/templates/profiles/profile_list.html b/profiles/templates/profiles/profile_list.html index edbcdb0d83265c2110c72397d77953af332e2fb8..1907cf9c38bac0ae27ed9d9243d44456e662028a 100644 --- a/profiles/templates/profiles/profile_list.html +++ b/profiles/templates/profiles/profile_list.html @@ -29,26 +29,38 @@ $(document).ready(function($) { {% if nr_contributors_w_duplicate_names > 0 %} <li><a href="{% url 'scipost:contributor_duplicates' %}?kind=names">Handle Contributors with duplicate names ({{ nr_contributors_w_duplicate_names }} to handle)</a></li> {% else %} - <li class="text-success">[No name-duplicate Contributors found]</li> + <li><i class="fa fa-check-circle text-success"></i> No name-duplicate Contributors found</li> {% endif %} {% if nr_contributors_w_duplicate_emails > 0 %} <li><a href="{% url 'scipost:contributor_duplicates' %}?kind=names">Handle Contributors with duplicate emails ({{ nr_contributors_w_duplicate_emails }} to handle)</a></li> {% else %} - <li class="text-success">[No email-duplicate Contributors found]</li> + <li><i class="fa fa-check-circle text-success"></i> No email-duplicate Contributors found</li> {% endif %} {% 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> + {% else %} + <li><i class="fa fa-check-circle text-success"></i> All registered Contributors have a Profile</li> + {% endif %} + {% if nr_potential_duplicate_profiles > 0 %} + <li><i class="fa fa-exclamation-circle text-warning"></i> <a href="{% url 'profiles:duplicates' %}">Check for duplicate Profiles ({{ nr_potential_duplicate_profiles }} to handle)</a></li> + {% else %} + <li><i class="fa fa-check-circle text-success"></i> No potential duplicate Profiles detected</li> + {% endif %} + {% if next_reginv_wo_profile %} + <li><i class="fa fa-exclamation-circle text-warning"></i> Create a Profile for <a href="{% url 'profiles:profile_create' from_type='registrationinvitation' pk=next_reginv_wo_profile.id %}">the next</a> Registration Invitation without one ({{ nr_reginv_wo_profile }} to handle)</li> + {% else %} + <li><i class="fa fa-check-circle text-success"></i> All Registration Invitations have a Profile</li> + {% endif %} + {% if next_unreg_auth_wo_profile %} + <li><i class="fa fa-exclamation-circle text-warning"></i> 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> + {% else %} + <li><i class="fa fa-check-circle text-success"></i> All UnregisteredAuthors have a Profile</li> + {% endif %} + {% if next_refinv_wo_profile %} + <li><i class="fa fa-exclamation-circle text-warning"></i> 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> + {% else %} + <li><i class="fa fa-check-circle text-success"></i> All Referee Invitations have a Profile</li> {% endif %} - <li><a href="{% url 'profiles:duplicates' %}">Check for duplicate Profiles ({{ nr_potential_duplicate_profiles }} to handle)</a></li> - {% if next_reginv_wo_profile %} - <li>Create a Profile for <a href="{% url 'profiles:profile_create' from_type='registrationinvitation' pk=next_reginv_wo_profile.id %}">the next</a> Registration Invitation without one ({{ nr_reginv_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 %} <li><a href="{% url 'profiles:profile_create' %}">Add a Profile</a></li> </ul> <h4>Specialize the list:</h4> diff --git a/profiles/views.py b/profiles/views.py index 3ed0d8c792a0e256f6ca0d6fc9f897013b9c31e4..72e9cf1c3feeb787519537300eec7125821f0a5f 100644 --- a/profiles/views.py +++ b/profiles/views.py @@ -70,7 +70,8 @@ class ProfileCreateView(PermissionsMixin, CreateView): matching_profiles = matching_profiles.filter( Q(last_name=reginv.last_name) | Q(emails__email__in=reginv.email)) - context['matching_profiles'] = matching_profiles.distinct() + context['matching_profiles'] = matching_profiles.distinct().order_by( + 'last_name', 'first_name') return context def get_initial(self): @@ -137,6 +138,12 @@ def profile_match(request, profile_id, from_type, pk): nr_rows = 0 if from_type == 'contributor': nr_rows = Contributor.objects.filter(pk=pk).update(profile=profile) + # Give priority to the email coming from Contributor + if nr_rows == 1: + profile.emails.update(primary=False) + email, __ = ProfileEmail.objects.get_or_create( + profile=profile, email=get_object_or_404(Contributor, pk=pk).user.email) + profile.emails.filter(id=email.id).update(primary=True, still_valid=True) elif from_type == 'unregisteredauthor': nr_rows = UnregisteredAuthor.objects.filter(pk=pk).update(profile=profile) elif from_type == 'refereeinvitation':