[Getan-commits] [PATCH 19 of 32] Fix updating the entries of the project when one ore more entries are deleted

Wald Commits scm-commit at wald.intevation.org
Fri Oct 11 14:34:03 CEST 2013


# HG changeset patch
# User Björn Ricks <bjoern.ricks at intevation.de>
# Date 1381486238 -7200
# Node ID 05cb2e7e705f9f8f1c5e9d18fa397629adc62869
# Parent  eb05d803249e080a23fcf2d5cda172a5eeab517e
Fix updating the entries of the project when one ore more entries are deleted

diff -r eb05d803249e -r 05cb2e7e705f getan/controller.py
--- 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:


More information about the Getan-commits mailing list