diff --git a/submissions/forms.py b/submissions/forms.py index 25803c93d353e4591d6f6d1611590b01770ecdb1..dd0bbe9198598b04e6ac87f839c3c485d1a311dd 100644 --- a/submissions/forms.py +++ b/submissions/forms.py @@ -809,6 +809,11 @@ class ConsiderAssignmentForm(forms.Form): refusal_reason = forms.ChoiceField(choices=ASSIGNMENT_REFUSAL_REASONS, required=False) +class RefereeSearchForm(forms.Form): + last_name = forms.CharField(widget=forms.TextInput({ + 'placeholder': 'Search for a referee in the SciPost database'})) + + class RefereeSelectForm(forms.Form): """Pre-fill form to get the last name of the requested referee.""" diff --git a/submissions/templates/submissions/referee_form.html b/submissions/templates/submissions/referee_form.html index 28b12a4dbaa38d702aca9f91d0f3ddf326ee8bb3..75ce7fa3fe3b474b62303c4b7997e4031bb81729 100644 --- a/submissions/templates/submissions/referee_form.html +++ b/submissions/templates/submissions/referee_form.html @@ -72,7 +72,30 @@ {% endif %} <div class="row"> - <div class="col-12"> + <div class="col-12"> + {% if profiles_found %} + <h3>Matching people in our database:</h3> + <table class="table"> + <tr> + <th>Name</th> + <th>Contributor?</th> + <th>Action</th> + </tr> + {% for profile in profiles_found %} + <tr> + <td>{{ profile }}</td> + <td>{% if profile.contributor %}<i class="fa fa-check-circle text-success"></i>{% else %}<i class="fa fa-times-circle text-danger"></i>{% endif %}</td> + <td>Send refereeing invitation <a href="{% url 'submissions:send_refereeing_invitation' identifier_w_vn_nr=submission.preprint.identifier_w_vn_nr profile_id=profile.id auto_reminders_allowed=1 %}">with</a> or <a href="{% url 'submissions:send_refereeing_invitation' identifier_w_vn_nr=submission.preprint.identifier_w_vn_nr profile_id=profile.id auto_reminders_allowed=0 %}">without</a> {% include 'partials/submissions/refinv_auto_reminders_tooltip.html' %}</td> + </tr> + {% empty %} + <tr> + <td>No Profiles found</td> + <td></td> + </tr> + {% endfor %} + </table> + {% endif %} + {% if contributors_found %} <h3>Identified as contributor:</h3> <table class="table"> diff --git a/submissions/urls.py b/submissions/urls.py index 57711856f0e8f01895dce1c5fb10285626125496..198a4cbcf8fd5841ef6a3fb7093a1ad43e632620 100644 --- a/submissions/urls.py +++ b/submissions/urls.py @@ -100,6 +100,13 @@ urlpatterns = [ url(r'^assignments$', views.assignments, name='assignments'), url(r'^editorial_page/{regex}$'.format(regex=SUBMISSIONS_COMPLETE_REGEX), views.editorial_page, name='editorial_page'), + url(r'^find_referee/{regex}$'.format(regex=SUBMISSIONS_COMPLETE_REGEX), + views.find_referee, name='find_referee'), + url(r'^invite_referee/{regex}/(?P<profile_id>[0-9]+)' + '/(?P<auto_reminders_allowed>[0-1])$'.format( + regex=SUBMISSIONS_COMPLETE_REGEX), + views.invite_referee, name='invite_referee'), + # The following 3 views to be deprecated: url(r'^select_referee/{regex}$'.format(regex=SUBMISSIONS_COMPLETE_REGEX), views.select_referee, name='select_referee'), url(r'^recruit_referee/{regex}$'.format(regex=SUBMISSIONS_COMPLETE_REGEX), @@ -108,6 +115,7 @@ urlpatterns = [ '/(?P<auto_reminders_allowed>[0-1])$'.format( regex=SUBMISSIONS_COMPLETE_REGEX), views.send_refereeing_invitation, name='send_refereeing_invitation'), + # above 3 views to be deprecated url(r'^set_refinv_auto_reminder/(?P<invitation_id>[0-9]+)/(?P<auto_reminders>[0-1])$', views.set_refinv_auto_reminder, name='set_refinv_auto_reminder'), url(r'^accept_or_decline_ref_invitations/$', diff --git a/submissions/views.py b/submissions/views.py index e80c5017dcfab6219c6af982ffcb70854f80a497..b24523515f2e47ff9c92b9ff88043866efb3a82b 100644 --- a/submissions/views.py +++ b/submissions/views.py @@ -33,7 +33,8 @@ from .mixins import SubmissionAdminViewMixin from .forms import ( SubmissionIdentifierForm, RequestSubmissionForm, SubmissionSearchForm, RecommendationVoteForm, ConsiderAssignmentForm, InviteEditorialAssignmentForm, EditorialAssignmentForm, VetReportForm, - SetRefereeingDeadlineForm, RefereeSelectForm, iThenticateReportForm, VotingEligibilityForm, + SetRefereeingDeadlineForm, RefereeSearchForm, RefereeSelectForm, + iThenticateReportForm, VotingEligibilityForm, RefereeRecruitmentForm, ConsiderRefereeInvitationForm, EditorialCommunicationForm, ReportForm, SubmissionCycleChoiceForm, ReportPDFForm, SubmissionReportsForm, EICRecommendationForm, SubmissionPoolFilterForm, FixCollegeDecisionForm, SubmissionPrescreeningForm, @@ -855,6 +856,42 @@ def cycle_form_submit(request, identifier_w_vn_nr): reverse('submissions:editorial_page', args=[submission.preprint.identifier_w_vn_nr])) +@login_required +@fellowship_or_admin_required() +def find_referee(request, identifier_w_vn_nr): + """ + Search for a referee in the set of Profiles, and if none is found, + create a new Profile and return to this page for further processing. + """ + submission = get_object_or_404(Submission.objects.filter_for_eic(request.user), + preprint__identifier_w_vn_nr=identifier_w_vn_nr) + context = {} + queryresults = '' + referee_search_form = RefereeSearchForm(request.POST or None) + if referee_search_form.is_valid(): + profiles_found = Profile.objects.filter( + last_name__icontains=ref_search_form.cleaned_data['last_name']) + context['profiles_found'] = profiles_found + # Check for recent co-authorship (thus referee disqualification) + try: + sub_auth_boolean_str = '((' + (submission + .metadata['entries'][0]['authors'][0]['name'] + .split()[-1]) + for author in submission.metadata['entries'][0]['authors'][1:]: + sub_auth_boolean_str += '+OR+' + author['name'].split()[-1] + sub_auth_boolean_str += ')+AND+' + search_str = sub_auth_boolean_str + ref_search_form.cleaned_data['last_name'] + ')' + queryurl = ('https://export.arxiv.org/api/query?search_query=au:%s' + % search_str + '&sortBy=submittedDate&sortOrder=descending' + '&max_results=5') + arxivquery = feedparser.parse(queryurl) + queryresults = arxivquery + except KeyError: + pass + context['ref_recruit_form'] = RefereeRecruitmentForm() + + +# The coming 3 methods are to be deprecated @login_required @fellowship_or_admin_required() def select_referee(request, identifier_w_vn_nr): @@ -875,7 +912,6 @@ def select_referee(request, identifier_w_vn_nr): contributors_found = Contributor.objects.filter( user__last_name__icontains=ref_search_form.cleaned_data['last_name']) context['contributors_found'] = contributors_found - # Check for recent co-authorship (thus referee disqualification) try: sub_auth_boolean_str = '((' + (submission @@ -964,14 +1000,15 @@ def recruit_referee(request, identifier_w_vn_nr): @transaction.atomic def send_refereeing_invitation(request, identifier_w_vn_nr, contributor_id, auto_reminders_allowed): - """Send RefereeInvitation to a registered Contributor. + """ + Send RefereeInvitation to a registered Contributor. This method is called by the EIC from the submission's editorial_page, in the case where the referee is an identified Contributor. For a referee who isn't a Contributor yet, the method recruit_referee above is called instead. - Accessible for: Editor-in-charge and Editorial Administration + Accessible for: Editor-in-charge and Editorial Administration. """ submission = get_object_or_404(Submission.objects.filter_for_eic(request.user), preprint__identifier_w_vn_nr=identifier_w_vn_nr)