def set_date(self, date, date_kind): self.__date_kind = date_kind if date_kind in (GTGCalendar.DATE_KIND_DUE): self.__fuzzydate_btns.show() else: self.__fuzzydate_btns.hide() if not date: # we set the widget to today's date if there is not a #date defined date = dates.date_today() self.__date = date if isinstance(date, dates.RealDate): self.__calendar.select_day(date.day()) cal_date = self.__from_datetime_to_calendar(date.to_py_date()) self.__calendar.select_month(cal_date.month, cal_date.year)
def is_started(self,task,parameters=None): '''Filter for tasks that are already started''' start_date = task.get_start_date() if start_date : #Seems like pylint falsely assumes that subtraction always results #in an object of the same type. The subtraction of dates #results in a datetime.timedelta object #that does have a 'days' member. difference = date_today() - start_date if difference.days == 0: # Don't count today's tasks started until morning return datetime.now().hour > 4 else: return difference.days > 0 #pylint: disable-msg=E1101 else: return True
def set_status(self, status, donedate=None): old_status = self.status self.can_be_deleted = False if status: #we first modify the status of the children #If Done, we set the done date if status in [self.STA_DONE, self.STA_DISMISSED]: for c in self.get_subtasks(): if c.get_status() in [self.STA_ACTIVE]: c.set_status(status, donedate=donedate) #to the specified date (if any) if donedate: self.closed_date = donedate #or to today else: self.closed_date = date_today() #If we mark a task as Active and that some parent are not #Active, we break the parent/child relation #It has no sense to have an active subtask of a done parent. # (old_status check is necessary to avoid false positive a start) elif status in [self.STA_ACTIVE] and\ old_status in [self.STA_DONE, self.STA_DISMISSED]: if self.has_parents(): for p_tid in self.get_parents(): par = self.req.get_task(p_tid) if par.is_loaded() and par.get_status() in\ [self.STA_DONE, self.STA_DISMISSED]: #we can either break the parent/child relationship #self.remove_parent(p_tid) #or restore the parent too par.set_status(self.STA_ACTIVE) #We dont mark the children as Active because #They might be already completed after all #then the task itself self.status = status self.sync()