[Getan-commits] [PATCH] Makes 'move' operation more consistent

Wald Commits scm-commit at wald.intevation.org
Wed Sep 13 09:06:56 CEST 2017


# HG changeset patch
# User Bernhard Reiter <bernhard at intevation.de>
# Date 1505286388 -7200
# Node ID 3103429ec963fee7392f64b39cf26bb9562d7c25
# Parent  d56fee6fd7ca9155b984c53443ebcc4752decc62
Makes 'move' operation more consistent.

 * Improves 'move' operation to work in the current entry, if there is no
   selection. This is more consistent with 'delete'. Patch by Frank Koormann.

 * Removes two superfluous methods in controller.

 * Improves README: Adds Frank Koormann as contributor. Better phrasing
   for the license indication.

 * TODO: Details problem with multi-selections.

diff -r d56fee6fd7ca -r 3103429ec963 CHANGES
--- a/CHANGES	Tue Sep 12 14:52:30 2017 +0200
+++ b/CHANGES	Wed Sep 13 09:06:28 2017 +0200
@@ -2,6 +2,9 @@
 
 TODO
 
+ * Improves 'move' operation to work in the current entry, if there is no
+   selection. This is more consistent with 'delete'. Patch by Frank Koormann.
+
  * Documentation: Adds description of the available tree mode.
 
 
diff -r d56fee6fd7ca -r 3103429ec963 README
--- a/README	Tue Sep 12 14:52:30 2017 +0200
+++ b/README	Wed Sep 13 09:06:28 2017 +0200
@@ -179,7 +179,7 @@
 
 CREDITS
 =======
-Getan is Free Software licensed under the terms of GPLv3 or later.
+Getan is Free Software licensed under the terms of GNU GPL v>=3.
 For details see LICENSE coming with the source of 'getan'.
 
 
@@ -193,6 +193,7 @@
 
 Contributions
 -------------
+Frank Koormann
 Stephan Holl
 Tom Gottfried
 
@@ -201,5 +202,4 @@
 To all users that gave feedback, especially at Intevation.
 
 
-
 .. vim: set ts=4 sw=4 tw=80 filetype=rst :
diff -r d56fee6fd7ca -r 3103429ec963 TODO
--- a/TODO	Tue Sep 12 14:52:30 2017 +0200
+++ b/TODO	Wed Sep 13 09:06:28 2017 +0200
@@ -8,7 +8,10 @@
   We could solve this requirement by making it configurable.
 
 20170317 BER: Reproduce and then fix a defect that it is surprising which
-  entries are moved by `m`. It happens when you have changed a lot of entries
+  entries are moved by `m` or deleted by 'd'.
+  It probably has to do how multi-selection are handled. Maybe they
+  are not cleared properly at the end of an operation.
+  One description: It happens when you have changed a lot of entries
   from different projects (I assume), e.g. by editing the description,
   the length or timedate and then use move where you intend to only move
   one, the unwanted result is several moved entries.
diff -r d56fee6fd7ca -r 3103429ec963 getan/controller.py
--- a/getan/controller.py	Tue Sep 12 14:52:30 2017 +0200
+++ b/getan/controller.py	Wed Sep 13 09:06:28 2017 +0200
@@ -73,28 +73,12 @@
         if self.view:
             self.view.update_entries(project.entries)
 
-    def move_entry(self, entry, project):
-        self.move_entries([entry], project)
-
     def move_entries(self, entries, project):
         old_project = self.project_by_id(entries[0].project_id)
         self.backend.move_entries(entries, project.id)
         self.update_entries(old_project)
         self.project_view.update_rows()
 
-    def move_selected_entries(self, project):
-        entries = []
-        while self.entries_view.selection:
-            node = self.entries_view.selection.pop()
-            if node.selected:
-                node.select()
-            entries.append(node.item)
-            logger.info("GetanController: move entry '%s' (id = %d, "
-                        "project id = %d) to project '%s'"
-                        % (node.item.desc, node.item.id,
-                            node.item.project_id, project.desc))
-        self.move_entries(entries, project)
-
     def delete_entries(self, entry_nodes):
         if not entry_nodes:
             return
diff -r d56fee6fd7ca -r 3103429ec963 getan/states.py
--- a/getan/states.py	Tue Sep 12 14:52:30 2017 +0200
+++ b/getan/states.py	Wed Sep 13 09:06:28 2017 +0200
@@ -533,6 +533,11 @@
             if self.view.selection:
                 self.set_next_state(MoveEntryState(self.projectlist_state,
                                                    self.controller, self.view))
+            else:
+                entry = self.view.item_in_focus()
+                self.set_next_state(MoveEntryState(self.projectlist_state,
+                                                     self.controller,
+                                                     self.view, [entry]))
             return True
 
         if keys.get_entry_edit() in key:
@@ -608,11 +613,14 @@
 
     proj = None
 
-    def __init__(self, state, controller, view):
+    def __init__(self, state, controller, view, entries=None):
         super(MoveEntryState, self).__init__(state, controller, view)
         self.view.set_footer_text(self.msg('project'), 'question')
+        self.entries = entries
         self.proj_keys = ""
         self.project_view = controller.project_view
+        if not self.entries:
+            self.entries = [x.item for x in self.view.selection]
 
     def set_project_footer(self):
         self.project_view.set_footer_text("Selecting project from "
@@ -638,7 +646,7 @@
         keys = self.config.get_keybinding()
         if 'y' in key and self.proj:
             logger.debug("MoveEntryState: move selected entries.")
-            self.controller.move_selected_entries(self.proj)
+            self.controller.move_entries(self.entries, self.proj)
             self.renew_focus()
             self.view.set_footer_text('', 'entry_footer')
             self.proj = None
@@ -685,6 +693,9 @@
 
         return False
 
+    def set_focus(self):
+        self.controller.view.set_focus("entries")
+
 
 class AlterProjectState(HandleUserInputState):
 


More information about the Getan-commits mailing list