SciPost Code Repository

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

Add basic referee stats to `select_referee` view

parent d60c79fc
No related branches found
No related tags found
No related merge requests found
......@@ -2,10 +2,13 @@ __copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)"
__license__ = "AGPL v3"
import datetime
from django.urls import reverse
from django.db import models
from django.db.models.functions import Concat
from django.shortcuts import get_object_or_404
from django.utils import timezone
from scipost.behaviors import orcid_validator
from scipost.constants import TITLE_CHOICES, TITLE_DR
......@@ -139,6 +142,23 @@ class Profile(models.Model):
"""
return ThesisLink.objects.filter(author_as_cont__profile=self)
@property
def responsiveness_as_referee(self):
"""Simple stats on last 5 years' responsiveness as a referee."""
invitations = self.refereeinvitation_set.all()
if self.contributor:
invitations = invitations | self.contributor.referee_invitations.all()
invitations = invitations.distinct(
).filter(date_invited__gt=timezone.now() - datetime.timedelta(days=1825))
return {
"sent": invitations.count(),
"accepted": invitations.accepted().count(),
"declined": invitations.declined().count(),
"cancelled": invitations.filter(cancelled=True).count(),
"fulfilled": invitations.filter(fulfilled=True).count(),
}
class ProfileEmail(models.Model):
"""Any email related to a Profile instance."""
......
......@@ -90,9 +90,9 @@
<thead class="table-light">
<tr>
<th>Name<br/><br/></th>
<th>Registered Contributor?<br/><br/></th>
<th>Email known?<br/><br/></th>
<th>Accepts<br/>refereeing requests?</th>
<th>Registered<br>Contributor?<br/><br/></th>
<th>Email<br>known?<br/><br/></th>
<th>Accepts<br/>requests?</th>
<th>Action<br/><span class="text-muted fw-normal">(Unregistered people will also automatically receive a registration invitation)</span></th>
</tr>
</thead>
......@@ -125,6 +125,23 @@
{% endif %}
</td>
</tr>
{% with profile.responsiveness_as_referee as stats %}
{% if stats.sent %}
<tr>
<td colspan="5">
<em class="ms-4">
{% include "bi/arrow-return-right.html" %}&nbsp;
Responsiveness (last 5 years) --
Sent: {{ stats.sent }},&nbsp;
Accepted: {{ stats.accepted }},&nbsp;
Declined: {{ stats.declined }},&nbsp;
Cancelled: {{ stats.cancelled }},&nbsp;
Fulfilled: {{ stats.fulfilled }}
</em>
</td>
</tr>
{% endif %}
{% endwith %}
{% empty %}
<tr>
<td>No Profiles found</td>
......
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-return-right" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M1.5 1.5A.5.5 0 0 0 1 2v4.8a2.5 2.5 0 0 0 2.5 2.5h9.793l-3.347 3.346a.5.5 0 0 0 .708.708l4.2-4.2a.5.5 0 0 0 0-.708l-4-4a.5.5 0 0 0-.708.708L13.293 8.3H3.5A1.5 1.5 0 0 1 2 6.8V2a.5.5 0 0 0-.5-.5z"/>
</svg>
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