These adjustments address a lot of the current problems with the models, mainly the deletion process but also the addition of a add_user and remove_user function for the HabitLists. In addition a lot of inconsistencies over the whole code were fixed and readjusted. Thx for reading
22 lines
578 B
Python
22 lines
578 B
Python
from dataclasses import dataclass
|
|
from db.SQLiteClient import create_habitTrackings, get_habitTrackings, delete_habitTrackings
|
|
|
|
|
|
@dataclass
|
|
class HabitTrackings:
|
|
id: int
|
|
habit_id: int
|
|
|
|
@staticmethod
|
|
def create(habit_id: int):
|
|
id = create_habitTrackings(habit_id)
|
|
return HabitTrackings(id, habit_id)
|
|
|
|
@staticmethod
|
|
def get(id: int):
|
|
habitTrackings = get_habitTrackings(id)
|
|
return HabitTrackings(habitTrackings[0], habitTrackings[1]) if habitTrackings else None
|
|
|
|
def delete(self):
|
|
delete_habitTrackings(self.id)
|