diff getan.py @ 107:a23e8191c6bc

Update project list when a new project was created
author Björn Ricks <bjoern.ricks@intevation.de>
date Mon, 12 Sep 2011 14:54:00 +0200
parents 4912568f9048
children 1165422b5db7
line wrap: on
line diff
--- a/getan.py	Mon Sep 12 14:53:28 2011 +0200
+++ b/getan.py	Mon Sep 12 14:54:00 2011 +0200
@@ -27,14 +27,11 @@
         self.ev_class = ev_class
         self.pv_class = pv_class
 
-        self.projects = backend.load_projects()
-        if self.projects:
-            entries = backend.load_entries(self.projects[0].id)
-        else:
-            entries = []
+        self.backend      = backend
+        projects, entries = self.load_projects()
+        self.projects = projects
         self.running  = []
 
-        self.backend      = backend
         self.project_view = pv_class(self, self.projects)
         self.entries_view = ev_class(entries)
 
@@ -54,6 +51,14 @@
         else:
             self.state = self.state.keypress(input)
 
+    def load_projects(self):
+        projects = self.backend.load_projects()
+        if projects:
+            entries = self.backend.load_entries(projects[0].id)
+        else:
+            entries = []
+        return (projects, entries)
+
     def update_entries(self, project):
         logger.debug("GetanController: update entries.")
         if project: entries = self.backend.load_entries(project.id)
@@ -139,6 +144,7 @@
         if not key or not description:
             return
         self.backend.insert_project(key, description)
+        self.update_projects()
         self.update_project_list()
 
     def update_entry(self, entry):
@@ -148,6 +154,11 @@
         for project in self.running:
             self.stop_project(display=False)
 
+    def update_projects(self):
+        projects, entries = self.load_projects()
+        self.projects = projects
+        self.project_view.load_rows(projects)
+
 
 def main():
 
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)