Exemplo n.º 1
0
def route_dict():
    r = {
        '/weibo/index':
        login_required(index),
        '/weibo/new':
        login_required(new),
        '/weibo/edit':
        login_required(same_user_required(edit)),
        '/weibo/add':
        login_required(add),
        '/weibo/update':
        login_required(same_user_required(update)),
        '/weibo/delete':
        login_required(same_user_required(delete)),
        # 评论功能
        '/comment/add':
        login_required(comment_add),
        '/comment/delete':
        login_required(comment_delete),
        '/comment/edit':
        login_required(same_user_required_for_comment(comment_edit)),
        '/comment/update':
        login_required(same_user_required_for_comment(comment_update)),
    }
    return r
Exemplo n.º 2
0
def route_dict():
    d = {
        '/api/todo/all': login_required(all),
        '/api/todo/add': login_required(add),
        '/api/todo/delete': login_required(owner_required(delete)),
        '/api/todo/update': login_required(owner_required(update)),
    }
    return d
Exemplo n.º 3
0
def route_dict():
    d = {
        '/comment/add': login_required(add),
        '/comment/delete': login_required(same_user_required_delete(delete)),
        '/comment/edit': login_required(same_user_required_update(edit)),
        '/comment/update': login_required(same_user_required_update(update))
    }
    return d
Exemplo n.º 4
0
def route_dict():
    d = {
        '/comment/add': login_required(add),
        '/comment/delete': login_required(comment_owner_required(delete)),
        '/comment/edit': login_required(comment_owner_required(edit)),
        '/comment/update': login_required(update),
    }
    return d
Exemplo n.º 5
0
def route_dict():
    r = {
        '/login': route_login,
        '/register': route_register,
        '/edit/password': login_required(edit_password),
        '/update/password': login_required(update_user_password),
    }
    return r
Exemplo n.º 6
0
def route_dict():
    d = {
        '/weibo/add': login_required(add),
        '/weibo/delete': login_required(weibo_owner_required(delete)),
        '/weibo/edit': login_required(weibo_owner_required(edit)),
        '/weibo/update': login_required(weibo_owner_required(update)),
        '/weibo/index': login_required(index),
    }
    return d
Exemplo n.º 7
0
def route_dict():
    d = {
        '/todo/add': login_required(add),
        '/todo/delete': login_required(same_user_required(delete)),
        '/todo/edit': login_required(same_user_required(edit)),
        '/todo/update': login_required(same_user_required(update)),
        '/todo/index': login_required(index),
    }
    return d
Exemplo n.º 8
0
def route_dict():
    """
    路由字典
    key 是路由
    value 是路由处理函数
    """
    d = {
        '/weibo/add':
        login_required(add),
        '/weibo/delete':
        login_required(weibo_owner_required(delete)),
        '/weibo/edit':
        login_required(weibo_owner_required(edit)),
        '/weibo/update':
        login_required(weibo_owner_required(update)),
        '/weibo/index':
        login_required(index),
        # 评论功能
        '/comment/add':
        login_required(comment_add),
        '/comment/delete':
        login_required(comment_owner_or_weibo_owner_required(comment_delete)),
        '/comment/edit':
        login_required(comment_owner_required(comment_edit)),
        '/comment/update':
        login_required(comment_owner_required(comment_update)),
    }
    return d
Exemplo n.º 9
0
def route_dict():
    r = {
        '/user/login': login,
        '/user/login/view': login_view,
        '/user/register': register,
        '/user/register/view': register_view,
        '/user/admin': login_required(admin),
        '/user/edit': login_required(same_user_required(edit)),
        '/user/update': login_required(same_user_required(update)),
    }
    return r
Exemplo n.º 10
0
def route_dict():
    """
    路由字典
    key 是路由(路由就是 path)
    value 是路由处理函数(就是响应)
    """
    d = {
        '/todo/ajax/add': login_required(add),
        '/todo/ajax/index': login_required(index),
        '/todo/ajax/all': login_required(all),
    }
    return d
Exemplo n.º 11
0
def route_dict():
    d = {
        '/api/weibo/all': login_required(all),
        '/api/weibo/add': login_required(add),
        '/api/weibo/delete': weibo_owner_required(delete),
        '/api/weibo/update': weibo_owner_required(update),
        '/weibo/index': login_required(index),
        '/api/comment/add': login_required(comment_add),
        '/api/comment/delete': comment_owner_required(comment_delete),
        '/api/comment/updata': comment_owner_required(comment_updata),
    }
    return d
Exemplo n.º 12
0
def route_dict():
    """
    路由字典
    key 是路由(路由就是 path)
    value 是路由处理函数(就是响应)
    """
    d = {
        '/todo/edit': login_required(same_user_required(edit)),
        '/todo/update': login_required(same_user_required(update)),
        '/todo/index': login_required(index),
    }
    return d
Exemplo n.º 13
0
def route_dict():
    """
    路由字典
    key 是路由(路由就是 path)
    value 是路由处理函数(就是响应)
    """
    d = {
        '/comment/add': login_required(add),
        '/comment/edit': login_required(comment_owner_required(edit)),
        '/comment/update': login_required(comment_owner_required(update)),
        '/comment/delete': login_required(comment_owner_required(delete)),
    }
    return d
Exemplo n.º 14
0
def route_dict():
    """
    路由字典
    key 是路由(路由就是 path)
    value 是路由处理函数(就是响应)
    """
    d = {
        '/todo': login_required(index),
        '/todo/add': login_required(add),
        '/todo/edit': login_required(edit),
        '/todo/update': login_required(update),
        '/todo/delete': login_required(delete),
    }
    return d
