User:Pedro Sá Couto/TW/Commenting: Difference between revisions
< User:Pedro Sá Couto | TW
No edit summary |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 7: | Line 7: | ||
=WHY?= | =WHY?= | ||
Tactical Watermarks will exist alongside its use. We ask users to give input on any changes that should or may be made to the Guidelines of the application. | Tactical Watermarks will exist alongside its use. We ask users to give input on any changes that should or may be made to the Guidelines of the application.<br> | ||
This is also a way to improve the input that users may give to how Tactical Watermarks is run. | This is also a way to improve the input that users may give to how Tactical Watermarks is run. | ||
Line 19: | Line 19: | ||
<source lang="python"> | <source lang="python"> | ||
#Terms & Comment | |||
# create table for comments | |||
table_comment = db['commented'] | |||
@app.route('/write_comment', methods=['GET']) | |||
def write_comment(): | |||
return render_template('public/write_comment.html') | |||
# from GET /write_comment render terms.html | |||
@app.route('/terms', methods=['GET']) | |||
def terms(): | |||
comments = table_comment.find(order_by='-id') | |||
return render_template('public/terms.html', comments=comments) | |||
# from POST /submit store data in the database and forward to the terms | |||
@app.route('/submitcomment', methods=['POST']) | |||
def submitcomment(): | |||
comment = dict(name=request.form['name'], commenting=request.form['commenting']) | |||
table_comment.insert(comment) | |||
return redirect(url_for('terms')) | |||
</source> | </source> |
Latest revision as of 02:32, 15 June 2020
STEPS
Leaving a comment is separated in 4 steps:
1. Filling the form with to leave a new comment to the Guidelines
3. Submiting the request
4. Displaying the comment
WHY?
Tactical Watermarks will exist alongside its use. We ask users to give input on any changes that should or may be made to the Guidelines of the application.
This is also a way to improve the input that users may give to how Tactical Watermarks is run.
PREVIEW
Printscreen from https://hub.xpub.nl/watermark/terms
Python View
#Terms & Comment
# create table for comments
table_comment = db['commented']
@app.route('/write_comment', methods=['GET'])
def write_comment():
return render_template('public/write_comment.html')
# from GET /write_comment render terms.html
@app.route('/terms', methods=['GET'])
def terms():
comments = table_comment.find(order_by='-id')
return render_template('public/terms.html', comments=comments)
# from POST /submit store data in the database and forward to the terms
@app.route('/submitcomment', methods=['POST'])
def submitcomment():
comment = dict(name=request.form['name'], commenting=request.form['commenting'])
table_comment.insert(comment)
return redirect(url_for('terms'))