def run(self): super(DueQuery, self).run() self._filters.append(OR(Task.q.status == "new", Task.q.status == "started")) self._filters.append(Task.q.dueDate != None) tasks = Task.select(AND(*self._filters)) lst = [] for task in tasks: item = Item(task) item.grp1 = task.dueDate.date() item.grp2 = task.project.name lst.append(item) fmt1 = formatDate return dict(lst=lst, fmt1=fmt1)
def run(self): super(ProjectQuery, self).run() self._filters.append(OR(Task.q.status == "new", Task.q.status == "started")) tasks = Task.select(AND(*self._filters)) lst = [] for task in tasks: item = Item(task) item.grp1 = task.project.name item.grp2 = "" lst.append(item) # Show notes at the end lst.sort(key=attrgetter("isNote")) fmt1 = lambda x: x return dict(lst=lst, fmt1=fmt1)
def run(self): super(DoneQuery, self).run() self._filters.append(Task.q.status == "done") if self.minDate is not None: self._filters.append(Task.q.doneDate >= self.minDate) if self.maxDate is not None: self._filters.append(Task.q.doneDate < self.maxDate) if self.minDate is None and self.maxDate is None: self._filters.append(Task.q.doneDate != None) tasks = Task.select(AND(*self._filters)) lst = [] for task in tasks: item = Item(task) item.grp1 = task.doneDate.date() item.grp2 = task.project.name lst.append(item) fmt1 = formatDate return dict(lst=lst, fmt1=fmt1)
def setTaskStatus(self, taskId, status): task = Task.get(taskId) status = unicode(status) task.status = status if status == "done": task.doneDate = datetime.now()
def removeTask(self, taskId): Task.delete(taskId) self.updateViewAndKeepPosition()
def editTask(self, taskId): task = Task.get(taskId) dlg = AddTaskDialog(task, self) if dlg.exec_() == QDialog.Accepted: self.updateViewAndKeepPosition()
def updateView(self): filters = [] queryType = self.ui.queryListWidget.currentRow() # Project wantedProject = self.ui.projectLineEdit.text() if not wantedProject.isEmpty(): filters.append( IN( Task.q.project, Select(Project.q.id, LIKE(Project.q.name, "%" + unicode(wantedProject) + "%")) )) # Status statusFilters = [] if queryType == QUERY_DONE: minDate = datetimeFromQDate(self.ui.fromDateEdit.date()) maxDate = datetimeFromQDate(self.ui.toDateEdit.date()) if maxDate < minDate: minDate, maxDate = maxDate, minDate maxDate += timedelta(1) doneFilter = AND( \ Task.q.status == "done", \ Task.q.doneDate >= minDate, \ Task.q.doneDate < maxDate \ ) statusFilters.append(doneFilter) else: statusFilters.append(Task.q.status == "new") statusFilters.append(Task.q.status == "started") filters.append(OR(*statusFilters)) # Due date if queryType == QUERY_DUE: dueDate = datetimeFromQDate(self.ui.dueDateEdit.date()) + timedelta(1) filters.append(Task.q.dueDate < dueDate) tasks = Task.select(AND(*filters)) lst = [] class Item(object): __slots__ = ["task", "grp1", "grp2"] for task in tasks: item = Item() item.task = task if queryType == QUERY_DUE: item.grp1 = task.dueDate.date() item.grp2 = task.project.name elif queryType == QUERY_PROJECT: item.grp1 = task.project.name item.grp2 = "" elif queryType == QUERY_DONE: item.grp1 = task.doneDate.date() item.grp2 = task.project.name else: raise Exception() lst.append(item) if queryType == QUERY_DUE: fmt1 = formatDate elif queryType == QUERY_PROJECT: fmt1 = lambda x: x elif queryType == QUERY_DONE: fmt1 = formatDate else: raise Exception() tmpl = self.jinjaEnv.get_template("index.html") html = tmpl.render(lst=lst, fmt1=fmt1) baseUrl = QUrl.fromLocalFile(os.path.join(self.dataDir, "static/")) self.ui.webView.setHtml(html, baseUrl) self.ui.webView.page().mainFrame().addToJavaScriptWindowObject("qtWindow", self)