[Getan-commits] [PATCH] Added possibility to move starting datetime of entries
Wald Commits
scm-commit at wald.intevation.org
Mon Sep 12 10:21:02 CEST 2016
# HG changeset patch
# User Bernhard Reiter <bernhard at intevation.de>
# Date 1473668361 -7200
# Node ID 527168c08ae46f396fe362dcab5b77f2b90cb004
# Parent 67dc21692bfadd3dbca32ac35a0ca4cbd094a8f4
Added possibility to move starting datetime of entries.
diff -r 67dc21692bfa -r 527168c08ae4 INTRODUCTION
--- a/INTRODUCTION Thu Jan 28 10:08:32 2016 +0100
+++ b/INTRODUCTION Mon Sep 12 10:19:21 2016 +0200
@@ -14,6 +14,7 @@
| F2 | Switch sorting of entries in ProjectList.
| d | Delete marked entries (in EntryList).
| e | Edit the text of an entry.
+| a | Adjust the starting datetime of an entry.
| m | Start the 'wizard' to move selected entries to another
project.
| esc | Exit the application. This is only possible if no project
diff -r 67dc21692bfa -r 527168c08ae4 TODO
--- a/TODO Thu Jan 28 10:08:32 2016 +0100
+++ b/TODO Mon Sep 12 10:19:21 2016 +0200
@@ -1,4 +1,5 @@
-20160128 BER: Should be possible to move the starting time with the GUI.
+20160912 BER: Better code: states.py: classes EditEntryState and
+ AdjustEntryState have same methods exit() and set_focus(), maybe join them?
20151130 BER: templates/zeiterfassung2: Really sort by date, right now the
sorting it sometimes skewed if the week wraps around the end of the month.
diff -r 67dc21692bfa -r 527168c08ae4 getan/config.py
--- a/getan/config.py Thu Jan 28 10:08:32 2016 +0100
+++ b/getan/config.py Mon Sep 12 10:19:21 2016 +0200
@@ -89,6 +89,7 @@
KEY_ENTRY_DOWN = "entry_down"
KEY_ENTRY_MOVE = "entry_move"
KEY_ENTRY_EDIT = "entry_edit"
+ KEY_ENTRY_ADJUST = "entry_adjust"
KEY_ADD_TIME = "add_time"
KEY_SUBTRACT_TIME = "subtract_time"
KEY_PROJECT_PAUSE = "project_pause"
@@ -107,6 +108,7 @@
KEY_ENTRY_DELETE: "d",
KEY_ENTRY_MOVE: "m",
KEY_ENTRY_EDIT: "e",
+ KEY_ENTRY_ADJUST: "a",
KEY_ADD_TIME: "+",
KEY_SUBTRACT_TIME: "-",
KEY_PROJECT_PAUSE: " ",
@@ -158,6 +160,9 @@
def get_entry_edit(self):
return self.get_binding(self.KEY_ENTRY_EDIT)
+ def get_entry_adjust(self):
+ return self.get_binding(self.KEY_ENTRY_ADJUST)
+
def get_entry_up(self):
return self.get_binding(self.KEY_ENTRY_UP)
diff -r 67dc21692bfa -r 527168c08ae4 getan/states.py
--- a/getan/states.py Thu Jan 28 10:08:32 2016 +0100
+++ b/getan/states.py Mon Sep 12 10:19:21 2016 +0200
@@ -543,6 +543,14 @@
entry))
return True
+ if keys.get_entry_adjust() in key:
+ entry = self.view.item_in_focus()
+ if entry:
+ self.set_next_state(AdjustEntryState(self.projectlist_state,
+ self.controller, self.view,
+ entry))
+ return True
+
return False
@@ -774,6 +782,55 @@
self.controller.view.set_focus("entries")
self.view.frame.set_focus("footer")
+class AdjustEntryState(HandleUserInputState):
+
+ messages = {
+ 'adjust_entry': _('Adjust datetime of entry: '),
+ }
+
+ def __init__(self, state, controller, view, entry):
+ view.set_footer_text(self.msg('adjust_entry'),
+ 'question', True)
+ super(AdjustEntryState, self).__init__(controller, view,
+ None, view.footer)
+
+ # we only care up to seconds (which is 19 characters).
+ # for usability the default value has to match the strptime fmt below.
+ self.footer.set_edit_text(str(entry.start)[:19])
+ self.footer.set_edit_pos(len(self.footer.edit_text))
+ self.entry = entry
+ self.state = state
+ logger.debug("AdjustEntryState: Entry %s" % entry)
+
+ def enter(self):
+ entry_datetime = self.footer.get_edit_text() #
+
+ entry = self.entry
+ duration = entry.get_duration()
+
+ try:
+ entry.start = datetime.strptime(entry_datetime, "%Y-%m-%d %H:%M:%S")
+ except:
+ return self
+
+ entry.end = entry.start + duration
+
+ self.controller.update_entry(entry)
+ self.view.node_in_focus().update()
+ return self.exit()
+
+ def exit(self):
+ self.view.set_footer_text("", 'entry_footer', False)
+ self.set_next_state(DefaultEntryListState(self.state, self.controller,
+ self.view))
+ return True
+
+ def set_focus(self):
+ self.controller.view.set_focus("entries")
+ self.view.frame.set_focus("footer")
+
+
+
class ProjectEditKeyState(AlterProjectState):
More information about the Getan-commits
mailing list