Skip to content

Commit

Permalink
bugfixing a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
tobixen committed Apr 13, 2024
1 parent 956ee35 commit 1aea859
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
1 change: 1 addition & 0 deletions plann/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ def delete(ctx, multi_delete, **kwargs):
@click.option('--pdb/--no-pdb', default=None, help="Interactive edit through pdb (experts only)")
@click.option('--add-category', default=None, help="Add a category (equivalent with --set-category, while --set-categories will overwrite existing categories))", multiple=True)
@click.option('--postpone', help="Add something to the DTSTART and DTEND/DUE")
@click.option('--postpone-with-children', help="Add something to the DTSTART and DTEND/DUE for this and children")
@click.option('--interactive-ical/--no-interactive-ical', help="Edit the ical interactively")
@click.option('--interactive-relations/--no-interactive-relations', help="Edit the relationships")
@click.option('--interactive/--no-interactive', help="Interactive edit")
Expand Down
20 changes: 14 additions & 6 deletions plann/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def _interactive_edit(obj):
input = click.prompt("postpone <n>d / ignore / part(ially-complete) / complete / split / cancel / set foo=bar / edit / family / pdb?", default='ignore')
command_edit(obj, input, interactive=True)

def _edit(ctx, add_category=None, cancel=None, interactive_ical=False, interactive_relations=False, mass_interactive_default='ignore', mass_interactive=False, interactive=False, complete=None, complete_recurrence_mode='safe', postpone=None, interactive_reprioritize=False, **kwargs):
def _edit(ctx, add_category=None, cancel=None, interactive_ical=False, interactive_relations=False, mass_interactive_default='ignore', mass_interactive=False, interactive=False, complete=None, complete_recurrence_mode='safe', postpone=None, postpone_with_children=None, interactive_reprioritize=False, **kwargs):
"""
Edits a task/event/journal
"""
Expand All @@ -235,14 +235,23 @@ def _edit(ctx, add_category=None, cancel=None, interactive_ical=False, interacti
_process_set_args(ctx, kwargs, keep_category=True)
if interactive_ical:
_interactive_ical_edit(ctx.obj['objs'])
## TODO: should be possible to combine this with other opitions
return

if interactive_relations:
_interactive_relation_edit(ctx.obj['objs'])
## TODO: should be possible to combine this with other opitions
return

if mass_interactive:
_mass_interactive_edit(ctx.obj['objs'], default=mass_interactive_default)
## TODO: should be possible to combine this with other opitions
return

if interactive_reprioritize:
_mass_reprioritize(ctx.obj['objs'])
## TODO: should be possible to combine this with other opitions
return

for obj in ctx.obj['objs']:
if interactive:
Expand All @@ -266,11 +275,10 @@ def _edit(ctx, add_category=None, cancel=None, interactive_ical=False, interacti
comp.status='CANCELLED'
elif cancel is False:
comp.status='NEEDS-ACTION'
if postpone:
## TODO: why do we have a completely different code here compared to in the interactive edit?
for attrib in ('DTSTART', 'DTEND', 'DUE'):
if comp.get(attrib):
comp[attrib].dt = parse_add_dur(comp[attrib].dt, postpone, for_storage=True)
if postpone or postpone_with_children:
_procrastinate([obj], postpone or postpone_with_children, with_children=postpone_with_children and True)

## OPTIMIZE TODO: only save objects that actually have been edited
obj.save()

def _check_for_panic(ctx, hours_per_day, output=True, print_timeline=True, fix_timeline=False, interactive_fix_timeline=False, timeline_start=None, timeline_end=None, include_all_events=False):
Expand Down
2 changes: 1 addition & 1 deletion plann/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def _get_obj_from_line(line, calendar):
return obj

def _command_line_edit(line, calendar, interactive=True):
regexp = re.compile("((?:set [^ ]*=[^ ]*)|(?:postpone [0-9]+[smhdwy])|[^ ]*) (.*)$")
regexp = re.compile("((?:set [^ ]*=[^ ]*)|(?:postpone (?:[0-9]+[smhdwy]|20[0-9][0-9]-[0-9][0-9]-[0-9][0-9]))|[^ ]*) (.*)$")
line = _strip_line(line)
if not line:
return
Expand Down
2 changes: 1 addition & 1 deletion plann/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def _procrastinate(objs, delay, check_dependent="error", with_children=False, wi
new_due = parse_add_dur(new_due, delay, ts_allowed=True, for_storage=True)
## Let's force the due to be a timestamp
if not isinstance(new_due, datetime.datetime):
new_due = datetime.datetime(ts.year, ts.month, ts.day)
new_due = datetime.datetime(new_due.year, new_due.month, new_due.day)
parent = x.set_due(new_due, move_dtstart=True, check_dependent=chk_parent)
if parent:
if check_dependent in ("error", "interactive"):
Expand Down

0 comments on commit 1aea859

Please sign in to comment.