Feature #457
- Tasks may now be given an 'until' date, after which they expire and are deleted.
This commit is contained in:
@@ -1154,10 +1154,6 @@ void Task::validate ()
|
||||
if (! has ("due") && has ("recur"))
|
||||
throw std::string (STRING_TASK_VALID_REC_DUE);
|
||||
|
||||
// Cannot have an until date no recurrence frequency.
|
||||
if (has ("until") && !has ("recur"))
|
||||
throw std::string (STRING_TASK_VALID_UNTIL);
|
||||
|
||||
// Recur durations must be valid.
|
||||
if (has ("recur"))
|
||||
{
|
||||
|
||||
@@ -203,7 +203,7 @@ int CmdInfo::execute (std::string& output)
|
||||
if (task->has ("until"))
|
||||
{
|
||||
row = view.addRow ();
|
||||
view.set (row, 0, STRING_CMD_INFO_RECUR_UNTIL);
|
||||
view.set (row, 0, STRING_CMD_INFO_UNTIL);
|
||||
view.set (row, 1, Date (task->get_date ("until")).toString (dateformat));
|
||||
}
|
||||
|
||||
|
||||
@@ -225,7 +225,7 @@
|
||||
#define STRING_CMD_INFO_USAGE "Shows all data and metadata"
|
||||
#define STRING_CMD_INFO_BLOCKED "This task blocked by"
|
||||
#define STRING_CMD_INFO_BLOCKING "This task is blocking"
|
||||
#define STRING_CMD_INFO_RECUR_UNTIL "Recur until"
|
||||
#define STRING_CMD_INFO_UNTIL "Until"
|
||||
#define STRING_CMD_INFO_MODIFICATION "Modification"
|
||||
#define STRING_CMD_INFO_TOTAL_ACTIVE "Total active time"
|
||||
#define STRING_CMD_UNDO_USAGE "Reverts the most recent change to a task"
|
||||
@@ -698,6 +698,7 @@
|
||||
#define STRING_FEEDBACK_TAG_NOCAL "The 'nocal' special tag will keep this task off the calendar report."
|
||||
#define STRING_FEEDBACK_TAG_NEXT "The 'next' special tag will boost the urgency of this task so it appears on the 'next' report."
|
||||
#define STRING_FEEDBACK_UNBLOCKED "Unblocked {1} '{2}'."
|
||||
#define STRING_FEEDBACK_EXPIRED "Task {1} '{2}' expired and was deleted."
|
||||
|
||||
// File
|
||||
#define STRING_FILE_PERMS "Task does not have the correct permissions for '{1}'."
|
||||
@@ -732,9 +733,6 @@
|
||||
#define STRING_RECORD_JUNK_AT_EOL "Unrecognized characters at end of line."
|
||||
#define STRING_RECORD_NOT_FF4 "Record not recognized as format 4."
|
||||
|
||||
// recur
|
||||
#define STRING_RECUR_PAST_UNTIL "Task ({1}) has past its 'until' date, and has been deleted."
|
||||
|
||||
// 'show' command
|
||||
#define STRING_CMD_SHOW "Shows all configuration variables or subset"
|
||||
#define STRING_CMD_SHOW_ARGS "You can only specify 'all' or a search string."
|
||||
|
||||
@@ -468,6 +468,18 @@ std::string onProjectChange (Task& task1, Task& task2)
|
||||
return messages;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
std::string onExpiration (Task& task)
|
||||
{
|
||||
std::stringstream msg;
|
||||
|
||||
if (context.verbose ("affected"))
|
||||
msg << format (STRING_FEEDBACK_EXPIRED, task.id, task.get ("description"))
|
||||
<< "\n";
|
||||
|
||||
return msg.str ();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
static void countTasks (
|
||||
const std::vector <Task>& all,
|
||||
|
||||
@@ -79,6 +79,7 @@ void feedback_special_tags (const Task&, const std::string&);
|
||||
void feedback_unblocked (const Task&);
|
||||
std::string onProjectChange (Task&, bool scope = true);
|
||||
std::string onProjectChange (Task&, Task&);
|
||||
std::string onExpiration (Task&);
|
||||
|
||||
// sort.cpp
|
||||
void sort_tasks (std::vector <Task>&, std::vector <int>&, const std::string&);
|
||||
|
||||
@@ -56,6 +56,7 @@ extern Context context;
|
||||
void handleRecurrence ()
|
||||
{
|
||||
std::vector <Task> tasks = context.tdb2.pending.get_tasks ();
|
||||
Date now;
|
||||
|
||||
// Look at all tasks and find any recurring ones.
|
||||
std::vector <Task>::iterator t;
|
||||
@@ -68,12 +69,10 @@ void handleRecurrence ()
|
||||
std::vector <Date> due;
|
||||
if (!generateDueDates (*t, due))
|
||||
{
|
||||
std::cout << format (STRING_RECUR_PAST_UNTIL, trim (t->get ("description")))
|
||||
<< "\n";
|
||||
|
||||
// Determine the end date.
|
||||
t->setStatus (Task::deleted);
|
||||
context.tdb2.modify (*t);
|
||||
context.footnote (onExpiration (*t));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -137,6 +136,18 @@ void handleRecurrence ()
|
||||
context.tdb2.modify (*t);
|
||||
}
|
||||
}
|
||||
|
||||
// Non-recurring tasks expire too.
|
||||
else
|
||||
{
|
||||
if (t->has ("until") &&
|
||||
Date (t->get_date ("until")) < now)
|
||||
{
|
||||
t->setStatus (Task::deleted);
|
||||
context.tdb2.modify(*t);
|
||||
context.footnote (onExpiration (*t));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user