示例#1
0
文件: views.py 项目: artran/Timelord
def adjust_time(request):
    'Add a log entry for a single task. The POST parameters are the task_id and delta_time in minutes.'

    if request.method != 'POST':
        return status(request)
    user = request.user
    current_task = Task.objects.get(pk=request.POST['task'])
    log = LogEntry()
    log.staff = user
    log.task = current_task
    log.delta_time = request.POST['adjust']
    log.save()
    return api_views.task_status(request)
示例#2
0
文件: views.py 项目: artran/Timelord
def log(request):
    'Add log entries for an arbitary number of tasks. The task_id is a key into a map and the delta is the value.'

    if request.method != 'POST':
        return status(request)

    user = request.user
    for item in request.POST.items():
        key = item[0]
        val = item[1]

        if key != 'task':
            try:
                task = Task.objects.get(pk=key)
                log = LogEntry()
                log.staff = user
                log.task = task
                log.delta_time = val
                log.save()
            except:
                pass

    return api_views.task_status(request)