From 1dc906ba2ea5ac95479054ed9ce079fba1022555 Mon Sep 17 00:00:00 2001 From: JessicaVDussault Date: Thu, 11 May 2023 13:27:08 -0500 Subject: [PATCH 1/2] changes import to shorten references (style not substance change) --- tock/hours/tests/test_views.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/tock/hours/tests/test_views.py b/tock/hours/tests/test_views.py index 3f9f596b..a17c5a7e 100644 --- a/tock/hours/tests/test_views.py +++ b/tock/hours/tests/test_views.py @@ -3,7 +3,6 @@ from decimal import Decimal import hours.models -import projects.models from api.tests import client from api.views import ProjectSerializer, UserDataSerializer from django.conf import settings @@ -17,6 +16,7 @@ from hours.views import (GeneralSnippetsTimecardSerializer, ReportsList, TimecardView) from organizations.models import Organization, Unit +from projects.models import AccountingCode, Project User = get_user_model() @@ -71,7 +71,7 @@ def test_project_csv(self): def test_general_snippets(self): """Test that snippets are returned in correct CSV format.""" - project = projects.models.Project.objects.get_or_create( + project = Project.objects.get_or_create( name='General' )[0] tco = hours.models.TimecardObject.objects.first() @@ -212,10 +212,10 @@ def setUp(self): self.nonbillable_project = hours.models.Project.objects.filter( accounting_code__billable=False )[0] - self.billable_project = projects.models.Project.objects.filter( + self.billable_project = Project.objects.filter( accounting_code__billable=True )[0] - self.excluded_project = projects.models.Project.objects.filter( + self.excluded_project = Project.objects.filter( exclude_from_billability=True )[0] self.timecard_obj_0 = hours.models.TimecardObject.objects.create( @@ -268,9 +268,8 @@ def setUp(self): user=self.user, submitted=True, reporting_period=self.reporting_period) - self.project_1 = projects.models.Project.objects.get(name="openFEC") - self.project_2 = projects.models.Project.objects.get( - name="Peace Corps") + self.project_1 = Project.objects.get(name="openFEC") + self.project_2 = Project.objects.get(name="Peace Corps") self.timecard_object_1 = hours.models.TimecardObject.objects.create( timecard=self.timecard, project=self.project_1, @@ -498,23 +497,23 @@ def test_project_choice_filtering(self): org_coe = Organization.objects.create(name='CoE') org_coe.save() - accounting_code = projects.models.AccountingCode.objects.get(pk=1) + accounting_code = AccountingCode.objects.get(pk=1) - project_18f = projects.models.Project.objects.create( + project_18f = Project.objects.create( name='an 18f project', accounting_code=accounting_code, organization=org_18f ) project_18f.save() - project_coe = projects.models.Project.objects.create( + project_coe = Project.objects.create( name='a coe project', accounting_code=accounting_code, organization=org_coe ) project_coe.save() - project_none = projects.models.Project.objects.create( + project_none = Project.objects.create( name='a project with no org assignment', accounting_code=accounting_code, ) @@ -687,7 +686,7 @@ def test_do_not_prefill_timecard(self): submitted=False, reporting_period=new_period ) - new_project = projects.models.Project.objects.get(name="Midas") + new_project = Project.objects.get(name="Midas") new_tco = hours.models.TimecardObject.objects.create( timecard=new_timecard, project=new_project, @@ -1013,9 +1012,9 @@ def setUp(self): user=self.user ) - self.project_1 = projects.models.Project.objects.first() + self.project_1 = Project.objects.first() self.project_1.save() - self.project_2 = projects.models.Project.objects.last() + self.project_2 = Project.objects.last() self.project_2.save() self.pfd1 = hours.models.TimecardPrefillData.objects.create( From c330adc93ddbbdf7ad84078be843c681dd2a0c9b Mon Sep 17 00:00:00 2001 From: JessicaVDussault Date: Thu, 11 May 2023 13:32:11 -0500 Subject: [PATCH 2/2] adds or updates allocation to user pages updates test to include allocation total note that project allocation differs from billable allocation --- tock/hours/tests/test_views.py | 16 ++++++++++++---- tock/hours/views.py | 1 + .../templates/employees/user_recent_tocks.html | 14 +++++++++++--- .../hours/reporting_period_user_detail.html | 5 ++++- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/tock/hours/tests/test_views.py b/tock/hours/tests/test_views.py index a17c5a7e..12d394ca 100644 --- a/tock/hours/tests/test_views.py +++ b/tock/hours/tests/test_views.py @@ -218,6 +218,8 @@ def setUp(self): self.excluded_project = Project.objects.filter( exclude_from_billability=True )[0] + self.weekly_billable_project = Project.objects.get(name="Weekly Billing") + self.timecard_obj_0 = hours.models.TimecardObject.objects.create( timecard=self.timecard, project=self.nonbillable_project, @@ -226,13 +228,18 @@ def setUp(self): self.timecard_obj_1 = hours.models.TimecardObject.objects.create( timecard=self.timecard, project=self.billable_project, - hours_spent=27 + hours_spent=10 ) self.timecard_obj_2 = hours.models.TimecardObject.objects.create( timecard=self.timecard, project=self.excluded_project, hours_spent=2 ) + self.timecard_obj_3 = hours.models.TimecardObject.objects.create( + timecard=self.timecard, + project=self.weekly_billable_project, + project_allocation=0.5 + ) self.timecard.save() def test_user_reporting_period_report(self): @@ -241,12 +248,13 @@ def test_user_reporting_period_report(self): 'reports:ReportingPeriodUserDetailView', kwargs={'reporting_period':'1999-12-31', 'username':'aaron.snow'} )) - self.assertEqual(response.context['user_utilization'], Decimal('0.90')) + self.assertEqual(response.context['user_utilization'], Decimal('0.83')) self.assertEqual(response.context['user_target_hours'], 30.00) - self.assertEqual(response.context['user_billable_hours'], 27) + self.assertEqual(response.context['user_billable_hours'], 10) self.assertEqual(response.context['user_non_billable_hours'], 11) + self.assertEqual(response.context['user_weekly_allocation'], Decimal('0.5')) self.assertEqual(response.context['user_excluded_hours'], 2) - self.assertContains(response, '90%') + self.assertContains(response, '83%') @override_settings(STARTING_FY_FOR_REPORTS_PAGE=2015) class ReportTests(WebTest): diff --git a/tock/hours/views.py b/tock/hours/views.py index 2961cc87..c8eb6a53 100644 --- a/tock/hours/views.py +++ b/tock/hours/views.py @@ -802,6 +802,7 @@ def get_context_data(self, **kwargs): context = super( ReportingPeriodUserDetailView, self).get_context_data(**kwargs) context['user_billable_hours'] = timecard.billable_hours + context['user_weekly_allocation'] = timecard.total_weekly_allocation context['user_non_billable_hours'] = timecard.non_billable_hours context['user_excluded_hours'] = timecard.excluded_hours context['user_target_hours'] = timecard.target_hours diff --git a/tock/tock/templates/employees/user_recent_tocks.html b/tock/tock/templates/employees/user_recent_tocks.html index 3214531b..8a0fc5bb 100644 --- a/tock/tock/templates/employees/user_recent_tocks.html +++ b/tock/tock/templates/employees/user_recent_tocks.html @@ -26,7 +26,7 @@

Recent Tocks

Totals - Billable + Billable Hours {% for i in recent_timecards %} {% with recent_timecards|index:forloop.counter0 as tc %} {{tc.billable_hours}} @@ -34,14 +34,22 @@

Recent Tocks

{% endfor %} - Non-Billable + + Billable Allocation {% for i in recent_timecards %} {% with recent_timecards|index:forloop.counter0 as tc %} - {{tc.non_billable_hours}} + {% widthratio tc.total_weekly_allocation 1 100 %}% {% endwith %} {% endfor %} + Non-Billable Hours + {% for i in recent_timecards %} + {% with recent_timecards|index:forloop.counter0 as tc %} + {{tc.non_billable_hours}} + {% endwith %} + {% endfor %} + Excluded from Utilization {% for i in recent_timecards %} {% with recent_timecards|index:forloop.counter0 as tc %} diff --git a/tock/tock/templates/hours/reporting_period_user_detail.html b/tock/tock/templates/hours/reporting_period_user_detail.html index 1f96841f..daee177c 100644 --- a/tock/tock/templates/hours/reporting_period_user_detail.html +++ b/tock/tock/templates/hours/reporting_period_user_detail.html @@ -30,7 +30,8 @@

{{ object.user }}'s time from {{ object.reporting_period.start_date }} to {{ {% endif %} {{ entry.hours_spent }} - {{ entry.project_allocation }} + {% widthratio entry.project_allocation 1 100 %}% + {% for note in entry.notes_list %}

{{ note }}

@@ -58,6 +59,7 @@

Reporting Period Summary

Billable Hours + Billable Allocation Non-Billable Hours Excluded Hours Target Hours @@ -67,6 +69,7 @@

Reporting Period Summary

{{ user_billable_hours }} + {% widthratio user_weekly_allocation 1 100 %}% {{ user_non_billable_hours }} {{ user_excluded_hours }} {{ user_target_hours }}