Skip to content

Commit

Permalink
WiP delete. DOES NOT WORK YET
Browse files Browse the repository at this point in the history
  • Loading branch information
ntoll authored and sssoleileraaa committed Jan 22, 2020
1 parent bdcfc2e commit 1fe8ba5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion securedrop_client/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,8 +752,11 @@ def on_delete_source_success(self, result) -> None:
"""
Handler for when a source deletion succeeds.
"""
# Delete the local version of the source.
storage.delete_local_source_by_uuid(self.session, result)
self.gui.clear_error_status() # remove any permanent error status message
self.sync_api()
# Update the sources UI.
self.update_sources()

def on_delete_source_failure(self, result: Exception) -> None:
logging.info("failed to delete source at server")
Expand Down
9 changes: 9 additions & 0 deletions securedrop_client/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ def get_local_sources(session: Session) -> List[Source]:
return session.query(Source).all()


def delete_local_source_by_uuid(session: Session, uuid: str) -> Source:
"""
Return the source with the referenced UUID.
"""
source = session.query(Source).filter_by(uuid=uuid)
session.delete(source)
session.commit()


def get_local_messages(session: Session) -> List[Message]:
"""
Return all submission objects from the local database.
Expand Down

0 comments on commit 1fe8ba5

Please sign in to comment.