diff --git a/production/templates/production/_production_timesheet_card.html b/production/templates/production/_production_timesheet_card.html new file mode 100644 index 0000000000000000000000000000000000000000..fcb30532b488a1c1aac300d0b2ff74b0df9885d7 --- /dev/null +++ b/production/templates/production/_production_timesheet_card.html @@ -0,0 +1,30 @@ +{% load bootstrap %} + +<div class="card-block"> + <table class="table mb-5"> + <thead class="thead-default"> + <tr> + <th>Date</th> + <th>Stream</th> + <th>Event</th> + <th>Duration</th> + </tr> + </thead> + <tbody role="tablist"> + {% for event in events %} + {% if event.duration %} + <tr> + <td>{{ event.noted_on }}</td> + <td>{{ event.stream }}</td> + <td>{{ event.get_event_display }}</td> + <td>{{ event.duration }}</td> + </tr> + {% endif %} + {% empty %} + <tr> + <td colspan="4">No events found.</td> + </tr> + {% endfor %} + </tbody> + </table> +</div> diff --git a/production/templates/production/production.html b/production/templates/production/production.html index 40f12bcc417bf4cee25452b0d8bf2651efef68b7..c748477f0602c7fa9752847ad328fc7915bb4869 100644 --- a/production/templates/production/production.html +++ b/production/templates/production/production.html @@ -13,21 +13,147 @@ <div class="row"> <div class="col-12"> - <h1 class="highlight">Manuscripts under production</h1> + <h1 class="highlight">Production</h1> </div> </div> + + <div class="row"> <div class="col-12"> - <ul class="list-group list-group-flush"> - {% for stream in streams %} - <li class="list-group-item{% if not forloop.first %} pt-3{% endif %}"> - {% include 'production/_production_stream_card.html' with stream=stream form=prodevent_form %} - </li> - {% empty %} - <li class="list-group-item">No production streams found.</li> - {% endfor %} - </ul> + <div class="tab-nav-container"> + <div class="tab-nav-inner"> + <ul class="nav btn-group personal-page-nav" role="tablist"> + <li class="nav-item btn btn-secondary"> + <a href="#streams" class="nav-link active" data-toggle="tab">Streams</a> + </li> + <li class="nav-item btn btn-secondary"> + <a href="#mytimesheet" class="nav-link" data-toggle="tab">My Timesheet</a> + </li> + {% if perms.scipost.can_view_timesheets %} + <li class="nav-item btn btn-secondary"> + <a href="#teamtimesheets" class="nav-link" data-toggle="tab">Team Timesheets</a> + </li> + {% endif %} + </ul> + </div> + </div> + </div> +</div> + + +<div class="tab-content"> + <div class="tab-pane active" id="streams" role="tabpanel"> + <div class="row"> + <div class="col-12"> + <h2 class="highlight">Streams</h2> + </div> + </div> + + <table class="table table-hover mb-5"> + <thead class="thead-default"> + <tr> + <th>Authors</th> + <th>Title</th> + <th>Accepted</th> + <th>Latest Event</th> + <th>Date</th> + </tr> + </thead> + + <tbody id="accordion" role="tablist" aria-multiselectable="true"> + {% for stream in streams %} + <tr data-toggle="collapse" data-parent="#accordion" href="#collapse{{ stream.id }}" aria-expanded="true" aria-controls="collapse{{ stream.id }}" style="cursor: pointer;"> + <td>{{ stream.submission.author_list }}</td> + <td>{{ stream.submission.title }}</td> + <td>{{ stream.submission.acceptance_date|date:"Y-m-d" }}</td> + <td>{{ stream.productionevent_set.last.get_event_display }}</td> + <td>{{ stream.productionevent_set.last.noted_on }}</td> + </tr> + <tr id="collapse{{ stream.id }}" class="collapse" role="tabpanel" aria-labelledby="heading{{ stream.id }}" style="background-color: #fff;"> + <td colspan="5"> + {% include 'production/_production_stream_card.html' with stream=stream form=prodevent_form %} + </td> + </tr> + {% empty %} + <tr> + <td colspan="5">No production streams found.</td> + </tr> + {% endfor %} + </tbody> + </table> </div> + + + <div class="tab-pane" id="mytimesheet" role="tabpanel"> + <div class="row"> + <div class="col-12"> + <h2 class="highlight">My Timesheet</h2> + </div> + </div> + + <table class="table mb-5"> + <thead class="thead-default"> + <tr> + <th>Date</th> + <th>Stream</th> + <th>Event</th> + <th>Duration</th> + </tr> + </thead> + + <tbody role="tablist"> + {% for event in ownevents %} + <tr> + <td>{{ event.noted_on }}</td> + <td>{{ event.stream }}</td> + <td>{{ event.get_event_display }}</td> + <td>{{ event.duration }}</td> + </tr> + {% empty %} + <tr> + <td colspan="4">No events found.</td> + </tr> + {% endfor %} + </tbody> + </table> + </div> + + {% if perms.scipost.can_view_timesheets %} + <div class="tab-pane" id="teamtimesheets" role="tabpanel"> + <div class="row"> + <div class="col-12"> + <h2 class="highlight">Team Timesheets</h2> + </div> + </div> + + <table class="table table-hover mb-5"> + <thead class="thead-default"> + <tr> + <th>Name</th> + </tr> + </thead> + + <tbody id="accordion" role="tablist" aria-multiselectable="true"> + {% for member in production_team.all %} + <tr data-toggle="collapse" data-parent="#accordion" href="#collapse{{ member.id }}" aria-expanded="true" aria-controls="collapse{{ member.id }}" style="cursor: pointer;"> + <td>{{ member }}</td> + </tr> + <tr id="collapse{{ member.id }}" class="collapse" role="tabpanel" aria-labelledby="heading{{ member.id }}" style="background-color: #fff;"> + <td> + {% include 'production/_production_timesheet_card.html' with events=member.productionevent_set.all %} + </td> + </tr> + {% empty %} + <tr> + <td>No Team Member found.</td> + </tr> + {% endfor %} + </tbody> + </table> + + </div> + {% endif %} + </div> {% endblock content %} diff --git a/production/views.py b/production/views.py index 0a7536f6a3c0f4de8f0e0e13250ddfc462497e09..06c723470234e8d9acf18dddf4a589860526be55 100644 --- a/production/views.py +++ b/production/views.py @@ -1,4 +1,7 @@ +import datetime + from django.contrib import messages +from django.contrib.auth.models import Group from django.core.urlresolvers import reverse from django.shortcuts import get_object_or_404, render, redirect from django.utils import timezone @@ -11,6 +14,8 @@ from .constants import PRODUCTION_STREAM_COMPLETED from .models import ProductionStream, ProductionEvent from .forms import ProductionEventForm +from scipost.models import Contributor + ###################### # Production process # @@ -24,10 +29,17 @@ def production(request): """ streams = ProductionStream.objects.ongoing().order_by('opened') prodevent_form = ProductionEventForm() + ownevents = ProductionEvent.objects.filter( + noted_by=request.user.contributor, + duration__gte=datetime.timedelta(minutes=1)).order_by('-noted_on') context = { 'streams': streams, 'prodevent_form': prodevent_form, + 'ownevents': ownevents, } + if request.user.has_perm('scipost.can_view_timesheets'): + context['production_team'] = Contributor.objects.filter( + user__groups__name='Production Officers').order_by('user__last_name') return render(request, 'production/production.html', context) diff --git a/scipost/management/commands/add_groups_and_permissions.py b/scipost/management/commands/add_groups_and_permissions.py index 0b00a69fd2d49ea18156d9582d347a95da58ac13..d3d038c9c4facfd50eb84c6d950e4be179c5613a 100644 --- a/scipost/management/commands/add_groups_and_permissions.py +++ b/scipost/management/commands/add_groups_and_permissions.py @@ -200,6 +200,12 @@ class Command(BaseCommand): name='Can view docs: scipost', content_type=content_type) + # Financial administration + can_view_timesheets, created = Permission.objects.get_or_create( + codename='can_view_timesheets', + name='Can view timesheets', + content_type=content_type) + # Mailchimp can_manage_mailchimp, created = Permission.objects.get_or_create( codename='can_manage_mailchimp', @@ -223,12 +229,19 @@ class Command(BaseCommand): can_fix_College_decision, can_view_production, can_attend_VGMs, + can_view_timesheets, can_manage_mailchimp, ]) + + FinancialAdmin.permissions.set([ + can_view_timesheets, + ]) + AdvisoryBoard.permissions.set([ can_manage_registration_invitations, can_attend_VGMs, ]) + EditorialAdmin.permissions.set([ can_view_pool, can_assign_submissions, @@ -236,9 +249,11 @@ class Command(BaseCommand): can_prepare_recommendations_for_voting, can_fix_College_decision, can_view_production, + can_view_timesheets, can_publish_accepted_submission, can_attend_VGMs, ]) + EditorialCollege.permissions.set([ can_view_pool, can_take_charge_of_submissions, @@ -246,12 +261,14 @@ class Command(BaseCommand): view_bylaws, can_attend_VGMs, ]) + VettingEditors.permissions.set([ can_vet_commentary_requests, can_vet_thesislink_requests, can_vet_authorship_claims, can_vet_comments, ]) + RegisteredContributors.permissions.set([ can_submit_manuscript, can_submit_comments, @@ -260,15 +277,19 @@ class Command(BaseCommand): can_request_thesislinks, can_referee, ]) + Developers.permissions.set([ can_view_docs_scipost, ]) + Ambassadors.permissions.set([ can_manage_registration_invitations, ]) + JuniorAmbassadors.permissions.set([ can_draft_registration_invitations, ]) + ProductionOfficers.permissions.set([ can_view_docs_scipost, can_view_production, @@ -282,12 +303,14 @@ class Command(BaseCommand): can_email_prospartner_contact, can_view_partners, ]) + PartnersOfficers.permissions.set([ can_read_partner_page, can_view_own_partner_details, can_manage_SPB, can_view_partners, ]) + PartnerAccounts.permissions.set([ can_read_partner_page, can_view_own_partner_details, diff --git a/scipost/templates/scipost/personal_page.html b/scipost/templates/scipost/personal_page.html index 32fcb4a45dd902f6925bd7211eb46b5be3e1cece..10485656d0002f7454cde5e7ea1622550195c7aa 100644 --- a/scipost/templates/scipost/personal_page.html +++ b/scipost/templates/scipost/personal_page.html @@ -99,40 +99,43 @@ {% endif %} </div> <div class="col-md-6"> - {% if 'SciPost Administrators' in user_groups %} - <h3>You are a SciPost Administrator.</h3> - {% endif %} - {% if 'Editorial Administrators' in user_groups %} - <h3>You are a SciPost Editorial Administrator.</h3> - {% endif %} - {% if 'Advisory Board' in user_groups %} - <h3>You are a member of the Advisory Board.</h3> - {% endif %} - {% if 'Editorial College' in user_groups %} - <h3>You are a member of the Editorial College.</h3> - {% endif %} - {% if 'Vetting Editors' in user_groups %} - <h3>You are a SciPost Vetting Editor.</h3> - {% endif %} - {% if 'Registered Contributors' in user_groups %} - <h3>You are a Registered Contributor.</h3> - {% endif %} - {% if 'Testers' in user_groups %} - <h3>You are a SciPost Tester.</h3> - {% endif %} - {% if 'Ambassadors' in user_groups %} - <h3>You are a SciPost Ambassador.</h3> - {% endif %} - {% if 'Junior Ambassadors' in user_groups %} - <h3>You are a SciPost Junior Ambassador.</h3> - {% endif %} - - <h3 class="mt-3">Update your personal data or password</h3> - - <ul> - <li><a href="{% url 'scipost:update_personal_data' %}">Update your personal data</a></li> - <li><a href="{% url 'scipost:change_password' %}">Change your password</a></li> - </ul> + {% if 'SciPost Administrators' in user_groups %} + <h3>You are a SciPost Administrator.</h3> + {% endif %} + {% if 'Editorial Administrators' in user_groups %} + <h3>You are a SciPost Editorial Administrator.</h3> + {% endif %} + {% if 'Advisory Board' in user_groups %} + <h3>You are a member of the Advisory Board.</h3> + {% endif %} + {% if 'Editorial College' in user_groups %} + <h3>You are a member of the Editorial College.</h3> + {% endif %} + {% if 'Vetting Editors' in user_groups %} + <h3>You are a SciPost Vetting Editor.</h3> + {% endif %} + {% if 'Registered Contributors' in user_groups %} + <h3>You are a Registered Contributor.</h3> + {% endif %} + {% if 'Testers' in user_groups %} + <h3>You are a SciPost Tester.</h3> + {% endif %} + {% if 'Ambassadors' in user_groups %} + <h3>You are a SciPost Ambassador.</h3> + {% endif %} + {% if 'Junior Ambassadors' in user_groups %} + <h3>You are a SciPost Junior Ambassador.</h3> + {% endif %} + {% if 'Production Officers' in user_groups %} + <h3>You are a SciPost Production Officer.</h3> + {% endif %} + + <h3 class="mt-3">Update your personal data or password</h3> + + <ul> + <li><a href="{% url 'scipost:update_personal_data' %}">Update your personal data</a></li> + <li><a href="{% url 'scipost:change_password' %}">Change your password</a></li> + </ul> </div> </div>