def approve_overtime_plan(request, overtime_plan_id): approver = request.user overtime_plan = get_overtime_plan(overtime_plan_id) approved_overtime_plan = approve_overtime_plan_service(approver, overtime_plan) if approved_overtime_plan: messages.success(request, "You approved %s's overtime plan" % approved_overtime_plan.applicant) else: messages.error(request, "You are not associated to any role on the system") return HttpResponseRedirect(reverse(approve_overtime_plans_page))
def pending_overtime_plan_page(request, overtime_plan_id): overtime_plan = get_overtime_plan(overtime_plan_id) overtime_schedules = get_overtime_schedules(overtime_plan) context = { "overtime_page": "active", "overtime_plan": overtime_plan, "overtime_schedules": overtime_schedules } return render(request, 'overtime/pending_overtime_plan.html', context)
def add_overtime_schedule_page(request, overtime_plan_id): overtime_plan = get_overtime_plan(overtime_plan_id) if request.POST: employee_id = request.POST["employee"] employee = get_employee(employee_id) date = request.POST["date"] number_of_hours = request.POST["number_of_hours"] description = request.POST["description"] OvertimeSchedule.objects.create( employee=employee, overtime_plan=overtime_plan, date=date, number_of_hours=number_of_hours, description=description, ) return HttpResponseRedirect(reverse(add_overtime_schedule_page, args=[overtime_plan.id])) context = { "employees": get_active_employees(), "overtime_schedules": get_overtime_schedules(overtime_plan) } return render(request, 'overtime/add_employee_schedules.html', context)