diff --git a/scipost_django/profiles/models.py b/scipost_django/profiles/models.py index 8646d93e08fe843920e70b9e0b905fd7a978e811..7b1b90fd9a5c38a2ac49e1a23a93b43637016ec0 100644 --- a/scipost_django/profiles/models.py +++ b/scipost_django/profiles/models.py @@ -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.""" diff --git a/scipost_django/submissions/templates/submissions/select_referee.html b/scipost_django/submissions/templates/submissions/select_referee.html index 419988ce4c92abd15b812ce57f2170b1d9b8dd03..f17f4351fe1dcc5c0639905ad6fe743166e6f4d0 100644 --- a/scipost_django/submissions/templates/submissions/select_referee.html +++ b/scipost_django/submissions/templates/submissions/select_referee.html @@ -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" %} + Responsiveness (last 5 years) -- + Sent: {{ stats.sent }}, + Accepted: {{ stats.accepted }}, + Declined: {{ stats.declined }}, + Cancelled: {{ stats.cancelled }}, + Fulfilled: {{ stats.fulfilled }} + </em> + </td> + </tr> + {% endif %} + {% endwith %} {% empty %} <tr> <td>No Profiles found</td> diff --git a/scipost_django/templates/bi/arrow-return-right.html b/scipost_django/templates/bi/arrow-return-right.html new file mode 100644 index 0000000000000000000000000000000000000000..9a76dfb14fe73bea1d4497748c3efd7a4028e139 --- /dev/null +++ b/scipost_django/templates/bi/arrow-return-right.html @@ -0,0 +1,3 @@ +<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>