From 6282c374f7cac26951009ce6b22b86769f750384 Mon Sep 17 00:00:00 2001 From: Verox001 Date: Tue, 5 Mar 2024 09:59:09 +0100 Subject: [PATCH 1/8] Fixed habit times check --- app.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app.py b/app.py index 087d361..e4a9fa7 100644 --- a/app.py +++ b/app.py @@ -207,6 +207,10 @@ def habit_create(): except ValueError: errors['list_query'] = 'Die Anzahl muss eine Zahl sein.' + # Check if unit is day and times is one + if unit == 'Tag' and times == 1: + errors['times'] = 'Die Anzahl muss größer als 1 sein, wenn das Habit täglich ist.' + if errors: return render_template( 'habit.html', @@ -378,6 +382,9 @@ def edit_habit_change(): except ValueError: errors['list_query'] = 'Die Anzahl muss eine Zahl sein.' + if unit == 'Tag' and times == 1: + errors['times'] = 'Die Anzahl muss größer als 1 sein, wenn das Habit täglich ist.' + if errors: return render_template( "edit-habit.html", From 45f39745147faa50366a2f1eec54ae91a7f36600 Mon Sep 17 00:00:00 2001 From: janphilippweinsheimer Date: Tue, 5 Mar 2024 10:05:38 +0100 Subject: [PATCH 2/8] fixed yassins wrongdoing --- db/SQLiteClient.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/SQLiteClient.py b/db/SQLiteClient.py index d9b811c..efb9bb9 100644 --- a/db/SQLiteClient.py +++ b/db/SQLiteClient.py @@ -190,7 +190,7 @@ def update_slot(id: int, slot: int): def update_habit(id: int, name: str, note: str, times: int, unit: int): now = datetime.now().isoformat() - query = (f"UPDATE habits SET name = {name}, note = {note}, times = {times}, unit = {unit}, updated_at = '{now}' " + query = (f"UPDATE habits SET name = '{name}', note = '{note}', times = {times}, unit = {unit}, updated_at = '{now}' " f"WHERE id = {id};") conn = con3() cursor = conn.cursor() From 8814a6a834a6215ca4842cc4c19004e0492e8e03 Mon Sep 17 00:00:00 2001 From: Verox001 Date: Tue, 5 Mar 2024 10:13:50 +0100 Subject: [PATCH 3/8] Added requirements.txt --- requirements.txt | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..fc4309f --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +pillow~=10.2.0 +flask~=3.0.0 \ No newline at end of file From 7aec15c4cd0cdce216446870ce592e0ccf206420 Mon Sep 17 00:00:00 2001 From: Verox001 Date: Tue, 5 Mar 2024 10:33:28 +0100 Subject: [PATCH 4/8] Updated requirements.txt --- requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index fc4309f..dc40e89 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ pillow~=10.2.0 -flask~=3.0.0 \ No newline at end of file +flask~=3.0.0 +flask-login~=0.6.3 \ No newline at end of file From 295f02509c2e00110a062a84f46cb336db13e3ef Mon Sep 17 00:00:00 2001 From: Verox001 Date: Tue, 5 Mar 2024 10:37:18 +0100 Subject: [PATCH 5/8] Started app at 0.0.0.0 host --- app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.py b/app.py index e4a9fa7..b92f71e 100644 --- a/app.py +++ b/app.py @@ -667,4 +667,4 @@ def add_user(): # Run the application if __name__ == '__main__': - app.run(port=5000, debug=True) + app.run(host="0.0.0.0", port=5000, debug=True) From 51742411ca10aa74a12781410ac9dd38579b3cd3 Mon Sep 17 00:00:00 2001 From: Verox001 Date: Tue, 5 Mar 2024 10:49:29 +0100 Subject: [PATCH 6/8] Fixed day count --- app.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app.py b/app.py index b92f71e..dd72258 100644 --- a/app.py +++ b/app.py @@ -208,8 +208,8 @@ def habit_create(): errors['list_query'] = 'Die Anzahl muss eine Zahl sein.' # Check if unit is day and times is one - if unit == 'Tag' and times == 1: - errors['times'] = 'Die Anzahl muss größer als 1 sein, wenn das Habit täglich ist.' + if unit == 'Tag' and times != 1: + errors['times'] = 'Die Anzahl muss 1 sein, wenn das Habit täglich ist.' if errors: return render_template( @@ -382,8 +382,8 @@ def edit_habit_change(): except ValueError: errors['list_query'] = 'Die Anzahl muss eine Zahl sein.' - if unit == 'Tag' and times == 1: - errors['times'] = 'Die Anzahl muss größer als 1 sein, wenn das Habit täglich ist.' + if unit == 'Tag' and times != 1: + errors['times'] = 'Die Anzahl muss 1 sein, wenn das Habit täglich ist.' if errors: return render_template( From 785edd1f88a693382c0de1fe6903ea7b192b4de8 Mon Sep 17 00:00:00 2001 From: Verox001 Date: Tue, 5 Mar 2024 10:54:26 +0100 Subject: [PATCH 7/8] Fixed SQL operational error --- db/SQLiteClient.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/SQLiteClient.py b/db/SQLiteClient.py index d9b811c..efb9bb9 100644 --- a/db/SQLiteClient.py +++ b/db/SQLiteClient.py @@ -190,7 +190,7 @@ def update_slot(id: int, slot: int): def update_habit(id: int, name: str, note: str, times: int, unit: int): now = datetime.now().isoformat() - query = (f"UPDATE habits SET name = {name}, note = {note}, times = {times}, unit = {unit}, updated_at = '{now}' " + query = (f"UPDATE habits SET name = '{name}', note = '{note}', times = {times}, unit = {unit}, updated_at = '{now}' " f"WHERE id = {id};") conn = con3() cursor = conn.cursor() From 424a423f7c2786b07fd418a9f3a4f12b0fdb4eea Mon Sep 17 00:00:00 2001 From: janphilippweinsheimer Date: Tue, 5 Mar 2024 11:15:43 +0100 Subject: [PATCH 8/8] delete list --- app.py | 18 ++++++++++++++++++ templates/components/delete_list.html | 20 ++++++++++++++++++++ templates/components/habit_lists.html | 24 ++++++++++++++++++++++-- templates/components/scripts.html | 22 ++++++++++++++++++++++ templates/index.html | 4 ++++ 5 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 templates/components/delete_list.html diff --git a/app.py b/app.py index dd72258..a28b27f 100644 --- a/app.py +++ b/app.py @@ -568,6 +568,24 @@ def delete_habit(): return {} +@app.route('/delete-list', methods=['POST']) +@login_required +def delete_list(): + list_id = request.get_json()["listId"] + + habit_list = HabitList.get(list_id) + + if habit_list is None: + return {"error": "List not found"} + + # Check if habit belongs to user + if current_user not in habit_list.get_users(): + return {"error": "List does not belong to user"} + + habit_list.delete() + return {} + + @app.route('/reorder', methods=['POST']) @login_required def reorder_habits(): diff --git a/templates/components/delete_list.html b/templates/components/delete_list.html new file mode 100644 index 0000000..b140c83 --- /dev/null +++ b/templates/components/delete_list.html @@ -0,0 +1,20 @@ + + \ No newline at end of file diff --git a/templates/components/habit_lists.html b/templates/components/habit_lists.html index a111a4a..86b2653 100644 --- a/templates/components/habit_lists.html +++ b/templates/components/habit_lists.html @@ -15,7 +15,7 @@