def tasks(type=SINGLE_TYPE, scheduled=None):
    if not scheduled:
        tasks = Task.factory(type).objects.all()
    else:
        tasks = Task.factory(type).objects(scheduled_time__exists=True).all()
    return render_template('tasks/list.html', tasks=tasks, type=type)
def tasks(type=SINGLE_TYPE, scheduled=None):
    if not scheduled:
        tasks = Task.factory(type).objects.all()
    else:
        tasks = Task.factory(type).objects(scheduled_time__exists=True).all()
    return render_template('tasks/list.html', tasks=tasks, type=type)
def tasks_view(type=SINGLE_TYPE, id=None):
    return render_template('tasks/view.html',
                           task=Task.factory(type).objects(pk=str(id)).first(),
                           type=type)
def tasks_view(type=SINGLE_TYPE, id=None):
   return render_template('tasks/view.html', task=Task.factory(type).objects(pk=str(id)).first(), type=type)