def tasks_change_remind(self, tasks_uuid): """ Show dialog and change given tasks start date. Args: tasks_uuid: task to change Returns: True if date was changed. """ task = OBJ.Task.get(self._session, uuid=tasks_uuid[0]) alarm = None if task.alarm: alarm = DTU.datetime2timestamp(task.alarm) dlg = DlgRemindSettings(self._parent_wnd, alarm, task.alarm_pattern) if not dlg.run(True): return False if dlg.alarm: alarm = DTU.timestamp2datetime(dlg.alarm) alarm_pattern = None else: alarm = None alarm_pattern = dlg.alarm_pattern task.alarm = alarm task.alarm_pattern = alarm_pattern task_logic.update_task_alarm(task) tasks_to_save = [task] for task_uuid in tasks_uuid[1:]: task = OBJ.Task.get(self._session, uuid=task_uuid) task.alarm = alarm task.alarm_pattern = alarm_pattern task_logic.update_task_alarm(task) tasks_to_save.append(task) return task_logic.save_modified_tasks(tasks_to_save, self._session)
def tasks_set_completed_status(self, tasks_uuid, compl): if compl: if not mbox.message_box_question(self.wnd, _("Set tasks completed?"), None, _("Set complete"), _("Close")): return False else: if not mbox.message_box_question(self.wnd, _("Set tasks not completed?"), None, _("Set complete"), _("Close")): return False tasks_to_save = [] for task_uuid in tasks_uuid: task = OBJ.Task.get(self._session, uuid=task_uuid) if not task: _LOG.warn("tasks_set_completed_status: task %r not found", task_uuid) continue if task.task_completed != compl: if compl: task_logic.complete_task(task, self._session) else: task.task_completed = False tasks_to_save.append(task) if tasks_to_save: return task_logic.save_modified_tasks(tasks_to_save, self._session) return False
def tasks_change_hide_until(self, tasks_uuid): """ Show dialog and change given tasks show settings. Args: tasks_uuid: task to change Returns: True if date was changed. """ task = OBJ.Task.get(self._session, uuid=tasks_uuid[0]) date_time = None if task.hide_until: date_time = DTU.datetime2timestamp(task.hide_until) dlg = DlgShowSettings(self._parent_wnd, date_time, task.hide_pattern) if not dlg.run(True): return hide_until = None hide_pattern = dlg.pattern if dlg.datetime: hide_until = DTU.timestamp2datetime(dlg.datetime) tasks_to_save = [] for task_uuid in tasks_uuid: task = OBJ.Task.get(self._session, uuid=task_uuid) task.hide_until = hide_until task.hide_pattern = hide_pattern task_logic.update_task_hide(task) tasks_to_save.append(task) return task_logic.save_modified_tasks(tasks_to_save, self._session)
def tasks_change_due_date(self, tasks_uuid): """ Change due date for given tasks. """ task1 = OBJ.Task.get(self._session, uuid=tasks_uuid[0]) task1_due_attr = 'due_date' if task1.type == enums.TYPE_PROJECT: task1_due_attr = 'due_date_project', if self._set_date(task1, task1_due_attr, 'due_time_set'): tasks_to_save = [task1] due = (task1.due_date_project if task1.type == enums.TYPE_PROJECT else task1.due_date) for task_uuid in tasks_uuid[1:]: task = OBJ.Task.get(self._session, uuid=task_uuid) if task.type == enums.TYPE_PROJECT: if (task.start_time_set != task1.start_time_set or task.due_date_project != due): task.due_date_project = due task.due_time_set = task1.due_time_set tasks_to_save.append(task) else: if (task.start_time_set != task1.start_time_set or task.due_date != due): task.due_date = due task.due_time_set = task1.due_time_set tasks_to_save.append(task) return task_logic.save_modified_tasks(tasks_to_save, self._session) return False
def tasks_change_folder(self, tasks_uuid): """ Change folder in given tasks; display window with defined folders to select. Args: tasks_uuid: list of tasks uuid to change Returns: True when success. """ values, choices = [None], [_("No Folder")] for folder in OBJ.Folder.all(session=self._session): values.append(folder.uuid) choices.append(folder.title) dlg = wx.SingleChoiceDialog(self.wnd, _("Change tasks folder to:"), _("Tasks"), choices, wx.CHOICEDLG_STYLE) folder = -1 if dlg.ShowModal() == wx.ID_OK: folder = values[dlg.GetSelection()] dlg.Destroy() if folder == -1: return False tasks_to_save = [] for task_uuid in tasks_uuid: task = OBJ.Task.get(self._session, uuid=task_uuid) if not task: _LOG.warn("tasks_change_status: task %r not found", task_uuid) continue if task.folder_uuid != folder: task.folder_uuid = folder tasks_to_save.append(task) if tasks_to_save: return task_logic.save_modified_tasks(tasks_to_save, self._session) return False
def tasks_change_project(self, tasks_uuid): """ Move tasks to project/checklist; display window with defined projects to select. Args: tasks_uuid: list of tasks uuid to change Returns: True when success. """ dlg = DlgProjectTree(self.wnd) if not dlg.run(modal=True): return False parent_uuid = dlg.selected tasks_to_save = [] for task_uuid in tasks_uuid: task = OBJ.Task.get(self._session, uuid=task_uuid) if not task: _LOG.warn("tasks_change_status: task %r not found", task_uuid) continue if task.parent_uuid != parent_uuid: if task_logic.change_task_parent(task, parent_uuid, self._session): tasks_to_save.append(task) if tasks_to_save: return task_logic.save_modified_tasks(tasks_to_save, self._session) return False
def tasks_change_status(self, tasks_uuid): """ Change status in given tasks; display window with statuses Args: tasks_uuid: list of tasks uuid to change Returns: True when success. """ values = sorted(enums.STATUSES.keys()) choices = [enums.STATUSES[val] for val in values] dlg = wx.SingleChoiceDialog(self.wnd, _("Change tasks status to:"), _("Tasks"), choices, wx.CHOICEDLG_STYLE) new_status = None if dlg.ShowModal() == wx.ID_OK: new_status = values[dlg.GetSelection()] dlg.Destroy() if new_status is None: return False tasks_to_save = [] for task_uuid in tasks_uuid: task = OBJ.Task.get(self._session, uuid=task_uuid) if not task: _LOG.warn("tasks_change_status: task %r not found", task_uuid) continue if task.status == new_status: continue task.status = new_status tasks_to_save.append(task) if tasks_to_save: return task_logic.save_modified_tasks(tasks_to_save, self._session) return False
def tasks_set_starred_flag(self, tasks_uuid, starred): """ Set starred flag for given tasks. """ tasks_to_save = [] for task_uuid in tasks_uuid: task = OBJ.Task.get(self._session, uuid=task_uuid) if not task: _LOG.warn("tasks_set_completed_status: task %r not found", task_uuid) continue task.starred = bool(starred) tasks_to_save.append(task) if tasks_to_save: return task_logic.save_modified_tasks(tasks_to_save, self._session) return False
def tasks_change_start_date(self, tasks_uuid): """ Change start date for given tasks. """ task1 = OBJ.Task.get(self._session, uuid=tasks_uuid[0]) if self._set_date(task1, 'start_date', 'start_time_set'): tasks_to_save = [task1] for task_uuid in tasks_uuid[1:]: task = OBJ.Task.get(self._session, uuid=task_uuid) if (task.start_date != task1.start_date or task.start_time_set != task1.start_time_set): task.start_date = task1.start_date task.start_time_set = task1.start_time_set tasks_to_save.append(task) return task_logic.save_modified_tasks(tasks_to_save, self._session) return False
def tasks_change_priority(self, tasks_uuid): """ Show dialog and change given tasks priority. Args: tasks_uuid: task to change Returns: True if date was changed. """ values = (-1, 0, 1, 2, 3) choices = [enums.PRIORITIES[val] for val in values] dlg = wx.SingleChoiceDialog(self.wnd, _("Change task priority to:"), _("Task"), choices, wx.CHOICEDLG_STYLE) new_priority = None if dlg.ShowModal() == wx.ID_OK: new_priority = values[dlg.GetSelection()] dlg.Destroy() tasks_to_save = [] for task_uuid in tasks_uuid: task = OBJ.Task.get(self._session, uuid=task_uuid) if new_priority == task: continue task.priority = new_priority tasks_to_save.append(task) return task_logic.save_modified_tasks(tasks_to_save, self._session)