From: Christian Heller Date: Thu, 8 Aug 2024 07:52:53 +0000 (+0200) Subject: Rename POST form key to field manipulated. X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/task?a=commitdiff_plain;h=c532d3b553e3881b241aa0885b14525224332c41;p=plomtask Rename POST form key to field manipulated. --- diff --git a/plomtask/http.py b/plomtask/http.py index 77438dc..c7897e8 100644 --- a/plomtask/http.py +++ b/plomtask/http.py @@ -631,10 +631,10 @@ class TaskHandler(BaseHTTPRequestHandler): step_fillers = self._form.get_all_str('step_filler') to_update: dict[str, Any] = { 'comment': self._form.get_str_or_fail('comment', '')} - for k1, k2 in [('is_done', 'done'), ('calendarize', 'calendarize')]: - v = self._form.get_bool_or_none(k2) + for k in ('is_done', 'calendarize'): + v = self._form.get_bool_or_none(k) if v is not None: - to_update[k1] = v + to_update[k] = v cond_rels = [self._form.get_all_int(name) for name in ['conditions', 'blockers', 'enables', 'disables']] effort_or_not = self._form.get_str('effort') diff --git a/templates/todo.html b/templates/todo.html index 732f788..20279bb 100644 --- a/templates/todo.html +++ b/templates/todo.html @@ -57,8 +57,8 @@ select{ font-size: 0.5em; margin: 0; padding: 0; } done - -{% if not todo.is_doable and todo.is_done %}{% endif %} + +{% if not todo.is_doable and todo.is_done %}{% endif %} diff --git a/tests/conditions.py b/tests/conditions.py index f6de4f8..3edafd6 100644 --- a/tests/conditions.py +++ b/tests/conditions.py @@ -134,7 +134,7 @@ class TestsWithServer(TestCaseWithServer): # test ignorance of meaningless non-empty params (incl. unknown key), # that 'sort_by' default to 'title' (even if set to something else, as # long as without handler) and 'pattern' get preserved - exp.set('pattern', 'bar') # preserved despite zero effect! + exp.set('pattern', 'bar') exp.set('sort_by', 'title') # for clarity (already default) self.check_json_get('/conditions?sort_by=foo&pattern=bar&foo=x', exp) # test non-empty result, automatic (positive) sorting by title diff --git a/tests/todos.py b/tests/todos.py index 07597ed..d84bb70 100644 --- a/tests/todos.py +++ b/tests/todos.py @@ -301,7 +301,7 @@ class TestsWithServer(TestCaseWithServer): self.check_post({}, '/todo?id=1') self.check_json_get('/todo?id=1', exp) # test posting doneness, comment, calendarization, effort - todo_post = {'done': 1, 'calendarize': 1, + todo_post = {'is_done': 1, 'calendarize': 1, 'comment': 'foo', 'effort': 2.3} self._post_exp_todo(1, todo_post, exp) self.check_json_get('/todo?id=1', exp) @@ -537,35 +537,35 @@ class TestsWithServer(TestCaseWithServer): # test Todo with adoptee can only be set done if adoptee is done too self.post_exp_day([], {'new_todo': [1]}) self.post_exp_day([], {'new_todo': [1]}) - self.check_post({'adopt': 2, 'done': 1}, '/todo?id=1', 400) - self.check_post({'done': 1}, '/todo?id=2') - self.check_post({'adopt': 2, 'done': 1}, '/todo?id=1', 302) + self.check_post({'adopt': 2, 'is_done': 1}, '/todo?id=1', 400) + self.check_post({'is_done': 1}, '/todo?id=2') + self.check_post({'adopt': 2, 'is_done': 1}, '/todo?id=1', 302) # test Todo cannot be set undone with adopted Todo not done yet - self.check_post({'done': 0}, '/todo?id=2') - self.check_post({'adopt': 2, 'done': 0}, '/todo?id=1', 400) + self.check_post({'is_done': 0}, '/todo?id=2') + self.check_post({'adopt': 2, 'is_done': 0}, '/todo?id=1', 400) # test unadoption relieves block - self.check_post({'done': 0}, '/todo?id=1', 302) + self.check_post({'is_done': 0}, '/todo?id=1', 302) # test Condition being set or unset can block doneness setting c1_post = {'title': '', 'description': '', 'is_active': 0} c2_post = {'title': '', 'description': '', 'is_active': 1} self.check_post(c1_post, '/condition', redir='/condition?id=1') self.check_post(c2_post, '/condition', redir='/condition?id=2') - self.check_post({'conditions': [1], 'done': 1}, '/todo?id=1', 400) - self.check_post({'done': 1}, '/todo?id=1', 302) - self.check_post({'done': 0}, '/todo?id=1', 302) - self.check_post({'blockers': [2], 'done': 1}, '/todo?id=1', 400) - self.check_post({'done': 1}, '/todo?id=1', 302) + self.check_post({'conditions': [1], 'is_done': 1}, '/todo?id=1', 400) + self.check_post({'is_done': 1}, '/todo?id=1', 302) + self.check_post({'is_done': 0}, '/todo?id=1', 302) + self.check_post({'blockers': [2], 'is_done': 1}, '/todo?id=1', 400) + self.check_post({'is_done': 1}, '/todo?id=1', 302) # test setting Todo doneness can set/un-set Conditions, but only on # doneness change, not by mere passive state - self.check_post({'done': 0}, '/todo?id=2', 302) - self.check_post({'enables': [1], 'done': 1}, '/todo?id=1') - self.check_post({'conditions': [1], 'done': 1}, '/todo?id=2', 400) - self.check_post({'enables': [1], 'done': 0}, '/todo?id=1') - self.check_post({'enables': [1], 'done': 1}, '/todo?id=1') - self.check_post({'conditions': [1], 'done': 1}, '/todo?id=2') - self.check_post({'blockers': [1], 'done': 0}, '/todo?id=2', 400) - self.check_post({'disables': [1], 'done': 1}, '/todo?id=1') - self.check_post({'blockers': [1], 'done': 0}, '/todo?id=2', 400) + self.check_post({'is_done': 0}, '/todo?id=2', 302) + self.check_post({'enables': [1], 'is_done': 1}, '/todo?id=1') + self.check_post({'conditions': [1], 'is_done': 1}, '/todo?id=2', 400) + self.check_post({'enables': [1], 'is_done': 0}, '/todo?id=1') + self.check_post({'enables': [1], 'is_done': 1}, '/todo?id=1') + self.check_post({'conditions': [1], 'is_done': 1}, '/todo?id=2') + self.check_post({'blockers': [1], 'is_done': 0}, '/todo?id=2', 400) + self.check_post({'disables': [1], 'is_done': 1}, '/todo?id=1') + self.check_post({'blockers': [1], 'is_done': 0}, '/todo?id=2', 400) self.check_post({'disables': [1]}, '/todo?id=1') - self.check_post({'disables': [1], 'done': 1}, '/todo?id=1') + self.check_post({'disables': [1], 'is_done': 1}, '/todo?id=1') self.check_post({'blockers': [1]}, '/todo?id=2') diff --git a/tests/utils.py b/tests/utils.py index acfabe7..1a306d1 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -757,8 +757,6 @@ class Expected: new_children = v if isinstance(v, list) else [v] corrected_kwargs['children'] += new_children continue - if 'done' == k: - k = 'is_done' if k in {'is_done', 'calendarize'}: v = v in VALID_TRUES corrected_kwargs[k] = v