forked from ticketfrei/ticketfrei
writing goodlist & blacklist -> db
This commit is contained in:
parent
06739db87c
commit
0438fe8014
|
@ -137,6 +137,41 @@ def manage_bot():
|
||||||
else:
|
else:
|
||||||
bottle.abort(401, "Sorry, access denied.")
|
bottle.abort(401, "Sorry, access denied.")
|
||||||
|
|
||||||
|
@app.route('/settings/goodlist', method="POST")
|
||||||
|
def update_goodlist():
|
||||||
|
"""
|
||||||
|
Writes the goodlist textarea on /settings to the database.
|
||||||
|
This function expects a multi-line string, transmitted over the textarea form.
|
||||||
|
:return: redirect to settings page
|
||||||
|
"""
|
||||||
|
# get new goodlist
|
||||||
|
words = bottle.request.forms.get("goodlist")
|
||||||
|
# get user.id
|
||||||
|
email = bottle.cookie_decode("account", secret)
|
||||||
|
db.cur.execute("SELECT id FROM user WHERE email = ?", (email, ))
|
||||||
|
user_id = db.cur.fetchone()
|
||||||
|
# write new goodlist to db
|
||||||
|
db.cur.execute("UPDATE trigger_good SET ? WHERE user.id = ?", (words, user_id, ))
|
||||||
|
return bottle.redirect("/settings")
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/settings/blacklist', method="POST")
|
||||||
|
def update_blacklist():
|
||||||
|
"""
|
||||||
|
Writes the blacklist textarea on /settings to the database.
|
||||||
|
This function expects a multi-line string, transmitted over the textarea form.
|
||||||
|
:return: redirect to settings page
|
||||||
|
"""
|
||||||
|
# get new blacklist
|
||||||
|
words = bottle.request.forms.get("blacklist")
|
||||||
|
# get user.id
|
||||||
|
email = bottle.cookie_decode("account", secret)
|
||||||
|
db.cur.execute("SELECT id FROM user WHERE email = ?", (email, ))
|
||||||
|
user_id = db.cur.fetchone()
|
||||||
|
# write new goodlist to db
|
||||||
|
db.cur.execute("UPDATE trigger_bad SET ? WHERE user.id = ?", (words, user_id, ))
|
||||||
|
return bottle.redirect("/settings")
|
||||||
|
|
||||||
|
|
||||||
@app.route('/enable', method="POST")
|
@app.route('/enable', method="POST")
|
||||||
def enable():
|
def enable():
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
Log in with Twitter
|
Log in with Twitter
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<h2>Log in with Mastodon</h2>
|
<h2>Log in with Mastodon</h2>
|
||||||
<form action="/login/mastodon" method='post'>
|
<form action="/login/mastodon" method='post'>
|
||||||
<label>Mastodon instance:
|
<label>Mastodon instance:
|
||||||
|
@ -63,13 +63,35 @@
|
||||||
</datalist>
|
</datalist>
|
||||||
<input name='confirm' value='Log in' type='submit'/>
|
<input name='confirm' value='Log in' type='submit'/>
|
||||||
</form>
|
</form>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<!-- login with e-mail -->
|
<!-- offer mailing list creation button -->
|
||||||
|
|
||||||
<!-- good list entry field -->
|
<!-- good list entry field -->
|
||||||
|
<p>
|
||||||
|
Those words have to be contained in a report.
|
||||||
|
If none of these expressions is in the report, it will be ignored by the bot.
|
||||||
|
You can use the defaults, or enter some expressions specific to your city and language.
|
||||||
|
</p>
|
||||||
|
<form action="/settings/goodlist" method="post">
|
||||||
|
<textarea name="goodlist" wrap="physical">
|
||||||
|
<!-- find a way to display current good list. js which reads from a cookie? template? -->
|
||||||
|
</textarea>
|
||||||
|
<button type="submit">Submit trigger words</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
<!-- blacklist entry field -->
|
<!-- blacklist entry field -->
|
||||||
|
<p>
|
||||||
|
Those words are not allowed in reports.
|
||||||
|
If you encounter spam, you can add more here - the bot will ignore reports which use such words.
|
||||||
|
<!-- There are words which you can't exclude from the blacklist, e.g. certain racist, sexist, or antisemitic slurs. (to be implemented) -->
|
||||||
|
</p>
|
||||||
|
<form action="/settings/blacklist" method="post">
|
||||||
|
<textarea name="blacklist" wrap="physical">
|
||||||
|
<!-- find a way to display current blacklist. js which reads from a cookie? template? -->
|
||||||
|
</textarea>
|
||||||
|
<button type="submit">Submit blacklist</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
<script src="/static/js/functions.js"></script>
|
<script src="/static/js/functions.js"></script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue