This commit is contained in:
parent
1e2d39a5c0
commit
e7fee4999e
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)
|
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'])
|
# @app.route('/post_my_file', method=['POST'])
|
||||||
# def post_a_file():
|
# def post_a_file():
|
||||||
# pass
|
# pass
|
||||||
|
@ -19,20 +19,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-action">
|
<div class="card-action">
|
||||||
<button class="btn waves-effect waves-light" type="submit" name="action">Отправить!!
|
<button class="btn waves-effect waves-light"
|
||||||
<i class="material-icons right">send</i>
|
type="submit" name="action"
|
||||||
</button>
|
hx-post="/post_to_another_post/{{ posto._key }}"
|
||||||
</div>
|
hx-target="#neu-posts"
|
||||||
<!-- <div class="posting_form">
|
hx-include="[name='send_this_text']"
|
||||||
<h4>Создай то, о чем будут говорить многие.</h4>
|
>
|
||||||
<div class="container">
|
Отправить!!
|
||||||
<div class="input-field col s6">
|
|
||||||
<input id="send_this_text" type="text" >
|
|
||||||
<label for="send_this_text">Печатать сюда</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="container">
|
|
||||||
<button class="btn waves-effect waves-light" type="submit" name="action">Отправить!!
|
|
||||||
<i class="material-icons right">send</i>
|
<i class="material-icons right">send</i>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user