Exemplo n.º 1
0
def check(key_id=None):
    entity = ds.get_by_id(key_id)
    if not entity:
        abort(404)
    if entity['check'] == "0":
        entity['check'] = "1"
    elif entity['check'] == "1":
        entity['check'] = "0"
    ds.update(entity)
    return redirect('/works/todo')
Exemplo n.º 2
0
def greetings(key_id=None):
    if request.method == 'GET':
        if key_id:
            entity = ds.get_by_id(key_id)
            if not entity:
                abort(404)
            return entity

        greetings = ds.get_all()

        res = {'greetings': greetings}
        return res

    elif request.method == 'POST':
        author = request.json['author']
        message = request.json['message']
        entity = ds.insert(author, message)
        return entity, 201

    elif request.method == 'PUT':
        entity = ds.get_by_id(key_id)
        if not entity:
            abort(404)
            return entity

        entity['author'] = request.json['author']
        entity['message'] = request.json['message']
        entity = ds.update(entity)
        return entity

    elif request.method == 'DELETE':
        ds.delete(key_id)
        return '', 204
Exemplo n.º 3
0
def edit(key_id=None):
    # ログインしていなければトップへリダイレクト
    if not is_login():
        return show_msg("認証失敗。ログインが必要なページです。")
    entity = ds.get_by_id(key_id)
    if not entity:
        abort(404)
    addtodo = request.form.get('addtodo', '')
    if addtodo == '':
        return redirect('/works/todo/admin')
    entity['things'] = addtodo
    entity = ds.update(entity)
    return redirect('/works/todo/admin')