home
·
contact
·
privacy
projects
/
plomtask
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Create choice for creating Todos with or without children.
[plomtask]
/
plomtask
/
http.py
diff --git
a/plomtask/http.py
b/plomtask/http.py
index 0aa692545d3e5ae38f4be7190a697df40259dcb0..e9e23633a92ddd5b02d9402dfaefae357476b125 100644
(file)
--- a/
plomtask/http.py
+++ b/
plomtask/http.py
@@
-155,6
+155,7
@@
class TaskHandler(BaseHTTPRequestHandler):
def do_GET_day(self) -> dict[str, object]:
"""Show single Day of ?date=."""
date = self.params.get_str('date', date_in_n_days(0))
def do_GET_day(self) -> dict[str, object]:
"""Show single Day of ?date=."""
date = self.params.get_str('date', date_in_n_days(0))
+ make_type = self.params.get_str('make_type')
todays_todos = Todo.by_date(self.conn, date)
total_effort = 0.0
for todo in todays_todos:
todays_todos = Todo.by_date(self.conn, date)
total_effort = 0.0
for todo in todays_todos:
@@
-178,6
+179,7
@@
class TaskHandler(BaseHTTPRequestHandler):
return {'day': Day.by_id(self.conn, date, create=True),
'total_effort': total_effort,
'top_nodes': top_nodes,
return {'day': Day.by_id(self.conn, date, create=True),
'total_effort': total_effort,
'top_nodes': top_nodes,
+ 'make_type': make_type,
'enablers_for': enablers_for,
'disablers_for': disablers_for,
'conditions_present': conditions_present,
'enablers_for': enablers_for,
'disablers_for': disablers_for,
'conditions_present': conditions_present,
@@
-411,8
+413,14
@@
class TaskHandler(BaseHTTPRequestHandler):
day = Day.by_id(self.conn, date, create=True)
day.comment = self.form_data.get_str('day_comment')
day.save(self.conn)
day = Day.by_id(self.conn, date, create=True)
day.comment = self.form_data.get_str('day_comment')
day.save(self.conn)
+ make_type = self.form_data.get_str('make_type')
for process_id in sorted(self.form_data.get_all_int('new_todo')):
for process_id in sorted(self.form_data.get_all_int('new_todo')):
- Todo.create_with_children(self.conn, process_id, date)
+ if 'empty' == make_type:
+ process = Process.by_id(self.conn, process_id)
+ todo = Todo(None, process, False, date)
+ todo.save(self.conn)
+ else:
+ Todo.create_with_children(self.conn, process_id, date)
done_ids = self.form_data.get_all_int('done')
comments = self.form_data.get_all_str('comment')
efforts = self.form_data.get_all_str('effort')
done_ids = self.form_data.get_all_int('done')
comments = self.form_data.get_all_str('comment')
efforts = self.form_data.get_all_str('effort')
@@
-428,10
+436,12
@@
class TaskHandler(BaseHTTPRequestHandler):
condition.save(self.conn)
for condition in todo.disables:
condition.save(self.conn)
condition.save(self.conn)
for condition in todo.disables:
condition.save(self.conn)
- return f'/day?date={date}'
+ return f'/day?date={date}
&make_type={make_type}
'
def do_POST_todo(self) -> str:
"""Update Todo and its children."""
def do_POST_todo(self) -> str:
"""Update Todo and its children."""
+ # pylint: disable=too-many-locals
+ # pylint: disable=too-many-branches
id_ = self.params.get_int('id')
for _ in self.form_data.get_all_str('delete'):
todo = Todo .by_id(self.conn, id_)
id_ = self.params.get_int('id')
for _ in self.form_data.get_all_str('delete'):
todo = Todo .by_id(self.conn, id_)
@@
-439,11
+449,14
@@
class TaskHandler(BaseHTTPRequestHandler):
return '/'
todo = Todo.by_id(self.conn, id_)
adopted_child_ids = self.form_data.get_all_int('adopt')
return '/'
todo = Todo.by_id(self.conn, id_)
adopted_child_ids = self.form_data.get_all_int('adopt')
- processes_to_make = self.form_data.get_all_int('make')
+ processes_to_make_full = self.form_data.get_all_int('make_full')
+ processes_to_make_empty = self.form_data.get_all_int('make_empty')
fill_fors = self.form_data.get_first_strings_starting('fill_for_')
for v in fill_fors.values():
fill_fors = self.form_data.get_first_strings_starting('fill_for_')
for v in fill_fors.values():
- if v.startswith('make_'):
- processes_to_make += [int(v[5:])]
+ if v.startswith('make_empty_'):
+ processes_to_make_empty += [int(v[11:])]
+ elif v.startswith('make_full_'):
+ processes_to_make_full += [int(v[10:])]
elif v != 'ignore':
adopted_child_ids += [int(v)]
to_remove = []
elif v != 'ignore':
adopted_child_ids += [int(v)]
to_remove = []
@@
-459,7
+472,12
@@
class TaskHandler(BaseHTTPRequestHandler):
continue
child = Todo.by_id(self.conn, child_id)
todo.add_child(child)
continue
child = Todo.by_id(self.conn, child_id)
todo.add_child(child)
- for process_id in processes_to_make:
+ for process_id in processes_to_make_empty:
+ process = Process.by_id(self.conn, process_id)
+ made = Todo(None, process, False, todo.date)
+ made.save(self.conn)
+ todo.add_child(made)
+ for process_id in processes_to_make_full:
made = Todo.create_with_children(self.conn, process_id, todo.date)
todo.add_child(made)
effort = self.form_data.get_str('effort', ignore_strict=True)
made = Todo.create_with_children(self.conn, process_id, todo.date)
todo.add_child(made)
effort = self.form_data.get_str('effort', ignore_strict=True)