This commit is contained in:
37
app.py
37
app.py
@@ -102,6 +102,43 @@ def post_a_post(post_key):
|
||||
return render_template("i-posts.html", host_id=docker_short_id, postos=postos)
|
||||
|
||||
|
||||
|
||||
@app.route('/post_to_another_post/<post_key>', methods=['POST'])
|
||||
def post_a_post(post_key):
|
||||
|
||||
|
||||
postos = db.collection('posts')
|
||||
|
||||
data = request.form['send_this_text']
|
||||
|
||||
metadata = postos.insert({
|
||||
'texto': data,
|
||||
'parent_post': f'{post_key}'
|
||||
}, overwrite_mode='update')
|
||||
|
||||
metadata = db.collection('post_parents').insert({
|
||||
'_from': f'posts/{post_key}',
|
||||
'_to': f'posts/{metadata["_key"]}'
|
||||
}, overwrite_mode='update')
|
||||
|
||||
|
||||
cursor = db.aql.execute(
|
||||
"""FOR ppp IN posts
|
||||
LET children = (FOR v IN 1..9999 OUTBOUND ppp post_parents RETURN v)
|
||||
UPDATE ppp WITH { children_num : COUNT_DISTINCT( children[*]._key ) } IN posts"""
|
||||
)
|
||||
cursor = db.aql.execute(
|
||||
"""FOR ppp IN posts
|
||||
LET children = (FOR v IN 1OUTBOUND ppp post_parents RETURN v)
|
||||
UPDATE ppp WITH { answers_num : COUNT_DISTINCT( children[*]._key ) } IN posts"""
|
||||
)
|
||||
|
||||
postos = db.collection('posts')
|
||||
postos = sorted(postos, key=lambda posto: posto['_key'], reverse=False)
|
||||
|
||||
return render_template("i-posts.html", host_id=docker_short_id, postos=postos)
|
||||
|
||||
|
||||
# @app.route('/post_my_file', method=['POST'])
|
||||
# def post_a_file():
|
||||
# pass
|
||||
|
||||
Reference in New Issue
Block a user