changeset 314:05cb2e7e705f

Fix updating the entries of the project when one ore more entries are deleted
author Björn Ricks <bjoern.ricks@intevation.de>
date Fri, 11 Oct 2013 12:10:38 +0200
parents eb05d803249e
children 8f89fd351225
files getan/controller.py
diffstat 1 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/getan/controller.py	Fri Oct 11 12:09:42 2013 +0200
+++ b/getan/controller.py	Fri Oct 11 12:10:38 2013 +0200
@@ -69,10 +69,10 @@
     def update_entries(self, project):
         logger.debug("GetanController: update entries for project %s." %
                      project.id)
-        if project:
-            entries = self.backend.load_entries(project.id)
-        else:
-            entries = []
+
+        entries = self.backend.load_entries(project.id)
+        project.entries = entries
+
         if self.view:
             self.view.update_entries(entries)
 
@@ -83,7 +83,6 @@
         old_project = self.project_by_id(entries[0].project_id)
         self.backend.move_entries(entries, project.id)
         project.entries = self.backend.load_entries(project.id)
-        old_project.entries = self.backend.load_entries(old_project.id)
         self.update_entries(old_project)
         self.project_view.update_rows()
 
@@ -103,11 +102,12 @@
     def delete_entries(self, entry_nodes):
         if not entry_nodes:
             return
-        proj = self.project_by_id(entry_nodes[0].project_id)
-        entries = entry_nodes
-        self.backend.delete_entries(entries)
-        proj.entries = self.backend.load_entries(proj.id)
-        self.update_entries(proj)
+        proj_id = entry_nodes[0].project_id
+        proj = self.project_by_id(proj_id)
+        if proj:
+            entries = entry_nodes
+            self.backend.delete_entries(entries)
+            self.update_entries(proj)
 
     def project_by_key(self, key):
         for proj in self.projects:
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)