def timer(request): if request.user.is_authenticated(): today = datetime.now().date() duration = TaskInterval.get_hours(request.user, today) running = TaskInterval.is_running(request.user) info = dict(hours_today="%.2f" % duration, running=running) return dict(timer=info) return dict()
def get_time_tracker_data(request): today = datetime.now().date() duration = TaskInterval.get_hours(request.user, today) response = dict(today='%.2f' % duration) response['tasks'] = [] for item in TaskInterval.objects.filter(doer=request.user, duration=None): task_time = TaskInterval.get_hours(request.user, task=item.task) response['tasks'].append(dict(id=item.task.id, time='%.2f' % task_time)) return HttpResponse(dumps(response))