changeset 73:745c644d9564

Add new state for editing entries
author Björn Ricks <bjoern.ricks@intevation.de>
date Wed, 25 May 2011 13:36:17 +0200
parents 90b61a24742b
children 057e0fc8a74d
files getan/states.py
diffstat 1 files changed, 33 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/getan/states.py	Wed May 25 13:33:23 2011 +0200
+++ b/getan/states.py	Wed May 25 13:36:17 2011 +0200
@@ -531,3 +531,36 @@
         self.controller.add_project(self.key, description)
         self.controller.view.set_footer_text(self.msg('choose_proj'), 'question')
         return PausedProjectsState(self.controller, self.view)
+
+
+class EditEntryState(HandleUserInputState):
+    messages = {
+        'edit_entry': _('Edit entry text: '),
+    }
+
+    def __init__(self, state, controller, view, entry):
+        controller.view.set_footer_text(self.msg('edit_entry'),
+                                             'question', True)
+        super(EditEntryState, self).__init__(controller, view,
+                None, controller.view.view.get_footer())
+        self.footer.set_edit_text(entry.desc)
+        self.footer.set_edit_pos(len(self.footer.edit_text))
+        self.view.frame.set_focus('footer')
+        self.entry = entry
+        self.state = state
+        logger.debug("EditEntryState: Entry %s" % entry)
+
+    def enter(self):
+        entry_desc = self.footer.get_edit_text()
+        if entry_desc == '':
+            return self
+        entry = self.entry
+        entry.desc = entry_desc
+        self.controller.update_entry(entry)
+        return self.exit()
+
+    def exit(self):
+        self.controller.view.set_footer_text("", 'question', False)
+        return DefaultEntryListState(self.state, self.controller, self.view)
+
+
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)