added a way to accept shared habit_lists instead of directly accepting. accepted via habit_list.accept_List(habit_List.id, user.id)
This commit is contained in:
parent
0dbac5afd5
commit
db45e7f059
@ -331,6 +331,15 @@ def add_user(list_id: int, user_id: int):
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
def accept_List(list_id: int, user_id: int):
|
||||
query = (f"UPDATE habit_users SET accepted = true WHERE {user_id} = habit_users.user_id AND {list_id} = habit_users.list_id;")
|
||||
conn = con3()
|
||||
cursor = conn.cursor()
|
||||
cursor.execute(query)
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
|
||||
|
||||
def remove_user(list_id: int, user_id: int):
|
||||
query = f"DELETE FROM habit_lists WHERE user_id = {user_id} AND list_id = {list_id};"
|
||||
|
||||
@ -3,7 +3,7 @@ from dataclasses import dataclass
|
||||
from models.Habit import Habit
|
||||
from models.User import User
|
||||
from db.SQLiteClient import (create_habitList, get_habitList, get_habits, get_users, add_user, remove_user,
|
||||
update_habitList, delete_habitList)
|
||||
update_habitList, delete_habitList, accept_List)
|
||||
|
||||
|
||||
@dataclass
|
||||
@ -66,6 +66,8 @@ class HabitList:
|
||||
else:
|
||||
return None
|
||||
|
||||
def accept_List(self, user:User):
|
||||
accept_List(self.id, user.id)
|
||||
|
||||
# Removes a User from the HabitList
|
||||
def remove_user(self, user_id):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user