Merge branch 'main' of gitea.hottis.de:moerp/elo-rezept-rechner
This commit is contained in:
commit
8bc3857482
20
src/Run.py
20
src/Run.py
@ -66,7 +66,6 @@ def get_products():
|
||||
with conn.cursor() as cursor:
|
||||
cursor.execute('SELECT name FROM nutrition_table')
|
||||
products = cursor.fetchall()
|
||||
print("ter")
|
||||
return {'products': [product[0] for product in products]}
|
||||
finally:
|
||||
if conn:
|
||||
@ -97,19 +96,24 @@ def add_lm():
|
||||
return "Lebensmittel nicht gefunden.", 404
|
||||
|
||||
|
||||
def convert_decimal(value):
|
||||
try:
|
||||
return float(value.replace(',', '.'))
|
||||
except (ValueError, TypeError):
|
||||
return 0.0 # Rückgabe eines Standardwertes im Fehlerfall
|
||||
|
||||
|
||||
@app.route('/add_nutrition', methods=['POST'])
|
||||
@oidc.accept_token()
|
||||
def add_nutrition():
|
||||
food = request.form.get('food')
|
||||
kcal = float(request.form.get('kcal'))
|
||||
ew = float(request.form.get('ew'))
|
||||
fett = float(request.form.get('fett'))
|
||||
kh = float(request.form.get('kh'))
|
||||
bst = float(request.form.get('bst'))
|
||||
ca = float(request.form.get('ca'))
|
||||
kcal = convert_decimal(request.form.get('kcal'))
|
||||
ew = convert_decimal(request.form.get('ew'))
|
||||
fett = convert_decimal(request.form.get('fett'))
|
||||
kh = convert_decimal(request.form.get('kh'))
|
||||
bst = convert_decimal(request.form.get('bst'))
|
||||
ca = convert_decimal(request.form.get('ca'))
|
||||
|
||||
print("test")
|
||||
# Verbindung zur Datenbank herstellen und Daten einfügen
|
||||
try:
|
||||
conn = psycopg2.connect()
|
||||
|
@ -34,7 +34,7 @@ button:not(:disabled):hover {
|
||||
}
|
||||
|
||||
button#remove-button {
|
||||
background-color: #f443366f; /* Helles Rot */
|
||||
background-color: #640000; /* Helles Rot */
|
||||
}
|
||||
|
||||
button#remove-button:disabled {
|
||||
@ -43,7 +43,7 @@ button#remove-button:disabled {
|
||||
}
|
||||
|
||||
button#remove-button:not(:disabled):hover {
|
||||
background-color: #d32f2f3d; /* Dunkleres Rot */
|
||||
background-color: #490000; /* Dunkleres Rot */
|
||||
}
|
||||
|
||||
|
||||
@ -72,7 +72,7 @@ tr:nth-child(even) {
|
||||
}
|
||||
|
||||
.selected, tr.selected {
|
||||
background-color: #ffdd99; /* Hervorhebung der Auswahl */
|
||||
background-color: #e19595; /* Hervorhebung der Auswahl */
|
||||
}
|
||||
|
||||
tr:hover:not(.selected) {
|
||||
|
@ -175,7 +175,7 @@ function updateTotalNutrition() {
|
||||
</head>
|
||||
<body>
|
||||
<nav id="navbar">
|
||||
<h1>Elos Rezept Rechner</h1>
|
||||
<h1>Elo's Rezept Rechner</h1>
|
||||
<ul>
|
||||
<li><a href="/" class="active">Rechner</a></li>
|
||||
<li><a href="/nutrition">Neue Lebensmittel</a></li>
|
||||
@ -210,6 +210,8 @@ function updateTotalNutrition() {
|
||||
<button id="remove-button" onclick="removeSelectedRow()" disabled>Entfernen</button>
|
||||
<table id="total-nutrition-table">
|
||||
<tr>
|
||||
<th>Lebensmittel</th>
|
||||
<th>Gewicht (g)</th>
|
||||
<th>kcal</th>
|
||||
<th>EW</th>
|
||||
<th>Fett</th>
|
||||
@ -218,6 +220,8 @@ function updateTotalNutrition() {
|
||||
<th>CA</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<t>Gesamtwerte</td>
|
||||
<td></td>-</td>
|
||||
<td id="total-kcal">0</td>
|
||||
<td id="total-ew">0</td>
|
||||
<td id="total-fett">0</td>
|
||||
|
@ -44,7 +44,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<nav id="navbar">
|
||||
<h1>Elos Rezept Rechner</h1>
|
||||
<h1>Elo's Rezept Rechner</h1>
|
||||
<ul>
|
||||
<li><a href="/">Rechner</a></li>
|
||||
<li><a href="/nutrition" class="active">Neue Lebensmittel</a></li>
|
||||
@ -65,12 +65,12 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input type="text" name="food" placeholder="Lebensmittel" oninput="updateSubmitButtonState()"></td>
|
||||
<td><input <input type="text" name="kcal" pattern="\d+(\.\d{1,2})?" placeholder="g" oninput="updateSubmitButtonState()"></td>
|
||||
<td><input <input type="text" name="ew" pattern="\d+(\.\d{1,2})?" placeholder="g" oninput="updateSubmitButtonState()"></td>
|
||||
<td><input <input type="text" name="fett" pattern="\d+(\.\d{1,2})?" placeholder="g" oninput="updateSubmitButtonState()"></td>
|
||||
<td><input <input type="text" name="kh" pattern="\d+(\.\d{1,2})?" placeholder="g" oninput="updateSubmitButtonState()"></td>
|
||||
<td><input <input type="text" name="bst" pattern="\d+(\.\d{1,2})?" placeholder="g" oninput="updateSubmitButtonState()"></td>
|
||||
<td><input <input type="text" name="ca" pattern="\d+(\.\d{1,2})?" placeholder="mg" oninput="updateSubmitButtonState()"></td>
|
||||
<td><input <input type="text" name="kcal" pattern="\d+([.,]\d{1,2})?" placeholder="g" oninput="updateSubmitButtonState()"></td>
|
||||
<td><input <input type="text" name="ew" pattern="\d+([.,]\d{1,2})?" placeholder="g" oninput="updateSubmitButtonState()"></td>
|
||||
<td><input <input type="text" name="fett" pattern="\d+([.,]\d{1,2})?" placeholder="g" oninput="updateSubmitButtonState()"></td>
|
||||
<td><input <input type="text" name="kh" pattern="\d+([.,]\d{1,2})?" placeholder="g" oninput="updateSubmitButtonState()"></td>
|
||||
<td><input <input type="text" name="bst" pattern="\d+([.,]\d{1,2})?" placeholder="g" oninput="updateSubmitButtonState()"></td>
|
||||
<td><input <input type="text" name="ca" pattern="\d+([.,]\d{1,2})?" placeholder="mg" oninput="updateSubmitButtonState()"></td>
|
||||
</tr>
|
||||
</table>
|
||||
<button type="submit" id="submit-button" disabled>Hinzufügen</button>
|
||||
|
Loading…
x
Reference in New Issue
Block a user