SciPost Code Repository

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

Improve refereeing process including vetting

parent 7a8098fe
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,9 @@ from django.contrib.auth.models import User, Group
from .models import *
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, Div, Field, Fieldset, HTML, Submit
class SubmissionForm(forms.ModelForm):
class Meta:
......@@ -52,8 +55,6 @@ class RefereeSelectForm(forms.Form):
last_name = forms.CharField()
# last_name=forms.CharField(widget=forms.TextInput(attrs={'size': 20, 'placeholder': 'search Contributors'}))
class RefereeRecruitmentForm(forms.ModelForm):
class Meta:
......@@ -64,6 +65,11 @@ class RefereeRecruitmentForm(forms.ModelForm):
super(RefereeRecruitmentForm, self).__init__(*args, **kwargs)
self.fields['first_name'].widget.attrs.update({'size': 20})
self.fields['last_name'].widget.attrs.update({'size': 20})
self.helper = FormHelper()
self.helper.layout = Layout(
Div(Field('title'), Field('first_name'), Field('last_name'), Field('email_address'),
css_class="flex-whitebox320")
)
class ConsiderRefereeInvitationForm(forms.Form):
......@@ -78,7 +84,7 @@ class ConsiderRefereeInvitationForm(forms.Form):
REPORT_ACTION_CHOICES = (
# (0, 'modify'),
(1, 'accept'),
(2, 'refuse (give reason below)'),
(2, 'refuse'),
)
REPORT_REFUSAL_CHOICES = (
......@@ -105,7 +111,10 @@ class ReportForm(forms.ModelForm):
class VetReportForm(forms.Form):
action_option = forms.ChoiceField(widget=forms.RadioSelect, choices=REPORT_ACTION_CHOICES, required=True, label='Action')
refusal_reason = forms.ChoiceField(choices=REPORT_REFUSAL_CHOICES)
refusal_reason = forms.ChoiceField(choices=REPORT_REFUSAL_CHOICES, required=False)
email_response_field = forms.CharField(widget=forms.Textarea(), label='Justification (optional)', required=False)
def __init__(self, *args, **kwargs):
super(VetReportForm, self).__init__(*args, **kwargs)
self.fields['email_response_field'].widget.attrs.update({'placeholder': 'Optional: give a textual justification (will be emailed to the Report\'s author)', 'rows': 3})
......@@ -299,7 +299,15 @@ class Report(models.Model):
return mark_safe(output)
def print_contents_for_editors(self):
output = ('<div class="row"><div class="col-2">Qualification:</p></div><div class="col-10"><p>' +
output = '<div class="reportid">\n'
output += '<h3><a id="report_id' + str(self.id) + '"></a>'
if self.anonymous:
output += '(chose public anonymity) '
output += ('<a href="/contributor/' + str(self.author.id) + '">' +
self.author.user.first_name + ' ' + self.author.user.last_name + '</a>')
output += ' on ' + self.date_submitted.strftime("%Y-%m-%d")
output += '</h3></div>'
output += ('<div class="row"><div class="col-2">Qualification:</p></div><div class="col-10"><p>' +
ref_qualif_dict[self.qualification] + '</p></div></div>')
output += self.print_contents()
output += '<h3>Recommendation: ' + report_rec_dict[self.recommendation] + '</h3>'
......
......@@ -43,16 +43,20 @@
{% if contributors_found %}
<h3>Identified as contributor:</h3>
{% for contributor in contributors_found %}
<p>{{ contributor.user.first_name }} {{ contributor.user.last_name }}
<a href="{% url 'submissions:send_refereeing_invitation' submission_id=submission.id contributor_id=contributor.id %}">Send refereeing invitation</a></p>
{% endfor %}
<table>
{% for contributor in contributors_found %}
<tr><td>{{ contributor.user.first_name }} {{ contributor.user.last_name }}</td><td>&nbsp;</td>
<td><a href="{% url 'submissions:send_refereeing_invitation' submission_id=submission.id contributor_id=contributor.id %}">Send refereeing invitation</a></td></tr>
{% endfor %}
</table>
{% elif ref_search_form.has_changed %}
<p>No Contributor with this last name could be identified.</p>
<br/>
<p>You can send a registration and refereeing invitation by filling this form:</p>
<form action="{% url 'submissions:recruit_referee' submission_id=submission.id %}" method="post">
{% csrf_token %}
{{ ref_recruit_form }}
{% load crispy_forms_tags %}
{% crispy ref_recruit_form %}
<input type="submit" value="Send invitation">
</form>
{% endif %}
......
......@@ -72,10 +72,10 @@
<div id="invitedreportslist">
{% for report in invited_reports %}
<hr class="hr6"/>
{{ report.print_identifier }}
{% if user|is_in_group:'Editorial College' %}
{{ report.print_contents_for_editors }}
{% else %}
{{ report.print_identifier }}
{{ report.print_contents }}
{% endif %}
......@@ -144,8 +144,12 @@
<div id="contributedreportslist">
{% for report in contributed_reports %}
<hr class="hr6"/>
{{ report.print_identifier }}
{{ report.print_contents }}
{% if user|is_in_group:'Editorial College' %}
{{ report.print_contents_for_editors }}
{% else %}
{{ report.print_identifier }}
{{ report.print_contents }}
{% endif %}
<hr style="border-style: dotted;" />
<h3><a href="{% url 'comments:reply_to_report' report_id=report.id %}">Reply to this Report</a> (authors only)</h3>
......
......@@ -2,6 +2,26 @@
{% block pagetitle %}: vet reports{% endblock pagetitle %}
{% block headsup %}
<script>
$(document).ready(function(){
$('#refusal').hide();
$('#id_action_option').on('change', function() {
if ($('#id_action_option_1').is(':checked')) {
$('#refusal').show();
}
else {
$('#refusal').hide();
}
});
});
</script>
{% endblock headsup %}
{% block bodysup %}
<section>
......@@ -25,27 +45,26 @@
<h4>Abstract:</h4>
<p>{{ report_to_vet.submission.abstract }}</p>
<hr style="border-style: dotted;" />
<h3>Report to vet:</h3>
<div class="row">
<div class="col-8">
<p>{{ report_to_vet.date_submitted }}</p>
<h4>Strengths:</h4>
<p>{{ report_to_vet.strengths }}</p>
<h4>Weaknesses:</h4>
<p>{{ report_to_vet.weaknesses }}</p>
<h4>Report:</h4>
<p>{{ report_to_vet.report }}</p>
<h4>Recommendation:</h4>
<p>{{ report_to_vet.recommendation }}</p>
</div>
<div class="col-4">
<form action="{% url 'submissions:vet_submitted_report_ack' report_id=report_to_vet.id %}" method="post">
{% csrf_token %}
{{ form.as_ul }}
<input type="submit" value="Submit" />
</form>
</div>
<div class="flex-greybox">
<h3>Report to vet:</h3>
</div>
{{ report_to_vet.print_contents_for_editors }}
<hr class="hr6"/>
<div class="flex-greaybox">
<h2>Please vet this Report:</h2>
</div>
<form action="{% url 'submissions:vet_submitted_report_ack' report_id=report_to_vet.id %}" method="post">
{% csrf_token %}
{{ form.action_option }}
<div id="refusal">
<ul>
<li>Refusal reason: {{ form.refusal_reason }}</li>
<li>{{ form.email_response_field }}</li>
</ul>
</div>
<input type="submit" value="Submit" />
</form>
{% endif %}
</section>
......
......@@ -224,7 +224,7 @@ def select_referee(request, submission_id):
if request.method == 'POST':
ref_search_form = RefereeSelectForm(request.POST)
if ref_search_form.is_valid():
contributors_found = Contributor.objects.filter(user__last_name=ref_search_form.cleaned_data['last_name'])
contributors_found = Contributor.objects.filter(user__last_name__icontains=ref_search_form.cleaned_data['last_name'])
else:
ref_search_form = RefereeSelectForm()
contributors_found = None
......@@ -246,6 +246,7 @@ def recruit_referee(request, submission_id):
if request.method == 'POST':
ref_recruit_form = RefereeRecruitmentForm(request.POST)
if ref_recruit_form.is_valid():
# TODO check if email already taken
ref_invitation = RefereeInvitation(submission=submission,
title=ref_recruit_form.cleaned_data['title'],
first_name=ref_recruit_form.cleaned_data['first_name'],
......@@ -337,6 +338,10 @@ def submit_report(request, submission_id):
if form.is_valid():
author = Contributor.objects.get(user=request.user)
invited = RefereeInvitation.objects.filter(submission=submission, referee=request.user.contributor).exists()
if invited:
invitation = RefereeInvitation.objects.get(submission=submission, referee=request.user.contributor)
invitation.fulfilled = True
invitation.save()
newreport = Report (
submission = submission,
author = author,
......
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