From 94cf6b8ac0185f498d1942e988ef2f43c50100df Mon Sep 17 00:00:00 2001 From: davidkim1 Date: Tue, 7 Nov 2023 16:18:43 -0500 Subject: [PATCH 1/4] added test for f_todo with uuid to be marked as finished --- tests/test_helpers.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_helpers.py b/tests/test_helpers.py index cdc4e69d9..959db200e 100644 --- a/tests/test_helpers.py +++ b/tests/test_helpers.py @@ -575,6 +575,9 @@ (["helper", "f_todo", "--index", "99100"], "WARNING: indices >= 9900 are used for milestones which should be finished using u_milestone and not f_todo\n" ), + (["helper", "f_todo", "--index", "1saefa"], + "The task \"(1saefa) test a_todo\" in test for sbillinge has been marked as finished.\n" + ), (["helper", "u_todo", "--index", "3", "--assigned-to", "sbillinge", "--description", "update the description", "--due-date", "2020-07-06", "--estimated-duration", "35", "--importance", "2", "--status", "finished", From c8d2542f3b9fa95f0edecfdac9f6a59cd1399856 Mon Sep 17 00:00:00 2001 From: davidkim1 Date: Tue, 7 Nov 2023 16:35:34 -0500 Subject: [PATCH 2/4] added a test in helper_map in for f_todo that passed a uuid without a flag --- tests/test_helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_helpers.py b/tests/test_helpers.py index 959db200e..37bb4a586 100644 --- a/tests/test_helpers.py +++ b/tests/test_helpers.py @@ -575,7 +575,7 @@ (["helper", "f_todo", "--index", "99100"], "WARNING: indices >= 9900 are used for milestones which should be finished using u_milestone and not f_todo\n" ), - (["helper", "f_todo", "--index", "1saefa"], + (["helper", "f_todo", "1saefa"], "The task \"(1saefa) test a_todo\" in test for sbillinge has been marked as finished.\n" ), (["helper", "u_todo", "--index", "3", "--assigned-to", "sbillinge", From 68a6347a76d43a5b57b0ff891255d39cd5a46ea1 Mon Sep 17 00:00:00 2001 From: davidkim1 Date: Tue, 14 Nov 2023 08:36:01 -0500 Subject: [PATCH 3/4] added tests for f_todo with uuid passed as index --- tests/test_helpers.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/test_helpers.py b/tests/test_helpers.py index 37bb4a586..9ef33ac7f 100644 --- a/tests/test_helpers.py +++ b/tests/test_helpers.py @@ -575,9 +575,12 @@ (["helper", "f_todo", "--index", "99100"], "WARNING: indices >= 9900 are used for milestones which should be finished using u_milestone and not f_todo\n" ), - (["helper", "f_todo", "1saefa"], + (["helper", "f_todo", "--index", "1saefa"], "The task \"(1saefa) test a_todo\" in test for sbillinge has been marked as finished.\n" ), + (["helper", "f_todo", "--index", "1saef"], + "Please enter either an index of todo or the first 6 characters of a todo\'s uuid..\n" + ), (["helper", "u_todo", "--index", "3", "--assigned-to", "sbillinge", "--description", "update the description", "--due-date", "2020-07-06", "--estimated-duration", "35", "--importance", "2", "--status", "finished", From 644a6719b155cd2217d1497cf08b3b4f3e42ee34 Mon Sep 17 00:00:00 2001 From: davidkim1 Date: Tue, 14 Nov 2023 11:57:44 -0500 Subject: [PATCH 4/4] added logic to f_todo helpers to finish todo based on uuid --- regolith/helpers/f_todohelper.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/regolith/helpers/f_todohelper.py b/regolith/helpers/f_todohelper.py index 397fd5f7d..97d129784 100644 --- a/regolith/helpers/f_todohelper.py +++ b/regolith/helpers/f_todohelper.py @@ -6,6 +6,7 @@ import dateutil.parser as date_parser import math +import re from regolith.helpers.basehelper import DbHelperBase from regolith.fsclient import _id_key @@ -30,7 +31,7 @@ def subparser(subpi): int_kwargs['widget'] = 'IntegerField' subpi.add_argument("-i", "--index", - help="Enter the index of a certain task in the enumerated list to mark as finished.", + help="Enter the index or the first 6 characters of a certain task in the enumerated list to mark as finished.", type=int) subpi.add_argument("--end-date", help="Add the end date of the task. Default is today.", @@ -72,11 +73,15 @@ def construct_global_ctx(self): def db_updater(self): rc = self.rc - if rc.index: - if rc.index >= 9900: - print("WARNING: indices >= 9900 are used for milestones which " - "should be finished using u_milestone and not f_todo") - return + # Check if rc.index is an integer and >= 9900 + if isinstance(rc.index, int) and rc.index >= 9900: + print("WARNING: indices >= 9900 are used for milestones which " + "should be finished using u_milestone and not f_todo") + return + # Check if rc.index is a string, less than 6 characters, and contains both letters and numbers + elif isinstance(rc.index, str) and len(rc.index) < 6 and re.search("[A-Za-z].*\d|\d.*[A-Za-z]", rc.index): + print("WARNING: String indices less than 6 characters containing both letters and numbers are not allowed") + return if not rc.assigned_to: try: rc.assigned_to = rc.default_user_id @@ -113,7 +118,10 @@ def db_updater(self): print("-" * 80) print_task(todolist, stati=['started']) else: - match_todo = [i for i in todolist if i.get("running_index") == rc.index] + if isinstance(rc.index, int): + match_todo = [i for i in todolist if i.get("running_index") == rc.index] + else: + match_todo = [i for i in todolist if i.get("uuid") == rc.index] if len(match_todo) == 0: raise RuntimeError("Please enter a valid index.") else: