comparison 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
comparison
equal deleted inserted replaced
106:a0779fb2ef4d 107:a23e8191c6bc
25 class GetanController: 25 class GetanController:
26 def __init__(self, backend, pv_class, ev_class): 26 def __init__(self, backend, pv_class, ev_class):
27 self.ev_class = ev_class 27 self.ev_class = ev_class
28 self.pv_class = pv_class 28 self.pv_class = pv_class
29 29
30 self.projects = backend.load_projects() 30 self.backend = backend
31 if self.projects: 31 projects, entries = self.load_projects()
32 entries = backend.load_entries(self.projects[0].id) 32 self.projects = projects
33 else:
34 entries = []
35 self.running = [] 33 self.running = []
36 34
37 self.backend = backend
38 self.project_view = pv_class(self, self.projects) 35 self.project_view = pv_class(self, self.projects)
39 self.entries_view = ev_class(entries) 36 self.entries_view = ev_class(entries)
40 37
41 self.view = GetanView(self, self.project_view, self.entries_view) 38 self.view = GetanView(self, self.project_view, self.entries_view)
42 self.state = PausedProjectsState(self, self.project_view) 39 self.state = PausedProjectsState(self, self.project_view)
51 if 'window resize' in input: 48 if 'window resize' in input:
52 self.view.loop.screen_size = None 49 self.view.loop.screen_size = None
53 self.view.loop.draw_screen() 50 self.view.loop.draw_screen()
54 else: 51 else:
55 self.state = self.state.keypress(input) 52 self.state = self.state.keypress(input)
53
54 def load_projects(self):
55 projects = self.backend.load_projects()
56 if projects:
57 entries = self.backend.load_entries(projects[0].id)
58 else:
59 entries = []
60 return (projects, entries)
56 61
57 def update_entries(self, project): 62 def update_entries(self, project):
58 logger.debug("GetanController: update entries.") 63 logger.debug("GetanController: update entries.")
59 if project: entries = self.backend.load_entries(project.id) 64 if project: entries = self.backend.load_entries(project.id)
60 else: entries = [] 65 else: entries = []
137 142
138 def add_project(self, key, description): 143 def add_project(self, key, description):
139 if not key or not description: 144 if not key or not description:
140 return 145 return
141 self.backend.insert_project(key, description) 146 self.backend.insert_project(key, description)
147 self.update_projects()
142 self.update_project_list() 148 self.update_project_list()
143 149
144 def update_entry(self, entry): 150 def update_entry(self, entry):
145 self.backend.update_entry(entry) 151 self.backend.update_entry(entry)
146 152
147 def shutdown(self): 153 def shutdown(self):
148 for project in self.running: 154 for project in self.running:
149 self.stop_project(display=False) 155 self.stop_project(display=False)
156
157 def update_projects(self):
158 projects, entries = self.load_projects()
159 self.projects = projects
160 self.project_view.load_rows(projects)
150 161
151 162
152 def main(): 163 def main():
153 164
154 usage = "usage: %prog [options] [databasefile (default: " + \ 165 usage = "usage: %prog [options] [databasefile (default: " + \
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)