Gewohnheit erstellen Butten

Seite für das erstellen von einer neuen Gewohnheit
fehlermeldungen und die übergabe an das backend müssen noch hinzugefügt werden
This commit is contained in:
janphilippweinsheimer 2024-01-19 11:13:01 +01:00
parent 8463c01133
commit 873bdc1e86
3 changed files with 49 additions and 8 deletions

7
app.py
View File

@ -41,7 +41,7 @@ def index():
# habits = [("lesen", "eine Seite vor dem schlafen gehen"), ("sport", "3x Gym")] # habits = [("lesen", "eine Seite vor dem schlafen gehen"), ("sport", "3x Gym")]
return render_template( return render_template(
'index.html', 'index.html',
title='Hallo ' + current_user.name, title=f"Hallo {current_user.name}",
utc_dt=datetime.datetime.now().strftime("%d.%m.%Y %H:%M %A"), utc_dt=datetime.datetime.now().strftime("%d.%m.%Y %H:%M %A"),
habits=habits, habits=habits,
errors={}, errors={},
@ -149,7 +149,6 @@ def habit_creation():
title='Erstelle ein Habit', title='Erstelle ein Habit',
unit=1, unit=1,
errors={}, errors={},
habits=current_user.get_habits()
) )
@ -186,8 +185,7 @@ def habit_create():
note=note, note=note,
times=times, times=times,
unit=unit, unit=unit,
errors=errors, errors=errors
habits=current_user.get_habits()
) )
# Map unit to integer # Map unit to integer
@ -214,7 +212,6 @@ def habit_create():
times=times, times=times,
unit=unit, unit=unit,
errors=errors, errors=errors,
habits=current_user.get_habits()
) )

36
templates/habit.html Normal file
View File

@ -0,0 +1,36 @@
{% extends 'layouts/main.html' %}
{% block content %}
<form>
<div class="mb-3">
<label for="name" class="form-label">Name der Gewohnheit</label>
<input type="text" class="form-control" id="name" name="name">
</div>
<div class="mb-3">
<label for="note" class="form-label">Beschreibung</label>
<input type="text" class="form-control" id="note" name="note">
</div>
<div class="row">
<div class="mb-3 col-2">
<label for="times" class="form-label">Häufigkeit</label>
<input type="number" min="1" class="form-control" id="times" name="times">
</div>
<div class="mb-3 col-10">
<label for="note" class="form-label">Im Zeitraum</label>
<select class="form-select" id="unit" name="unit">
<option selected value="Woche">Woche</option>
<option value="Tag">Tag</option>
<option value="Monat">Monat</option>
<option value="Jahr">Jahr</option>
</select>
</div>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
{% endblock %}

View File

@ -1,7 +1,7 @@
{% extends 'layouts/main.html' %} {% extends 'layouts/main.html' %}
{% block content %} {% block content %}
<h1>Hello World!</h1> <h1>{{ title }}</h1>
<h3>{{ utc_dt }}</h3> <h3>{{ utc_dt }}</h3>
@ -30,9 +30,17 @@
</script>
<h2>Task List</h2>
</script>
<div class="row">
<h2 class="col-10">Task List</h2>
<a class="col-2 btn btn-primary" role="button" href="/habit">
Task erstellen
</a>
</div>
<ul class="task-list row"> <ul class="task-list row">
{% for habit in habits %} {% for habit in habits %}
<li class="row col-md-4"> <li class="row col-md-4">