Skip to content

Commit

Permalink
calculate_new_due_date() added.
Browse files Browse the repository at this point in the history
  • Loading branch information
sagarghuge committed Jun 12, 2014
1 parent 7cf96af commit c488b13
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions GTG/core/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"""
task.py contains the Task class which represents (guess what) a task
"""
from datetime import datetime
from datetime import datetime, timedelta
import cgi
import re
import uuid
Expand Down Expand Up @@ -277,13 +277,17 @@ def set_complex_title(self, text, tags=[]):
def validate_task(self):
now = datetime.now()
current_date = Date.parse(now.strftime("%Y-%m-%d"))
print(current_date)
print(type(current_date))
print(self.due_date)
print(type(self.due_date))
if self.due_date.__le__(current_date):
self.activate_create_instance()

def calculate_new_due_date(self):
if self.repeats == "Daily":
if int(self.frequency) == 0 or int(self.frequency) == 1:
return self.get_due_date().__add__(1)
else:
return self.get_due_date() + \
timedelta(days=int(self.frequency))

#TODO refactor this method and create copy and create task new method
def create_recurring_instance(self, is_subtask, parent=None):
if is_subtask:
Expand All @@ -300,7 +304,8 @@ def create_recurring_instance(self, is_subtask, parent=None):
task.set_text(self.get_text())
task.set_start_date(self.get_start_date())
#TODO calculate new due date depending on the recurrence details.
task.set_due_date(self.get_due_date())
new_duedate = self.calculate_new_due_date()
task.set_due_date(new_duedate)
task.set_endon_date(self.get_endon_date())

#fire all recrrence methods
Expand Down

0 comments on commit c488b13

Please sign in to comment.