Bug #932 (part 1)

- Fixed bug that caused only parent recurring tasks to have their attributes
  properly removed.
- When duplicating a parent recurring task, a new recurring parent task is
  created.  When a child recurring task is duplicated, a plain task is created.
- Added unit tests.
- Thanks to Jennifer Cormier.
This commit is contained in:
Paul Beckingham 2012-02-20 01:10:42 -05:00
parent 0a0e8f0d6b
commit 9f8165e3c6
4 changed files with 101 additions and 5 deletions

View file

@ -71,24 +71,34 @@ int CmdDuplicate::execute (std::string& output)
// Duplicate the specified task.
Task dup (*task);
dup.set ("uuid", uuid ()); // Needs a new UUID.
dup.setStatus (Task::pending); // Does not inherit status.
dup.remove ("start"); // Does not inherit start date.
dup.remove ("end"); // Does not inherit end date.
dup.remove ("entry"); // Does not inherit entry date.
// Recurring tasks are duplicated and downgraded to regular tasks.
// When duplicating a child task, downgrade it to a plain task.
if (dup.has ("parent"))
{
dup.remove ("parent");
dup.remove ("recur");
dup.remove ("until");
dup.remove ("mask");
dup.remove ("imask");
std::cout << format (STRING_CMD_DUPLICATE_NON_REC, task->id)
<< "\n";
}
// When duplicating a parent task, create a new parent task.
else if (dup.getStatus () == Task::recurring)
{
dup.remove ("mask");
std::cout << format (STRING_CMD_DUPLICATE_REC, task->id)
<< "\n";
}
dup.setStatus (Task::pending); // Does not inherit status.
// Must occur after Task::recurring check.
modify_task_annotate (dup, modifications);
if (permission (dup,