Esempio n. 1
0
File: views.py Progetto: k0001/pinax
def tasks_history(request, id, group_slug=None, template_name="tasks/task_history.html", bridge=None):
    
    try:
        group = bridge.get_group(group_slug)
    except ObjectDoesNotExist:
        raise Http404
    
    if group:
        tasks = group.get_related_objects(Task)
    else:
        tasks = Task.objects.filter(object_id=None)
    
    task = get_object_or_404(tasks, id=id)
    task_history = task.history_task.all().order_by('-modified')
    nudge_history = task.task_nudge.all().order_by('-modified')

    result_list = sorted(
        chain(task_history, nudge_history),
        key=attrgetter('modified')
        )
    result_list.reverse()


    for change in task_history:
        change.humanized_state = STATE_CHOICES_DICT.get(change.state, None)
        change.humanized_resolution = RESOLUTION_CHOICES_DICT.get(change.resolution, None)


    return render_to_response(template_name, {
        "group": group,
        "task": task,
        "task_history": result_list,
        "nudge_history": nudge_history,
    }, context_instance=RequestContext(request))
Esempio n. 2
0
def tasks_history(request, id, template_name="tasks/task_history.html"):
    task = get_object_or_404(Task, id=id)
    task_history = task.history_task.all().order_by('-modified')
    nudge_history = task.task_nudge.all().order_by('-modified')

    result_list = sorted(
        chain(task_history, nudge_history),
        key=attrgetter('modified')
        )
    result_list.reverse()


    for change in task_history:
        change.humanized_state = STATE_CHOICES_DICT.get(change.state, None)
        change.humanized_resolution = RESOLUTION_CHOICES_DICT.get(change.resolution, None)


    return render_to_response(template_name, {
        "task": task,
        "task_history": result_list,
        "nudge_history":nudge_history

    }, context_instance=RequestContext(request))