fixed slots

This commit is contained in:
Yapollon 2024-02-13 10:46:54 +01:00
parent 32b0d3017c
commit 7ad54ffb30
4 changed files with 3 additions and 6 deletions

2
app.py
View File

@ -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:

View File

@ -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):

View File

@ -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)

View File

@ -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