From 4024f8f0322a682e2136ef8850194023656a4cb0 Mon Sep 17 00:00:00 2001 From: Simple_Not <44047940+moonbaseDelta@users.noreply.github.com> Date: Thu, 13 Jul 2023 21:56:36 +1000 Subject: [PATCH] check posts --- app.py | 21 ++++++++++++++------- templates/i-posts.html | 2 +- 2 files changed, 15 insertions(+), 8 deletions(-) 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 @@