diff --git a/app.py b/app.py index a5e8bb4..5419869 100644 --- a/app.py +++ b/app.py @@ -378,7 +378,7 @@ def delete_habit(): @app.route('/reorder', methods=['POST']) @login_required def reorder_habits(): - new_index = request.get_json()["newIndex"] + new_index = request.get_json()["newIndex"]+1 habit = Habit.get(request.get_json()["habitId"]) if habit is None: diff --git a/db/SQLiteClient.py b/db/SQLiteClient.py index 893b265..211cddc 100644 --- a/db/SQLiteClient.py +++ b/db/SQLiteClient.py @@ -151,7 +151,7 @@ def get_next_slot(list_id: int): cursor.execute(query) slot = cursor.fetchone() conn.close() - return slot[0] + 1 if slot else 0 + return slot[0] + 1 if slot else 1 def get_slots(list_id: int): diff --git a/models/Habit.py b/models/Habit.py index 0ac0f15..f524854 100644 --- a/models/Habit.py +++ b/models/Habit.py @@ -30,7 +30,6 @@ class Habit: @staticmethod def create(list_id: int, name: str, times: int, note: str | None = None, unit: int | None = 1): slot = get_next_slot(list_id) - print(slot) id = create_habit(list_id, name, times, unit, slot, note) return Habit(id, list_id, name, note, times, unit, slot) @@ -69,7 +68,6 @@ class Habit: def delete(self): slots = get_slots(self.list_id)[self.slot+1:] - print(slots) for slot in slots: update_slot(slot[0], slot[1] - 1) delete_habit(self.id) diff --git a/models/HabitList.py b/models/HabitList.py index ac888d3..97aa309 100644 --- a/models/HabitList.py +++ b/models/HabitList.py @@ -1,8 +1,7 @@ from dataclasses import dataclass from datetime import date, datetime -from db.SQLiteClient import create_habitTrackings, get_habitTrackings, delete_habitTrackings, create_habitList, \ - get_habitList, get_habits, get_users +from db.SQLiteClient import delete_habitTrackings, create_habitList, get_habitList, get_habits, get_users from models.Habit import Habit from models.User import User