diff --git a/app.py b/app.py index 2143c24..97c58b4 100644 --- a/app.py +++ b/app.py @@ -66,18 +66,25 @@ def page_posts_from_db(): return render_template("interactive-posts.html", postos=postos) -@app.route('/post_my_post', methods=['POST']) -def post_a_post(): +@app.route('/post_my_post/', methods=['POST']) +def post_a_post(post_key): postos = db.collection('posts') - novenkiy = { - 'texto': 'next post is this', - } + #### TODO проверить как-то по-умному что мы таки его добавили - metadata = postos.insert(novenkiy, overwrite_mode='update') - + metadata = postos.insert({ + 'texto': 'next post is this', + }, overwrite_mode='update') + + db.collection('posts').insert({ + '_key': post_key, + '_from': f'posts/post_key', + '_to': f'posts/{metadata["_key"]}' + }, overwrite_mode='update') + + postos = db.collection('posts') return render_template("i-posts.html", postos=postos) diff --git a/templates/i-posts.html b/templates/i-posts.html index 0889688..280c914 100644 --- a/templates/i-posts.html +++ b/templates/i-posts.html @@ -25,7 +25,7 @@