Add Delete Crossed Off Service
This commit is contained in:
@@ -89,6 +89,21 @@ def list_delete(session: Session, id: int):
|
||||
session.commit()
|
||||
|
||||
|
||||
def list_deleteCrossedOff(session: Session, id: int) -> ShoppingList:
|
||||
"""Delete all Crossed-Off Entries from a Shopping List."""
|
||||
sList = list_by_id(session, id)
|
||||
if not sList:
|
||||
raise NotFoundError(f'List {id} does not exist')
|
||||
|
||||
for entry in sList.entries:
|
||||
if entry.crossedOff:
|
||||
session.delete(entry)
|
||||
|
||||
session.commit()
|
||||
|
||||
return sList
|
||||
|
||||
|
||||
def list_deleteItem(session: Session, listId: int, entryId: int):
|
||||
"""Delete an Entry from a Shopping List."""
|
||||
entry = list_entry_by_id(session, listId, entryId)
|
||||
@@ -153,6 +168,7 @@ def list_update(
|
||||
|
||||
sList.name = name
|
||||
sList.notes = notes
|
||||
sList.set_modified_at()
|
||||
|
||||
session.add(sList)
|
||||
session.commit()
|
||||
@@ -184,6 +200,8 @@ def list_entry_set_crossedOff(session: Session, listId: int, entryId: int, cross
|
||||
entry = list_entry_by_id(session, listId, entryId)
|
||||
|
||||
entry.crossedOff = crossedOff
|
||||
entry.set_modified_at()
|
||||
|
||||
session.add(entry)
|
||||
session.commit()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user