Exemplo n.º 1
0
def index(request):
    """
    todo 首页的路由函数
    """
    u = current_user(request)
    key = 'completed'
    if key in request.query:
        # 只能手动判断,因为 bool(str(False)) == True
        if request.query[key] == 'true':
            index_completed = True
        else:
            index_completed = False
        todos = Todo.all(user_id=u.id, completed=index_completed)
        if index_completed:
            active_index = 'completed'
        else:
            active_index = 'uncompleted'
    else:
        todos = Todo.all(user_id=u.id)
        active_index = 'index'
    log('todo index', active_index)
    uncompleted = len(Todo.all(completed=False))
    return html_response('todo_index.html',
                         todos=todos,
                         active_index=active_index,
                         uncompleted=uncompleted)
Exemplo n.º 2
0
def all(request):
    """
        返回所有 todo
    """
    todo_list = Todo.all()
    todos = [t.json() for t in todo_list]
    return json_response(todos)
Exemplo n.º 3
0
def index():
    # 查找所有的 todo 并返回
    log('args', request.args)
    todo_list = Todo.all()
    # flask 已经配置好了 jinja2 模板引擎
    # 并且可以直接使用 render_template 来生成响应数据(http_response)
    return render_template('todo_index.html', todos=todo_list)
def index(request):
    """
    todo 首页的路由函数
    """
    u = current_user(request)
    todos = Todo.all(user_id=u.id)
    return html_response('todo_index.html', todos=todos)
Exemplo n.º 5
0
def index():
    """
    todo 首页的路由函数
    """
    u = current_user()
    todos = Todo.all(user_id=u.id)
    # 替换模板文件中的标记字符串
    return render_template('todo_index.html', todos=todos)
Exemplo n.º 6
0
def index(request):
    result = request.query.get('result', '')
    result = unquote_plus(result)
    u = current_user(request)
    todos = Todo.all()
    # 替换模板文件中的标记字符串
    body = Template.render('todo_index.html', todos=todos, result=result)
    return html_response(body)
Exemplo n.º 7
0
 def todos(self):
     # 列表推倒和过滤
     # return [t for t in Todo.all() if t.user_id == self.id]
     ts = []
     for t in Todo.all():
         if t.user_id == self.id:
             ts.append(t)
     return ts
Exemplo n.º 8
0
def all(request):
    """
    返回所有 routes
    """
    todo_list = Todo.all()
    # 要转换为 dict 格式才行
    todos = [t.json() for t in todo_list]
    return json_response(todos)
Exemplo n.º 9
0
def all():
    """
    返回所有 todo
    """
    todo_list = Todo.all()
    # 要转换为 dict 格式才行
    todos = [t.json() for t in todo_list]
    return jsonify(todos)
Exemplo n.º 10
0
def all(request):
    """
    返回 json 格式的所有 todo 数据
    """
    u = current_user(request)
    todos = Todo.all(user_id=u.id)
    todos = [todo.to_dict() for todo in todos]
    return json_response(todos)
Exemplo n.º 11
0
def all(request):
    """
    返回所有 todo
    """
    todos = Todo.all()
    # 要转换为 dict 格式才行
    todos = [t.json() for t in todos]
    return json_response(todos)
Exemplo n.º 12
0
def all(request):
    """
    返回所有的todo
    :param request:
    :return: json格式数据
    """
    todo_list = Todo.all()
    # 把todo对象转化成字典
    todos = [t.json() for t in todo_list]
    return json_response(todos)
Exemplo n.º 13
0
def index():
    # 查找所有的 todo 并返回
    todo_list = Todo.all()
    request.method
    log("args", request.args)
    # []
    # todos = todolist
    # flask 已经配置好了 jinja2 模板引擎
    # 并且可以直接使用 render_template 来生成响应数据(http_response)
    return render_template('todo_index.html', todos=todo_list)
Exemplo n.º 14
0
def index(request):
    """
    todo 首页的路由函数
    """
    # u = current_user(request)
    # todos = Todo.find_all(user_id=u.id)
    todos = Todo.all()
    # 替换模板文件中的标记字符串
    body = JinjaTemplateRender.render('todo_index.html', todos=todos)
    return html_response(body)
Exemplo n.º 15
0
def all_task():
    u = current_user()
    ts = Todo.all(user_id=u.id)
    response = []
    for t in ts:
        d = dict(
            id=t.id,
            task=t.task,
            done=t.done,
        )
        response.append(d)
    # print('response', response)
    return jsonify(response)
Exemplo n.º 16
0
def index():
    # 查找所有的 routes 并返回
    todo_list = Todo.all()
    # flask 已经配置好了 jinjia2 模板引擎
    # 并且可以直接使用 render_template 来生成相应数据(http_response)
    return render_template('todo_index.html', todos=todo_list)
Exemplo n.º 17
0
def all_todo(request):
    todo_list = Todo.all()
    todos = [todo.json() for todo in todo_list]
    return json_response(todos)
Exemplo n.º 18
0
def index():
    # 查找所有的 todo 并返回
    todo_list = Todo.all()
    # flask 已经配置好了 jinja2 模板引擎
    # 并且可以直接使用 render_template 来生成响应数据(http_response)
    return render_template('todo_index.html', todos=todo_list, strtime=strtime)
Exemplo n.º 19
0
def index(reqeust):
    todos = Todo.all()
    body = render_template('todo.html', todos=todos)
    r = http_response(body)
    return r
Exemplo n.º 20
0
def index(request):
    todo_list = Todo.all()
    body = templates('simple_todo_index.html', todos=todo_list)
    return http_response(body)
Exemplo n.º 21
0
def all(request):
    ts = [t.__dict__ for t in Todo.all()]
    return json_response(ts)
Exemplo n.º 22
0
def todo_all(request):
    todo_list = Todo.all()
    todos = [t.json() for t in todo_list]
    return json_response(todos)
Exemplo n.º 23
0
def index():
    # 查找所有的 todo 并返回
    todo_list = Todo.all()
    return render_template('todo/index.html', todos=todo_list)
Exemplo n.º 24
0
def all():
    u = current_user()
    todos = [t.json() for t in Todo.all(user_id=u.id)]
    return jsonify(todos)
Exemplo n.º 25
0
def todo_complete():
    todos = Todo.all(complete=True)
    return render_json(todos)
Exemplo n.º 26
0
def index():
    todo_list = Todo.all()
    return render_template('todo_index.html', todos=todo_list)
Exemplo n.º 27
0
def todo_index():
    log('all')
    todos = Todo.all()
    return render_json(todos)
Exemplo n.º 28
0
def index():
    todo_list = Todo.all()
    # request.method
    log("args", request.args)
    return render_template('todo_index.html', todos=todo_list)
Exemplo n.º 29
0
def todo_uncomplete():
    todos = Todo.all(complete=False)
    return render_json(todos)
Exemplo n.º 30
0
def ajax_all(request):
    u = current_user(request)
    todos = Todo.all(user_id=u.id)
    todos = [t.__dict__ for t in todos]
    return json_response(todos)