def test_calculate_total_report_hours(self): duration_list = [1, 1, 1, 1] report_list = [] total_hours = 0 report_list,total_hours = get_report_list(duration_list, report_list, total_hours) self.assertEqual( calculate_total_report_hours(report_list), total_hours ) duration_list = [0.03, 0.023, 0.53, 0.863, 0.23, 0.57] report_list = [] total_hours = 0 report_list,total_hours = get_report_list(duration_list, report_list, total_hours) self.assertEqual( calculate_total_report_hours(report_list), total_hours ) duration_list = [12, 24, 23.5, 15.67, 22.453, 3.42] report_list = [] total_hours = 0 report_list,total_hours = get_report_list(duration_list, report_list, total_hours) self.assertEqual( calculate_total_report_hours(report_list), total_hours ) duration_list = [5] report_list = [] total_hours = 0 report_list,total_hours = get_report_list(duration_list, report_list, total_hours) self.assertEqual( calculate_total_report_hours(report_list), total_hours ) duration_list = [0, 0, 0, 0] report_list = [] total_hours = 0 report_list,total_hours = get_report_list(duration_list, report_list, total_hours) self.assertEqual( calculate_total_report_hours(report_list), total_hours )
def test_calculate_total_report_hours(self): duration_list = [1, 1, 1, 1] report_list = [] total_hours = 0 report_list, total_hours = get_report_list(duration_list, report_list, total_hours) self.assertEqual(calculate_total_report_hours(report_list), total_hours) duration_list = [0.03, 0.023, 0.53, 0.863, 0.23, 0.57] report_list = [] total_hours = 0 report_list, total_hours = get_report_list(duration_list, report_list, total_hours) self.assertEqual(calculate_total_report_hours(report_list), total_hours) duration_list = [12, 24, 23.5, 15.67, 22.453, 3.42] report_list = [] total_hours = 0 report_list, total_hours = get_report_list(duration_list, report_list, total_hours) self.assertEqual(calculate_total_report_hours(report_list), total_hours) duration_list = [5] report_list = [] total_hours = 0 report_list, total_hours = get_report_list(duration_list, report_list, total_hours) self.assertEqual(calculate_total_report_hours(report_list), total_hours) duration_list = [0, 0, 0, 0] report_list = [] total_hours = 0 report_list, total_hours = get_report_list(duration_list, report_list, total_hours) self.assertEqual(calculate_total_report_hours(report_list), total_hours)
def post(self, request, *args, **kwargs): volunteer_id = self.kwargs['volunteer_id'] volunteer = get_volunteer_by_id(volunteer_id) event_list = get_signed_up_events_for_volunteer(volunteer_id) job_list = get_signed_up_jobs_for_volunteer(volunteer_id) event_name = self.request.POST['event_name'] job_name = self.request.POST['job_name'] start_date = self.request.POST['start_date'] end_date = self.request.POST['end_date'] volunteer_shift_list = get_volunteer_shifts(volunteer_id, event_name, job_name, start_date, end_date) if volunteer_shift_list: report_list = generate_report(volunteer_shift_list) total_hours = calculate_total_report_hours(report_list) report = Report.objects.create(total_hrs=total_hours, volunteer=volunteer) report.volunteer_shifts.add(*volunteer_shift_list) report.save() return render(request, 'volunteer/report.html', { 'report_list': report_list, 'total_hours': total_hours, 'notification': True, 'job_list': job_list, 'event_list': event_list, 'selected_event': event_name, 'selected_job': job_name }) else: return render(request, 'volunteer/report.html', { 'job_list': job_list, 'event_list': event_list, 'notification': True, })
def post(self, request, *args, **kwargs): volunteer_id = self.kwargs['volunteer_id'] event_list = get_signed_up_events_for_volunteer(volunteer_id) job_list = get_signed_up_jobs_for_volunteer(volunteer_id) event_name = self.request.POST['event_name'] job_name = self.request.POST['job_name'] start_date = self.request.POST['start_date'] end_date = self.request.POST['end_date'] report_list = get_volunteer_report(volunteer_id, event_name, job_name, start_date, end_date) total_hours = calculate_total_report_hours(report_list) return render( request, 'volunteer/report.html', { 'report_list': report_list, 'total_hours': total_hours, 'notification': True, 'job_list': job_list, 'event_list': event_list, 'selected_event': event_name, 'selected_job': job_name })
def post(self, request, *args, **kwargs): report_list = get_administrator_report( self.request.POST['first_name'], self.request.POST['last_name'], self.request.POST['organization'], self.request.POST['event_name'], self.request.POST['job_name'], self.request.POST['start_date'], self.request.POST['end_date'], ) organization = self.request.POST['organization'] event_name = self.request.POST['event_name'] total_hours = calculate_total_report_hours(report_list) return render( request, 'administrator/report.html', { 'report_list': report_list, 'total_hours': total_hours, 'notification': True, 'organization_list': self.organization_list, 'selected_organization': organization, 'event_list': self.event_list, 'selected_event': event_name, 'job_list': self.job_list })
def post(self, request, *args, **kwargs): volunteer_id = self.kwargs['volunteer_id'] volunteer = get_volunteer_by_id(volunteer_id) event_list = get_signed_up_events_for_volunteer(volunteer_id) job_list = get_signed_up_jobs_for_volunteer(volunteer_id) event_name = self.request.POST['event_name'] job_name = self.request.POST['job_name'] start_date = self.request.POST['start_date'] end_date = self.request.POST['end_date'] volunteer_shift_list = get_volunteer_shifts(volunteer_id, event_name, job_name, start_date, end_date) if volunteer_shift_list: report_list = generate_report(volunteer_shift_list) total_hours = calculate_total_report_hours(report_list) report = Report.objects.create(total_hrs=total_hours, volunteer=volunteer) report.volunteer_shifts.add(*volunteer_shift_list) report.save() return render( request, 'volunteer/report.html', { 'report_list': report_list, 'total_hours': total_hours, 'notification': True, 'job_list': job_list, 'event_list': event_list, 'selected_event': event_name, 'selected_job': job_name }) else: return render( request, 'volunteer/report.html', { 'job_list': job_list, 'event_list': event_list, 'notification': True, })
def test_calculate_total_report_hours(self): duration_list = [1, 1, 1, 1] report_list = [] total_hours = 0 for duration in duration_list: total_hours += duration report = {} report["duration"] = duration report_list.append(report) self.assertEqual(calculate_total_report_hours(report_list), total_hours) duration_list = [1.5, 1.34, 2.3, 9, 4.7] report_list = [] total_hours = 0 for duration in duration_list: total_hours += duration report = {} report["duration"] = duration report_list.append(report) self.assertEqual(calculate_total_report_hours(report_list), total_hours) duration_list = [0.03, 0.023, 0.53, 0.863, 0.23, 0.57] report_list = [] total_hours = 0 for duration in duration_list: total_hours += duration report = {} report["duration"] = duration report_list.append(report) self.assertEqual(calculate_total_report_hours(report_list), total_hours) duration_list = [12, 24, 23.5, 15.67, 22.453, 3.42] report_list = [] total_hours = 0 for duration in duration_list: total_hours += duration report = {} report["duration"] = duration report_list.append(report) self.assertEqual(calculate_total_report_hours(report_list), total_hours) duration_list = [5] report_list = [] total_hours = 0 for duration in duration_list: total_hours += duration report = {} report["duration"] = duration report_list.append(report) self.assertEqual(calculate_total_report_hours(report_list), total_hours) duration_list = [0, 0, 0, 0] report_list = [] total_hours = 0 for duration in duration_list: total_hours += duration report = {} report["duration"] = duration report_list.append(report) self.assertEqual(calculate_total_report_hours(report_list), total_hours) duration_list = [0] report_list = [] total_hours = 0 for duration in duration_list: total_hours += duration report = {} report["duration"] = duration report_list.append(report) self.assertEqual(calculate_total_report_hours(report_list), total_hours)