changeset 155:497ed1991e85

Modify project selection The new project selection has two advantages: 1. It's possible to create and run e.g. projects a and aa Therefore it is possible to create a hirarchy again. 2. When inserting the project key only letters for valid projects are accepted. E.g. two projects exists aa and ab. In that case it is not possible to insert ac. Only a will be shown in the footer.
author Björn Ricks <bjoern.ricks@intevation.de>
date Thu, 06 Dec 2012 13:14:22 +0100
parents a620eb6e1fb0
children 917ebd951741
files getan/states.py
diffstat 1 files changed, 12 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/getan/states.py	Thu Dec 06 13:10:10 2012 +0100
+++ b/getan/states.py	Thu Dec 06 13:14:22 2012 +0100
@@ -92,7 +92,7 @@
         else:
             if len(key) > 0 and len(key[0]) == 1:
                 select_proj = SelectProjectState(self.controller, self.view, key[0])
-                return select_proj.check_key()
+                return select_proj.keypress(key)
         return self
 
 
@@ -114,7 +114,10 @@
     def set_footer_text(self):
         self.view.set_footer_text("Selecting project from key: %s" % self.proj_keys, "running")
 
-    def check_key(self):
+    def check_key(self, key):
+        return len(self.controller.find_projects_by_key(key)) > 0
+
+    def select_project(self):
         proj = self.controller.project_by_key(self.proj_keys)
         if proj:
             self.reset()
@@ -136,12 +139,15 @@
                 self.proj_keys = self.proj_keys[:-1]
                 self.set_footer_text()
             return self
-
+        if keys.get_enter() in key:
+            return self.select_project()
         else:
             if len(key) > 0 and len(key[0]) == 1:
-                self.proj_keys += key[0]
-                self.set_footer_text()
-                return self.check_key()
+                proj_key = self.proj_keys + key[0]
+                if self.check_key(proj_key):
+                    self.proj_keys += key[0]
+                    self.set_footer_text()
+                    return self.select_project()
         return self
 
 class ExitState(ProjectState):
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)