Wartungsupdate
This commit is contained in:
parent
7f87ec435c
commit
88fab67a9d
3 changed files with 285 additions and 19 deletions
144
app.py
144
app.py
|
|
@ -212,19 +212,14 @@ def index():
|
||||||
@app.route("/run/balance", methods=["POST"])
|
@app.route("/run/balance", methods=["POST"])
|
||||||
def run_balance():
|
def run_balance():
|
||||||
|
|
||||||
result = subprocess.run(
|
subprocess.run(
|
||||||
[sys.executable, str(BASE_DIR / "balance.py")],
|
[sys.executable, str(BASE_DIR / "balance.py")]
|
||||||
capture_output=True,
|
|
||||||
text=True
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return render_template(
|
return redirect(
|
||||||
"result.html",
|
"/maintenance?message=Kontostand erfolgreich aktualisiert"
|
||||||
title="balance.py",
|
|
||||||
output=result.stdout + result.stderr
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/run/transactions", methods=["POST"])
|
@app.route("/run/transactions", methods=["POST"])
|
||||||
def run_transactions():
|
def run_transactions():
|
||||||
|
|
||||||
|
|
@ -244,11 +239,31 @@ def run_transactions():
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
text=True
|
text=True
|
||||||
)
|
)
|
||||||
|
transaction_count = 0
|
||||||
|
|
||||||
return render_template(
|
try:
|
||||||
"result.html",
|
|
||||||
title="transactions.py",
|
transactions_file = (
|
||||||
output=result.stdout + result.stderr
|
BASE_DIR
|
||||||
|
/ "Transaktionen"
|
||||||
|
/ str(year)
|
||||||
|
/ "json"
|
||||||
|
/ f"transactions_{year}_KW{int(week):02d}.json"
|
||||||
|
)
|
||||||
|
|
||||||
|
if transactions_file.exists():
|
||||||
|
with open(
|
||||||
|
transactions_file,
|
||||||
|
encoding="utf-8"
|
||||||
|
) as f:
|
||||||
|
transaction_count = len(
|
||||||
|
json.load(f)
|
||||||
|
)
|
||||||
|
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
return redirect(
|
||||||
|
f"/maintenance?message={transaction_count} Transaktionen geladen"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -271,11 +286,97 @@ def run_categorize():
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
text=True
|
text=True
|
||||||
)
|
)
|
||||||
|
categorized_count = 0
|
||||||
|
|
||||||
return render_template(
|
try:
|
||||||
"result.html",
|
|
||||||
title="categorize_transactions.py",
|
categorized_file = (
|
||||||
output=result.stdout + result.stderr
|
BASE_DIR
|
||||||
|
/ "Transaktionen"
|
||||||
|
/ str(year)
|
||||||
|
/ "categorized_json"
|
||||||
|
/ f"categorized_transactions_{year}_KW{int(week):02d}.json"
|
||||||
|
)
|
||||||
|
|
||||||
|
if categorized_file.exists():
|
||||||
|
with open(
|
||||||
|
categorized_file,
|
||||||
|
encoding="utf-8"
|
||||||
|
) as f:
|
||||||
|
categorized_count = len(
|
||||||
|
json.load(f)
|
||||||
|
)
|
||||||
|
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
return redirect(
|
||||||
|
f"/maintenance?message={categorized_count} Buchungen kategorisiert"
|
||||||
|
)
|
||||||
|
@app.route("/run/weekly_update", methods=["POST"])
|
||||||
|
def run_weekly_update():
|
||||||
|
|
||||||
|
year = request.form.get("year", "").strip()
|
||||||
|
week = request.form.get("week", "").strip()
|
||||||
|
|
||||||
|
transaction_command = [
|
||||||
|
sys.executable,
|
||||||
|
str(BASE_DIR / "transactions.py")
|
||||||
|
]
|
||||||
|
|
||||||
|
categorize_command = [
|
||||||
|
sys.executable,
|
||||||
|
str(BASE_DIR / "categorize_transactions.py")
|
||||||
|
]
|
||||||
|
|
||||||
|
if year and week:
|
||||||
|
|
||||||
|
transaction_command.extend(
|
||||||
|
[year, week]
|
||||||
|
)
|
||||||
|
|
||||||
|
categorize_command.extend(
|
||||||
|
[year, week]
|
||||||
|
)
|
||||||
|
|
||||||
|
subprocess.run(
|
||||||
|
transaction_command
|
||||||
|
)
|
||||||
|
|
||||||
|
subprocess.run(
|
||||||
|
categorize_command
|
||||||
|
)
|
||||||
|
|
||||||
|
transaction_count = 0
|
||||||
|
|
||||||
|
try:
|
||||||
|
|
||||||
|
transactions_file = (
|
||||||
|
BASE_DIR
|
||||||
|
/ "Transaktionen"
|
||||||
|
/ str(year)
|
||||||
|
/ "json"
|
||||||
|
/ f"transactions_{year}_KW{int(week):02d}.json"
|
||||||
|
)
|
||||||
|
|
||||||
|
if transactions_file.exists():
|
||||||
|
with open(
|
||||||
|
transactions_file,
|
||||||
|
encoding="utf-8"
|
||||||
|
) as f:
|
||||||
|
transaction_count = len(
|
||||||
|
json.load(f)
|
||||||
|
)
|
||||||
|
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
message = (
|
||||||
|
f"{transaction_count} Transaktionen verarbeitet - "
|
||||||
|
f"KW {week}/{year}"
|
||||||
|
)
|
||||||
|
|
||||||
|
return redirect(
|
||||||
|
f"/maintenance?message={message}"
|
||||||
)
|
)
|
||||||
|
|
||||||
@app.route("/categories")
|
@app.route("/categories")
|
||||||
|
|
@ -448,12 +549,17 @@ def maintenance():
|
||||||
|
|
||||||
year, week, _ = datetime.now().isocalendar()
|
year, week, _ = datetime.now().isocalendar()
|
||||||
|
|
||||||
|
message = request.args.get(
|
||||||
|
"message",
|
||||||
|
""
|
||||||
|
)
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
"maintenance.html",
|
"maintenance.html",
|
||||||
year=year,
|
year=year,
|
||||||
week=week
|
week=week,
|
||||||
|
message=message
|
||||||
)
|
)
|
||||||
|
|
||||||
@app.route("/log")
|
@app.route("/log")
|
||||||
def show_log():
|
def show_log():
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -289,4 +289,98 @@ text-decoration: underline;
|
||||||
|
|
||||||
.balance-red {
|
.balance-red {
|
||||||
color: #c62828;
|
color: #c62828;
|
||||||
|
}
|
||||||
|
#modal-overlay {
|
||||||
|
|
||||||
|
position: fixed;
|
||||||
|
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
|
||||||
|
background: rgba(
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0.5
|
||||||
|
);
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
z-index: 9999;
|
||||||
|
}
|
||||||
|
|
||||||
|
#modal {
|
||||||
|
|
||||||
|
background: white;
|
||||||
|
|
||||||
|
padding: 30px;
|
||||||
|
|
||||||
|
border-radius: 12px;
|
||||||
|
|
||||||
|
box-shadow:
|
||||||
|
0 0 20px rgba(
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0.3
|
||||||
|
);
|
||||||
|
|
||||||
|
min-width: 400px;
|
||||||
|
|
||||||
|
text-align: center;
|
||||||
|
|
||||||
|
}
|
||||||
|
#modal p {
|
||||||
|
|
||||||
|
font-size: 18px;
|
||||||
|
|
||||||
|
line-height: 1.5;
|
||||||
|
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#modal h2 {
|
||||||
|
|
||||||
|
color: #ff6200;
|
||||||
|
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#modal button {
|
||||||
|
|
||||||
|
margin-top: 20px;
|
||||||
|
|
||||||
|
padding: 10px 25px;
|
||||||
|
|
||||||
|
background: #ff6200;
|
||||||
|
|
||||||
|
color: white;
|
||||||
|
|
||||||
|
border: none;
|
||||||
|
|
||||||
|
border-radius: 6px;
|
||||||
|
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
font-size: 16px;
|
||||||
|
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
#modal button:hover {
|
||||||
|
|
||||||
|
opacity: 0.9;
|
||||||
|
}
|
||||||
|
.modal-message {
|
||||||
|
|
||||||
|
font-size: 18px;
|
||||||
|
|
||||||
|
line-height: 1.6;
|
||||||
|
|
||||||
|
margin-bottom: 20px;
|
||||||
}
|
}
|
||||||
|
|
@ -56,6 +56,29 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% if message %}
|
||||||
|
|
||||||
|
<div id="modal-overlay">
|
||||||
|
|
||||||
|
<div id="modal">
|
||||||
|
|
||||||
|
<h2 class="success-title">
|
||||||
|
✅ Erfolgreich
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<p class="modal-message">
|
||||||
|
{{ message|replace('\n', '<br>')|safe }}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<button onclick="closeModal()">
|
||||||
|
OK
|
||||||
|
</button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -154,7 +177,38 @@
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
|
||||||
|
<h2>
|
||||||
|
Wochenupdate
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<form
|
||||||
|
action="/run/weekly_update"
|
||||||
|
method="post">
|
||||||
|
|
||||||
|
<input
|
||||||
|
type="hidden"
|
||||||
|
name="year"
|
||||||
|
value="{{ year }}">
|
||||||
|
|
||||||
|
<input
|
||||||
|
type="hidden"
|
||||||
|
name="week"
|
||||||
|
value="{{ week }}">
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Lädt Transaktionen und
|
||||||
|
kategorisiert automatisch.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<button type="submit">
|
||||||
|
Starten
|
||||||
|
</button>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -167,7 +221,19 @@ Hintergasse © 2026
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
<script>
|
||||||
|
|
||||||
|
function closeModal() {
|
||||||
|
|
||||||
|
document
|
||||||
|
.getElementById(
|
||||||
|
"modal-overlay"
|
||||||
|
)
|
||||||
|
.style
|
||||||
|
.display = "none";
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue