1
0
Fork 0
mirror of https://github.com/Lynnesbian/FediBooks/ synced 2024-11-25 16:48:58 +00:00

bot_edit now displays user's settings

This commit is contained in:
Lynne Megido 2019-09-10 13:36:36 +10:00
parent efa1eef5cc
commit 6838e16b03
4 changed files with 28 additions and 18 deletions

View file

@ -169,8 +169,13 @@ input:focus, select:focus, textarea:focus {
border: 3px mediumpurple solid; border: 3px mediumpurple solid;
} }
input[type="checkbox"] {
height: 1.4em;
}
label, input { label, input {
flex-basis: 0; flex-basis: 0;
text-align: left;
} }
label { label {
flex-grow: 1; flex-grow: 1;

View file

@ -12,54 +12,57 @@
<p class="large centred">@botname@example.com</p> <p class="large centred">@botname@example.com</p>
</div> </div>
{% include 'error.html' %}
{% include 'success.html' %}
<div class="container centred"> <div class="container centred">
<form action="/do/bot/edit" method="post" class="full-width"> <form action="/do/bot/edit" method="post" class="full-width">
<div class="row"> <!-- <div class="row">
<label for="username" class="large">Username</label> <label for="username" class="large">Username</label>
<input type="text" name="username" value="Bot Name"> <input type="text" name="username" value="Bot Name">
</div> </div> -->
<div class="row"> <div class="row">
<label for="freq" class="large">Post frequency (minutes)</label> <label for="freq" class="large">Post frequency (minutes)</label>
<input type="number" min="15" max="240" step="5" value="30" name="freq"> <input type="number" min="15" max="240" step="5" value="{{ bot['post_frequency'] }}" name="freq">
</div> </div>
<div class="row"> <div class="row">
<label for="cw" class="large">Content warning (subject)</label> <label for="cw" class="large">Content warning (subject)</label>
<input type="text" placeholder="None" name="cw"> <input type="text" placeholder="None" name="cw" value = "{{ bot['content_warning'] if bot['content_warning'] != None else '' }}">
</div> </div>
<div class="row"> <div class="row">
<label for="length" class="large">Maximum post length (characters)</label> <label for="length" class="large">Maximum post length (characters)</label>
<input type="number" min="100" max="5000" value="500" name="length"> <input type="number" min="100" max="5000" value="{{ bot['length'] }}" name="length">
</div> </div>
<div class="row"> <div class="row">
<label for="fake-mentions" class="large">Fake mentions</label> <label for="fake-mentions" class="large">Fake mentions</label>
<select name="fake-mentions"> <select name="fake-mentions">
<option value="always">At any time</option> <option value="always" {{ 'selected' if bot['fake_mentions'] == 'always' }}>At any time</option>
<option value="middle" default>Only in the middle of posts</option> <option value="middle" {{ 'selected' if bot['fake_mentions'] == 'middle' }}>Only in the middle of posts</option>
<option value="never">Never</option> <option value="never" {{ 'selected' if bot['fake_mentions'] == 'never' }}>Never</option>
</select> </select>
</div> </div>
<div class="row"> <div class="row">
<label for="fake-mention-style" class="large">Fake mention style</label> <label for="fake-mention-style" class="large">Fake mention style</label>
<select name="fake-mention-style"> <select name="fake-mention-style">
<option value="full">@user@instan.ce</option> <option value="full" {{ 'selected' if bot['fake_mentions_full'] }}>@user@instan.ce</option>
<option value="brief" default>@user</option> <option value="brief" {{ 'selected' if not bot['fake_mentions_full'] }}>@user</option>
</select> </select>
</div> </div>
<div class="row"> <div class="row">
<label for="privacy" class="large">Post privacy</label> <label for="privacy" class="large">Post privacy</label>
<select name="privacy"> <select name="privacy">
<option value="public">Public</option> <option value="public" {{ 'selected' if bot['post_privacy'] == 'public' }}>Public</option>
<option value="unlisted">Unlisted</option> <option value="unlisted" {{ 'selected' if bot['post_privacy'] == 'unlisted' }}>Unlisted</option>
<option value="followers">Followers only</option> <option value="followers" {{ 'selected' if bot['post_privacy'] == 'private' }}>Followers only</option>
</select> </select>
</div> </div>
<div class="row"> <div class="row">
<label for="cw-learning" class="large">Learn from posts with content warnings (subjects)</label> <label for="cw-learning" class="large">Learn from posts with content warnings (subjects)</label>
<input type="checkbox" name="cw-learning"> <input type="checkbox" name="cw-learning" {{ 'checked' if bot['learn_from_cw']}}>
</div> </div>
<div class="row"> <div class="row">
<label for="replies" class="large">Enable replies</label> <label for="replies" class="large">Enable replies</label>
<input type="checkbox" name="replies"> <input type="checkbox" name="replies" {{ 'checked' if bot['replies_enabled']}}>
</div> </div>
<div class="container centred"> <div class="container centred">
<button class="button btn-primary"><i class="fas fa-save"></i> Save</button> <button class="button btn-primary"><i class="fas fa-save"></i> Save</button>

View file

@ -27,7 +27,7 @@
</div> </div>
<div class="row"> <div class="row">
<label for="password" class="large">Password</label> <label for="password" class="large">Password</label>
<input type="password" name="password" placeholder="Unchanged"> <input type="password" name="password"pattern=".{8,}" placeholder="Unchanged">
</div> </div>
<div class="container light"> <div class="container light">

View file

@ -137,7 +137,9 @@ def settings():
@app.route("/bot/edit/<id>") @app.route("/bot/edit/<id>")
def bot_edit(id): def bot_edit(id):
return render_template("coming_soon.html") dc = mysql.connection.cursor(MySQLdb.cursors.DictCursor)
dc.execute("SELECT * FROM bots WHERE handle = %s", (id,))
return render_template("bot_edit.html", bot = dc.fetchone())
@app.route("/bot/delete/<id>", methods=['GET', 'POST']) @app.route("/bot/delete/<id>", methods=['GET', 'POST'])
def bot_delete(id): def bot_delete(id):