408fde440d
Photograph/screenshot a boarding pass, decode its BCBP barcode (PDF417/ Aztec/QR/DataMatrix), fetch the historical flight track from FlightAware the day after the flight, stage it for review, and write it into AirTrail via its REST API on approval. ntfy notifications carry signed Approve/Deny/Investigate actions.
32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
"""GET/POST /settings - notification backend configuration, plus a
|
|
send-test-notification action."""
|
|
|
|
from flask import Blueprint, redirect, render_template, request, url_for
|
|
|
|
import models
|
|
import notifier
|
|
|
|
bp = Blueprint("settings", __name__)
|
|
|
|
FORM_FIELDS = ["ntfy_server_url", "ntfy_topic", "ntfy_auth_token", "daily_run_time"]
|
|
|
|
|
|
@bp.route("/settings", methods=["GET", "POST"])
|
|
def settings():
|
|
message = None
|
|
if request.method == "POST":
|
|
if request.form.get("action") == "test":
|
|
notifier.get_notifier().send(
|
|
title="Test notification",
|
|
body="This is a test notification from boarding-pass-pipeline.",
|
|
url=None,
|
|
)
|
|
message = "Test notification sent."
|
|
else:
|
|
for f in FORM_FIELDS:
|
|
if f in request.form:
|
|
models.set_setting(f, request.form[f].strip())
|
|
message = "Settings saved."
|
|
|
|
return render_template("settings.html", settings=models.get_all_settings(), message=message)
|