fixed slots
This commit is contained in:
parent
32b0d3017c
commit
7ad54ffb30
2
app.py
2
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:
|
||||
|
||||
@ -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):
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user