Mercurial > getan
diff getan.py @ 99:4912568f9048
Refactor delete_entries to do what it says: delete the entries passed as argument
The provided entries weren't used to delete the entries from the database.
A better method name would have been delete_selected_entries().
author | Björn Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Mon, 12 Sep 2011 13:57:58 +0200 |
parents | 99639833968d |
children | a23e8191c6bc |
line wrap: on
line diff
--- a/getan.py Mon Sep 12 13:32:15 2011 +0200 +++ b/getan.py Mon Sep 12 13:57:58 2011 +0200 @@ -85,26 +85,14 @@ self.project_view.update_all() def delete_entries(self, entry_nodes): - if not entry_nodes: return - proj = None - entries = [] - try: - while self.entries_view.selection: - node = self.entries_view.selection.pop() - if node.selected: node.select() - entries.append(node.item) - logger.info("GetanController: delete entry '%s' (id = %d, "\ - "project id = %d)" - % (node.item.desc, node.item.id, - node.item.project_id)) - - if proj is None: - proj = self.project_by_id(node.item.project_id) - finally: - self.backend.delete_entries(entries) - proj.entries = self.backend.load_entries(proj.id) - self.update_entries(proj) - self.project_view.update() + if not entry_nodes: + return + proj = self.project_by_id(entry_nodes[0].project_id) + entries = entry_nodes + self.backend.delete_entries(entries) + proj.entries = self.backend.load_entries(proj.id) + self.update_entries(proj) + self.project_view.update() def update_project_list(self): self.project_view.update()