diff --git a/scipost/models.py b/scipost/models.py index c12b89aeef5b5ad31b90d4392e8621db90eb99ae..a925ed715f670725427d9af124ef6fb432905bf2 100644 --- a/scipost/models.py +++ b/scipost/models.py @@ -286,6 +286,51 @@ class Contributor(models.Model): output += '</ul>' return mark_safe(output) + def assignments_summary_as_td(self): + assignments = self.editorialassignment_set.all() + nr_ongoing = assignments.filter(accepted=True, completed=False).count() + nr_last_12mo = assignments.filter( + date_created__gt=timezone.now() - timezone.timedelta(days=365)).count() + nr_accepted = assignments.filter(accepted=True).count() + nr_accepted_last_12mo = assignments.filter( + accepted=True, date_created__gt=timezone.now() - timezone.timedelta(days=365)).count() + nr_refused = assignments.filter(accepted=False).count() + nr_refused_last_12mo = assignments.filter( + accepted=False, date_created__gt=timezone.now() - timezone.timedelta(days=365)).count() + nr_ignored = assignments.filter(accepted=None).count() + nr_ignored_last_12mo = assignments.filter( + accepted=None, date_created__gt=timezone.now() - timezone.timedelta(days=365)).count() + nr_completed = assignments.filter(completed=True).count() + nr_completed_last_12mo = assignments.filter( + completed=True, date_created__gt=timezone.now() - timezone.timedelta(days=365)).count() + + context = Context({ + 'nr_ongoing': nr_ongoing, + 'nr_total': assignments.count(), + 'nr_last_12mo': nr_last_12mo, + 'nr_accepted': nr_accepted, + 'nr_accepted_last_12mo': nr_accepted_last_12mo, + 'nr_refused': nr_refused, + 'nr_refused_last_12mo': nr_refused_last_12mo, + 'nr_ignored': nr_ignored, + 'nr_ignored_last_12mo': nr_ignored_last_12mo, + 'nr_completed': nr_completed, + 'nr_completed_last_12mo': nr_completed_last_12mo, + }) + output = '<td>' + if self.expertises: + for expertise in self.expertises: + output += subject_areas_dict[expertise] + '<br/>' + output += ('</td>' + '<td>{{ nr_ongoing }}</td>' + '<td>{{ nr_last_12mo }} / {{ nr_total }}</td>' + '<td>{{ nr_accepted_last_12mo }} / {{ nr_accepted }}</td>' + '<td>{{ nr_refused_last_12mo }} / {{ nr_refused }}</td>' + '<td>{{ nr_ignored_last_12mo }} / {{ nr_ignored }}</td>' + '<td>{{ nr_completed_last_12mo }} / {{ nr_completed }}</td>\n') + template = Template(output) + return template.render(context) + class UnavailabilityPeriod(models.Model): contributor = models.ForeignKey(Contributor) diff --git a/scipost/static/scipost/SciPost.css b/scipost/static/scipost/SciPost.css index 211ca1b94fa6a5d84919104663ca2170320bbbe6..8a3a6b984e65f9c20169e683b9bb53245b4b972e 100644 --- a/scipost/static/scipost/SciPost.css +++ b/scipost/static/scipost/SciPost.css @@ -74,6 +74,24 @@ ul.personalTabMenu li a.inactive { border: none; } +.assignments_listing { + border-collapse: collapse; + margin: 0px 5px; + padding: 0px; +} +.assignments_listing tr { + background-color: #dddddd; + border: 1px solid black; +} +.assignments_listing td { + border: 1px solid black; + padding: 4px 8px; +} +.assignments_listing th { + border: 1px solid black; + padding: 4px 8px; +} + .commentcategorychoices { list-style-type: none; } diff --git a/scipost/templates/scipost/Fellow_activity_overview.html b/scipost/templates/scipost/Fellow_activity_overview.html new file mode 100644 index 0000000000000000000000000000000000000000..2810fe96902ccb33ced1afddd7c50fbc2712d841 --- /dev/null +++ b/scipost/templates/scipost/Fellow_activity_overview.html @@ -0,0 +1,59 @@ +{% extends 'scipost/base.html' %} + +{% block pagetitle %}: Overview{% endblock pagetitle %} + +{% block headsup %} + +{% endblock headsup %} + +{% block bodysup %} + +{% load scipost_extras %} + +<section> + <div class="flex-container"> + <div class="flex-greybox"> + <h1>Overview of Fellows's activities</h1> + </div> + </div> + <p>Click on a Fellow's name to view full assignment details.</p> + <table class="assignments_listing"> + <thead> + <th>Name</th> + <th>Expertises</th> + <th>Ongoing</th> + <th>Assignments<br/>last yr / tot</th> + <th>Accepted<br/>last yr / tot</th> + <th>Refused<br/>last yr / tot</th> + <th>Ignored<br/>last yr / tot</th> + <th>Fulfilled<br/>last yr / tot</th> + </thead> + <tbody> + {% for Fellow in Fellows %} + <tr> + <td><a href="{% url 'scipost:Fellow_activity_overview' Fellow_id=Fellow.id %}">{{ Fellow.user.last_name }}, {{ Fellow.user.first_name }}</a></td> + {{ Fellow.assignments_summary_as_td }} + </tr> + {% endfor %} + </tbody> + </table> + +</section> + +{% if Fellow %} +<section> + <div class="flex-container"> + <div class="flex-greybox"> + <h1>Overview of Fellows's activities</h1> + </div> + </div> + <h3>Assignments for {{ Fellow.user.first_name }} {{ Fellow.user.last_name }}</h3> + <ul> + {% for assignment in assignments_of_Fellow %} + {{ assignment.header_as_li }} + {% endfor %} + </ul> +</section> +{% endif %} + +{% endblock bodysup %} diff --git a/scipost/templates/scipost/personal_page.html b/scipost/templates/scipost/personal_page.html index d9bba4d3aa32842db2fcdabe4077bd733990b1bf..68693f70b44bdbc4d048e9b4f6d761582a38f571 100644 --- a/scipost/templates/scipost/personal_page.html +++ b/scipost/templates/scipost/personal_page.html @@ -237,6 +237,9 @@ {% if perms.scipost.can_manage_registration_invitations %} <li><a href="{% url 'scipost:registration_invitations' %}">Manage Registration Invitations</a></li> {% endif %} + </ul> + <h3>Email communications</h3> + <ul> {% if perms.scipost.can_email_group_members %} <li><a href="{% url 'scipost:email_group_members' %}">Email Group Members</a></li> {% endif %} @@ -272,6 +275,9 @@ <div class="col-4"> <h3>Submissions assignments</h3> <ul> + {% if perms.scipost.can_view_pool %} + <li><a href="{% url 'scipost:Fellow_activity_overview' %}">View assignments overview</a></li> + {% endif %} {% if perms.scipost.can_assign_submissions %} <li>Assign Submissions via the <a href="{% url 'submissions:pool' %}">Submissions Pool</a> ({{ nr_submissions_to_assign }})</li> {% endif %} @@ -291,7 +297,7 @@ <h3>Submissions for which you are Editor-in-charge</h3> <ul> {% for assignment in active_assignments %} - {{ assignment.header_as_li }} + {{ assignment.header_as_li_for_eic }} {% endfor %} </ul> {% endif %} diff --git a/scipost/templatetags/scipost_extras.py b/scipost/templatetags/scipost_extras.py index 6e208cf54ce4660b30acbada69a39208cbcba3ad..4875c0b9986b84021d3568ed13e6de1a41393d68 100644 --- a/scipost/templatetags/scipost_extras.py +++ b/scipost/templatetags/scipost_extras.py @@ -22,3 +22,4 @@ def is_in_group(user, group_name): group = Group.objects.get(name=group_name) return True if group in user.groups.all() else False + diff --git a/scipost/urls.py b/scipost/urls.py index 65bb7af5a6f1a35ce75dcf92136bacaca08a162a..fec9a206b14edba615814215f5677c04afdcdcfe 100644 --- a/scipost/urls.py +++ b/scipost/urls.py @@ -117,6 +117,12 @@ urlpatterns = [ # Editorial College # ##################### url(r'^EdCol_by-laws$', views.EdCol_bylaws, name='EdCol_by-laws'), + url(r'^Fellow_activity_overview/(?P<Fellow_id>[0-9]+)$', + views.Fellow_activity_overview, + name='Fellow_activity_overview'), + url(r'^Fellow_activity_overview$', + views.Fellow_activity_overview, + name='Fellow_activity_overview'), ################ # Publications # diff --git a/scipost/views.py b/scipost/views.py index 1a7ee74c8755882bbe38be1bbf0eb818a30a9b41..585708bc3d50f4749899e76bbaca23bbb96db886 100644 --- a/scipost/views.py +++ b/scipost/views.py @@ -375,7 +375,7 @@ def vet_registration_requests(request): contributors_to_vet = (Contributor.objects .filter(user__is_active=True, status=0) .order_by('key_expires')) - reg_cont_group = Group.objects.get(name='Registered Contributors') + reg_cont_group = Group.objects.get(name='Registered Contributors') # TODO: remove this line? form = VetRegistrationForm() context = {'contributors_to_vet': contributors_to_vet, 'form': form } return render(request, 'scipost/vet_registration_requests.html', context) @@ -1109,6 +1109,20 @@ def EdCol_bylaws(request): return render(request, 'scipost/EdCol_by-laws.html') +@permission_required('scipost.can_view_pool', return_403=True) +def Fellow_activity_overview(request, Fellow_id=None): + Fellows = Contributor.objects.filter( + user__groups__name='Editorial College').order_by('user__last_name') + context = {'Fellows': Fellows,} + if Fellow_id: + Fellow = get_object_or_404(Contributor, pk=Fellow_id) + context['Fellow'] = Fellow + assignments_of_Fellow = EditorialAssignment.objects.filter( + to=Fellow).order_by('-date_created') + context['assignments_of_Fellow'] = assignments_of_Fellow + return render(request, 'scipost/Fellow_activity_overview.html', context) + + ######### # Lists # ######### diff --git a/submissions/models.py b/submissions/models.py index 8dbc54dc4ee23a5b819a15a344a384d2ec048164..34f3c02de9a06668cbe305e09878764111370b31 100644 --- a/submissions/models.py +++ b/submissions/models.py @@ -398,7 +398,7 @@ class EditorialAssignment(models.Model): template = Template(info) return template.render(context) - def header_as_li(self): + def header_as_li_for_eic(self): header = ('<li><div class="flex-container">' '<div class="flex-whitebox0">' '<p><a href="/submission/{{ arxiv_identifier_w_vn_nr }}" ' @@ -417,6 +417,25 @@ class EditorialAssignment(models.Model): 'status': submission_status_dict[self.submission.status]}) return template.render(context) + def header_as_li(self): + """ Same as above, but without link to Editorial Page. """ + header = ('<li><div class="flex-container">' + '<div class="flex-whitebox0">' + '<p><a href="/submission/{{ arxiv_identifier_w_vn_nr }}" ' + 'class="pubtitleli">{{ title }}</a></p>' + '<p>by {{ author_list }}</p>' + '<p> (submitted {{ date }} to {{ to_journal }})</p>' + '<p>Status: {{ status }}</p>' + '</p></div></div></li>') + template = Template(header) + context = Context({'arxiv_identifier_w_vn_nr': self.submission.arxiv_identifier_w_vn_nr, + 'title': self.submission.title, + 'author_list': self.submission.author_list, + 'date': self.submission.submission_date, + 'to_journal': journals_submit_dict[self.submission.submitted_to_journal], + 'status': submission_status_dict[self.submission.status]}) + return template.render(context) + class RefereeInvitation(models.Model): submission = models.ForeignKey(Submission)