Add card enabled to edit form
All checks were successful
ci/woodpecker/manual/woodpecker Pipeline was successful

This commit is contained in:
Madis Mägi 2023-08-14 05:47:00 +03:00
parent 83d72f355e
commit f96bf432cd
2 changed files with 13 additions and 1 deletions

View File

@ -85,6 +85,7 @@ def view_doorboy_enable(token_id):
class TokenEditForm(FlaskForm): class TokenEditForm(FlaskForm):
comment = StringField("Comment") comment = StringField("Comment")
enabled = BooleanField("Enabled")
@page_doorboy.route("/m/doorboy/<token_id>/edit", methods=["GET"]) @page_doorboy.route("/m/doorboy/<token_id>/edit", methods=["GET"])
@login_required @login_required
@ -98,6 +99,9 @@ def view_doorboy_edit(token_id):
}) })
form = TokenEditForm() form = TokenEditForm()
form.comment.data = token["token"].get("comment", "") form.comment.data = token["token"].get("comment", "")
if token["token"].get("enabled"):
form.enabled.render_kw = {"checked": "checked"}
form.enabled.data = "y"
return render_template("doorboy_token_edit.html", form=form, token=token) return render_template("doorboy_token_edit.html", form=form, token=token)
@page_doorboy.route("/m/doorboy/<token_id>/edit", methods=["POST"]) @page_doorboy.route("/m/doorboy/<token_id>/edit", methods=["POST"])
@ -114,9 +118,10 @@ def save_doorboy_edit(token_id):
}, { }, {
"$set": { "$set": {
"token.comment": form.comment.data, "token.comment": form.comment.data,
"token.enabled": form.enabled.data,
} }
}) })
return redirect("/m/doorboy") return redirect("/m/doorboy/me")
class HoldDoorForm(FlaskForm): class HoldDoorForm(FlaskForm):
door_name = SelectField("Door name", choices=[(j,j) for j in ["grounddoor", "frontdoor", "backdoor"]], validators=[DataRequired()]) door_name = SelectField("Door name", choices=[(j,j) for j in ["grounddoor", "frontdoor", "backdoor"]], validators=[DataRequired()])

View File

@ -6,6 +6,13 @@
<form method="POST" autocomplete="off"> <form method="POST" autocomplete="off">
{{ form.csrf_token }} {{ form.csrf_token }}
{{ form.comment.label }} {{ form.comment(size=20) }} {{ form.comment.label }} {{ form.comment(size=20) }}
<p>
<label>
{{ form.enabled }}
<span>{{ form.enabled.label }}</span>
</label>
</p>
<br/>
<button class="btn waves-effect waves-light" type="submit">Save</button> <button class="btn waves-effect waves-light" type="submit">Save</button>
</form> </form>
</div> </div>