def __init__(self, task, month, year, employee):
total_duration = 0
self.id = task.id
self.name = task.name
self.durations = [(0, 0) for _ in range(0, calendar.monthrange(year, month)[1])]
time_logs = TimeLog.objects.filter(workDate__year__gte=year,
workDate__month__gte=month,
workDate__year__lte=year,
workDate__month__lte=month,
task_id=task.id,
employee_id=employee)
for tl in time_logs:
index = int(tl.workDate.day)-1
self.durations[index] = (tl.duration, tl.id)
total_duration += tl.duration
self.durations.append((total_duration, 0))
评论列表
文章目录