def route_dict():
    """
    路由字典
    key 是路由(路由就是 path)
    value 是路由处理函数(就是响应)
    """
    d = {
        '/weibo/add': login_required(add),
        '/weibo/delete': login_required(same_user_required(delete)),
        '/weibo/edit': login_required(same_user_required(edit)),
        '/weibo/update': login_required(same_user_required(update)),
        '/weibo/index': login_required(index)
    }
    return d
Exemplo n.º 16
0
def route_dict():
    d = {
        '/weibo/add': login_required(add),
        '/weibo/delete': login_required(weibo_owner_required(delete)),
        '/weibo/edit': login_required(weibo_owner_required(edit)),
        '/weibo/update': login_required(weibo_owner_required(update)),
        '/weibo/index': login_required(index),
        # 评论功能
        '/comment/add': login_required(comment_add),
        '/comment/delete': login_required(comment_delete),
        '/comment/edit': login_required(comment_edit),
        '/comment/update': login_required(comment_update),
    }
    return d
Exemplo n.º 17
0
def route_dict():
    """
    路由字典
    key 是路由(路由就是 path)
    value 是路由处理函数(就是响应)
    """
    d = {
        '/weibo/index': login_required(index),
    }
    return d
Exemplo n.º 18
0
def index():
    """
    weibo 首页的路由函数
    """
    valid = login_required()
    if valid is not None:
        return valid
    u = current_user()
    weibos = Weibo.one(user_id=u.id)
    # 替换模板文件中的标记字符串
    return render_template('index.html', weibos=weibos, user=u)
Exemplo n.º 19
0
def route_dict():
    r = {
        '/weibo/index': login_required(index),
        '/weibo/new': login_required(new),
        '/weibo/edit': login_required(edit),
        '/weibo/add': login_required(add),
        '/weibo/update': login_required(update),
        '/weibo/delete': login_required(delete),
        # 评论功能
        '/comment/add': login_required(comment_add),
    }
    return r
Exemplo n.º 20
0
def route_dict():
    """
    路由字典
    key 是路由(路由就是 path)
    value 是路由处理函数(就是响应)
    """
    d = {
        '/weibo/add':  login_required(add),
        '/weibo/delete':  login_required(delete),
        '/weibo/edit':  login_required(edit),
        '/weibo/update':  login_required(update),
        '/weibo/index':  login_required(index),
        # 评论功能
        '/comment/add':  login_required(comment_add),
        '/comment/delete': login_required(comment_delete),
        '/comment/edit': login_required(comment_edit),
        '/comment/update': login_required(comment_update),
    }
    return d
Exemplo n.º 21
0
def route_dict():
    d = {
        '/api/weibo/all': weibo_all,
        '/api/weibo/add': login_required(weibo_add),
        '/api/weibo/delete': login_required(owner_required(weibo_delete)),
        '/api/weibo/update': login_required(owner_required(weibo_update)),
        '/api/comment/add': login_required(comment_add),
        '/api/comment/delete': login_required(owner_required(comment_delete)),
        '/api/comment/update': login_required(owner_required(comment_update)),
    }
    return d
Exemplo n.º 22
0
def route_dict():
    """
    路由字典
    key 是路由(路由就是 path)
    value 是路由处理函数(就是响应)
    """
    d = {
        '/weibo/index': login_required(index),
        '/weibo/all': all,
        '/weibo/add': add,
        '/weibo/delete': weibo_owner_required(delete),
        '/weibo/update': weibo_owner_required(update),
        '/comment/add': comment_add,
        '/comment/delete': comment_owner_required(comment_delete),
        '/comment/update': comment_owner_required(comment_update),
    }
    return d
Exemplo n.º 23
0
def route_dict():
    r = {
        '/': login_required(route_index),
        '/static': login_required(route_static),
    }
    return r
Exemplo n.º 24
0
def route_dict():
    r = {
        '/weibo/index': login_required(index),
    }
    return r
Exemplo n.º 25
0

def update(request):
    form = request.json()
    check_id(request, form)
    newTodo = Todo.update(form)
    return json_response(newTodo.json())


def switch(request):
    todo_id = int(request.query.get('id'))
    check_id(request, id=todo_id)
    status = request.query.get('status')
    t = Todo.complete(todo_id, status)
    return json_response(t.json())


route_dict = {
    '/ajax/todo/index': login_required(index),
    '/ajax/todo/add': login_required(add),
    '/ajax/todo/delete': login_required(delete),
    '/ajax/todo/update': login_required(update),
    '/ajax/todo/status_switch': login_required(switch),
}

# todo 权限验证和login_required可以用装饰器来做, 需要修改
# todo update等函数需要在类中定义,在这里每个函数内部只需要3步
# 1.拿数据
# 2.处理数据
# 3.返回数据
Exemplo n.º 26
0
def route_dict():
    d = {
        '/todo/index': login_required(index),
    }
    return d
Exemplo n.º 27
0
def new():
    login_required(add)
    bs = Board.all()
    token = new_csrf_token()
    return render_template("topic/new.html", bs=bs, token=token)
Exemplo n.º 28
0
    header = response_with_headers(headers)
    r = header + '\r\n' + body
    return r.encode(encoding='utf-8')


def admin_update(request):
    u = current_user(request)
    # 设定用户id=1是管理员进行权限验证
    if u.id != 1:
        return redirect('/login')
    form = request.form()
    print(form.get('id', -1))
    user_id = int(form.get('id', -1))
    user_password = form.get('password', '')
    user = User.find_by(id=user_id)
    user.password = user.salted_password(user_password)
    user.save()
    return redirect('/admin/users')


route_dict = {
    '/': route_index,
    '/login': route_login,
    '/out': route_out,
    '/register': route_register,
    '/messages': route_message,
    '/profile': login_required(route_profile),
    '/admin/users': login_required(admin),
    '/admin/user/update': login_required(admin_update),
}