changeset 100:8f433e3c2f21

Allow to pass entries to the DeleteEntryState By default DeleteEntryState uses the selected entries if no entry is passes to the constructor. This allows to reuse the state class for single entry deletion
author Björn Ricks <bjoern.ricks@intevation.de>
date Mon, 12 Sep 2011 14:05:34 +0200
parents 4912568f9048
children df98b84d22f9
files getan/states.py
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/getan/states.py	Mon Sep 12 13:57:58 2011 +0200
+++ b/getan/states.py	Mon Sep 12 14:05:34 2011 +0200
@@ -420,9 +420,12 @@
         'delete'  : _("Really delete this entry? (y/n)"),
     }
 
-    def __init__(self, state, controller, view):
+    def __init__(self, state, controller, view, entries=None):
         super(DeleteEntryState, self).__init__(state, controller, view)
         self.view.set_footer_text(self.msg('delete'), 'question')
+        self.entries = entries
+        if not self.entries:
+            self.entries = [x.item for x in self.view.selection]
 
     def keypress(self, key):
         ret = super(DeleteEntryState, self).keypress(key)
@@ -430,9 +433,8 @@
             return ret
 
         if 'y' in key:
-            entries = [x.item for x in self.view.selection]
-            if entries:
-                self.controller.delete_entries(entries)
+            if self.entries:
+                self.controller.delete_entries(self.entries)
                 self.renew_focus()
             self.view.set_footer_text("", 'entry_footer')
             return DefaultEntryListState(self.projectlist_state,
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)