diff --git a/app.py b/app.py index b3398df..295a8cc 100644 --- a/app.py +++ b/app.py @@ -211,16 +211,6 @@ def habit_create(): # Back to index return redirect(url_for('index')) - """return render_template( - 'habit.html', - title='Erstelle ein Habit', - name=name, - note=note, - times=times, - unit=unit, - errors=errors, - )""" - @app.route('/profile') @login_required @@ -300,28 +290,6 @@ def check_habit(): for tracking in trackings: if tracking.created_at.date() == datetime.date.today(): delete_tracking = tracking - """ - # day - if habit.unit == 0: - if tracking.created_at.date() == datetime.date.today(): - delete_tracking = tracking - break - # week - elif habit.unit == 1: - if tracking.created_at.date().isocalendar()[1] == datetime.date.today().isocalendar()[1]: - delete_tracking = tracking - break - # month - elif habit.unit == 2: - if tracking.created_at.date().month == datetime.date.today().month: - delete_tracking = tracking - break - # year - elif habit.unit == 3: - if tracking.created_at.date().year == datetime.date.today().year: - delete_tracking = tracking - break - """ if not delete_tracking: HabitTrackings.create(habit_id, 1) diff --git a/db/SQLiteClient.py b/db/SQLiteClient.py index 514a7d6..4220d40 100644 --- a/db/SQLiteClient.py +++ b/db/SQLiteClient.py @@ -140,20 +140,22 @@ def get_slots(user_id: int): return slots -def update_habit(id: int, name: str, note: str, times: int, unit: int): - query = f"UPDATE habits SET name = {name}, note = {note}, times = {times}, unit = {unit} WHERE id = {id};" - conn = con3() - cursor = conn.cursor() - cursor.execute(query) - conn.close() - return cursor.lastrowid - - def update_slot(id: int, slot: int): query = f"UPDATE habits SET slot = {slot} WHERE id = {id};" conn = con3() cursor = conn.cursor() cursor.execute(query) + conn.commit() + conn.close() + return cursor.lastrowid + + +def update_habit(id: int, name: str, note: str, times: int, unit: int): + query = f"UPDATE habits SET name = {name}, note = {note}, times = {times}, unit = {unit} WHERE id = {id};" + conn = con3() + cursor = conn.cursor() + cursor.execute(query) + conn.commit() conn.close() return cursor.lastrowid @@ -210,4 +212,6 @@ def delete_habitTrackings(id: int): if __name__ == "__main__": - pass \ No newline at end of file + habits = get_habits(1) + for habit in habits: + print(habit[6]) diff --git a/models/Habit.py b/models/Habit.py index 221934d..013c430 100644 --- a/models/Habit.py +++ b/models/Habit.py @@ -1,4 +1,3 @@ -import json from dataclasses import dataclass from datetime import datetime