def taskNode(self, task): node = self.baseCompositeNode(task, 'task', self.taskNode) node.setAttribute('status', str(task.getStatus())) if task.startDate() != date.Date(): node.setAttribute('startdate', str(task.startDate())) if task.dueDate() != date.Date(): node.setAttribute('duedate', str(task.dueDate())) if task.completionDate() != date.Date(): node.setAttribute('completiondate', str(task.completionDate())) if task.recurrence(): node.appendChild(self.recurrenceNode(task.recurrence())) if task.budget() != date.TimeDelta(): node.setAttribute('budget', self.budgetAsAttribute(task.budget())) if task.priority() != 0: node.setAttribute('priority', str(task.priority())) if task.hourlyFee() != 0: node.setAttribute('hourlyFee', str(task.hourlyFee())) if task.fixedFee() != 0: node.setAttribute('fixedFee', str(task.fixedFee())) if task.reminder() != None: node.setAttribute('reminder', str(task.reminder())) if task.shouldMarkCompletedWhenAllChildrenCompleted != None: node.setAttribute('shouldMarkCompletedWhenAllChildrenCompleted', str(task.shouldMarkCompletedWhenAllChildrenCompleted)) for effort in task.efforts(): node.appendChild(self.effortNode(effort)) for note in task.notes(): node.appendChild(self.noteNode(note)) for attachment in task.attachments(): node.appendChild(self.attachmentNode(attachment)) return node
def __init__(self, parent, task, *args, **kwargs): super(BudgetPage, self).__init__(parent, task, *args, **kwargs) # Boxes: budgetBox = widgets.BoxWithFlexGridSizer(self, label=_('Budget'), cols=3) revenueBox = widgets.BoxWithFlexGridSizer(self, label=_('Revenue'), cols=3) # Editable entries: self._budgetEntry = TimeDeltaEntry(budgetBox, task.budget()) self._hourlyFeeEntry = AmountEntry(revenueBox, task.hourlyFee()) self._fixedFeeEntry = AmountEntry(revenueBox, task.fixedFee()) # Readonly entries: if task.children(): recursiveBudget = render.budget(task.budget(recursive=True)) recursiveTimeSpent = render.timeSpent(task.timeSpent(recursive=True)) recursiveBudgetLeft = render.budget(task.budgetLeft(recursive=True)) recursiveFixedFee = render.amount(task.fixedFee(recursive=True)) recursiveRevenue = render.amount(task.revenue(recursive=True)) else: recursiveBudget = recursiveTimeSpent = recursiveBudgetLeft = \ recursiveFixedFee = recursiveRevenue = '' # Fill the boxes: self.addHeaders(budgetBox) for entry in [_('Budget'), self._budgetEntry, recursiveBudget, _('Time spent'), render.budget(task.timeSpent()), recursiveTimeSpent, _('Budget left'), render.budget(task.budgetLeft()), recursiveBudgetLeft]: budgetBox.add(entry, flag=wx.ALIGN_RIGHT) self.addHeaders(revenueBox) for entry in [_('Hourly fee'), self._hourlyFeeEntry, '', _('Fixed fee'), self._fixedFeeEntry, recursiveFixedFee, _('Revenue'), render.amount(task.revenue()), recursiveRevenue]: revenueBox.add(entry, flag=wx.ALIGN_RIGHT) for box in budgetBox, revenueBox: box.fit() self.add(box, proportion=0, flag=wx.EXPAND|wx.ALL, border=5) self.fit()
def taskNode(self, parentNode, task): # pylint: disable=W0621 maxDateTime = self.maxDateTime node = self.baseCompositeNode(parentNode, task, 'task', self.taskNode) node.attrib['status'] = str(task.getStatus()) if task.plannedStartDateTime() != maxDateTime: node.attrib['plannedstartdate'] = str(task.plannedStartDateTime()) if task.dueDateTime() != maxDateTime: node.attrib['duedate'] = str(task.dueDateTime()) if task.actualStartDateTime() != maxDateTime: node.attrib['actualstartdate'] = str(task.actualStartDateTime()) if task.completionDateTime() != maxDateTime: node.attrib['completiondate'] = str(task.completionDateTime()) if task.percentageComplete(): node.attrib['percentageComplete'] = str(task.percentageComplete()) if task.recurrence(): self.recurrenceNode(node, task.recurrence()) if task.budget() != date.TimeDelta(): node.attrib['budget'] = self.budgetAsAttribute(task.budget()) if task.priority(): node.attrib['priority'] = str(task.priority()) if task.hourlyFee(): node.attrib['hourlyFee'] = str(task.hourlyFee()) if task.fixedFee(): node.attrib['fixedFee'] = str(task.fixedFee()) reminder = task.reminder() if reminder != maxDateTime and reminder != None: node.attrib['reminder'] = str(reminder) reminderBeforeSnooze = task.reminder(includeSnooze=False) if reminderBeforeSnooze != None and reminderBeforeSnooze < task.reminder(): node.attrib['reminderBeforeSnooze'] = str(reminderBeforeSnooze) prerequisiteIds = ' '.join([prerequisite.id() for prerequisite in \ sortedById(task.prerequisites())]) if prerequisiteIds: node.attrib['prerequisites'] = prerequisiteIds if task.shouldMarkCompletedWhenAllChildrenCompleted() != None: node.attrib['shouldMarkCompletedWhenAllChildrenCompleted'] = \ str(task.shouldMarkCompletedWhenAllChildrenCompleted()) for effort in sortedById(task.efforts()): self.effortNode(node, effort) for eachNote in sortedById(task.notes()): self.noteNode(node, eachNote) for attachment in sortedById(task.attachments()): self.attachmentNode(node, attachment) return node
def taskNode(self, task): # pylint: disable-msg=W0621 maxDateTime = self.maxDateTime node = self.baseCompositeNode(task, 'task', self.taskNode) node.setAttribute('status', str(task.getStatus())) if task.startDateTime() != maxDateTime: node.setAttribute('startdate', str(task.startDateTime())) if task.dueDateTime() != maxDateTime: node.setAttribute('duedate', str(task.dueDateTime())) if task.completionDateTime() != maxDateTime: node.setAttribute('completiondate', str(task.completionDateTime())) if task.percentageComplete() != 0: node.setAttribute('percentageComplete', str(task.percentageComplete())) if task.recurrence(): node.appendChild(self.recurrenceNode(task.recurrence())) if task.budget() != date.TimeDelta(): node.setAttribute('budget', self.budgetAsAttribute(task.budget())) if task.priority() != 0: node.setAttribute('priority', str(task.priority())) if task.hourlyFee() != 0: node.setAttribute('hourlyFee', str(task.hourlyFee())) if task.fixedFee() != 0: node.setAttribute('fixedFee', str(task.fixedFee())) if task.reminder() != None: node.setAttribute('reminder', str(task.reminder())) prerequisiteIds = ' '.join([prerequisite.id() for prerequisite in \ task.prerequisites()]) if prerequisiteIds: node.setAttribute('prerequisites', prerequisiteIds) if task.shouldMarkCompletedWhenAllChildrenCompleted() != None: node.setAttribute('shouldMarkCompletedWhenAllChildrenCompleted', str(task.shouldMarkCompletedWhenAllChildrenCompleted())) for effort in task.efforts(): node.appendChild(self.effortNode(effort)) for eachNote in task.notes(): node.appendChild(self.noteNode(eachNote)) for attachment in task.attachments(): node.appendChild(self.attachmentNode(attachment)) return node
def taskNode(self, task): # pylint: disable-msg=W0621 node = self.baseCompositeNode(task, "task", self.taskNode) node.setAttribute("status", str(task.getStatus())) if task.startDateTime() != date.DateTime(): node.setAttribute("startdate", str(task.startDateTime())) if task.dueDateTime() != date.DateTime(): node.setAttribute("duedate", str(task.dueDateTime())) if task.completionDateTime() != date.DateTime(): node.setAttribute("completiondate", str(task.completionDateTime())) if task.percentageComplete() != 0: node.setAttribute("percentageComplete", str(task.percentageComplete())) if task.recurrence(): node.appendChild(self.recurrenceNode(task.recurrence())) if task.budget() != date.TimeDelta(): node.setAttribute("budget", self.budgetAsAttribute(task.budget())) if task.priority() != 0: node.setAttribute("priority", str(task.priority())) if task.hourlyFee() != 0: node.setAttribute("hourlyFee", str(task.hourlyFee())) if task.fixedFee() != 0: node.setAttribute("fixedFee", str(task.fixedFee())) if task.reminder() != None: node.setAttribute("reminder", str(task.reminder())) prerequisiteIds = " ".join([prerequisite.id() for prerequisite in task.prerequisites()]) if prerequisiteIds: node.setAttribute("prerequisites", prerequisiteIds) if task.shouldMarkCompletedWhenAllChildrenCompleted() != None: node.setAttribute( "shouldMarkCompletedWhenAllChildrenCompleted", str(task.shouldMarkCompletedWhenAllChildrenCompleted()) ) for effort in task.efforts(): node.appendChild(self.effortNode(effort)) for eachNote in task.notes(): node.appendChild(self.noteNode(eachNote)) for attachment in task.attachments(): node.appendChild(self.attachmentNode(attachment)) return node
def renderHourlyFee(self, task): return render.monetaryAmount(task.hourlyFee()) # hourlyFee has no recursive value
def _createColumns(self): kwargs = dict(renderDescriptionCallback=lambda task: task.description(), resizeCallback=self.onResizeColumn) columns = [widgets.Column('subject', _('Subject'), task.Task.subjectChangedEventType(), 'task.completionDate', 'task.dueDate', 'task.startDate', task.Task.trackStartEventType(), task.Task.trackStopEventType(), sortCallback=uicommand.ViewerSortByCommand(viewer=self, value='subject'), width=self.getColumnWidth('subject'), imageIndexCallback=self.subjectImageIndex, renderCallback=self.renderSubject, **kwargs)] + \ [widgets.Column('description', _('Description'), task.Task.descriptionChangedEventType(), sortCallback=uicommand.ViewerSortByCommand(viewer=self, value='description'), renderCallback=lambda task: task.description(), width=self.getColumnWidth('description'), **kwargs)] + \ [widgets.Column('attachments', '', task.Task.attachmentsChangedEventType(), width=self.getColumnWidth('attachments'), alignment=wx.LIST_FORMAT_LEFT, imageIndexCallback=self.attachmentImageIndex, headerImageIndex=self.imageIndex['attachment'], renderCallback=lambda task: '', **kwargs)] if self.settings.getboolean('feature', 'notes'): columns.append(widgets.Column('notes', '', task.Task.notesChangedEventType(), width=self.getColumnWidth('notes'), alignment=wx.LIST_FORMAT_LEFT, imageIndexCallback=self.noteImageIndex, headerImageIndex=self.imageIndex['note'], renderCallback=lambda task: '', **kwargs)) columns.extend( [widgets.Column('categories', _('Categories'), task.Task.categoryAddedEventType(), task.Task.categoryRemovedEventType(), task.Task.categorySubjectChangedEventType(), sortCallback=uicommand.ViewerSortByCommand(viewer=self, value='categories'), width=self.getColumnWidth('categories'), renderCallback=self.renderCategory, **kwargs)] + \ [widgets.Column('totalCategories', _('Overall categories'), task.Task.totalCategoryAddedEventType(), task.Task.totalCategoryRemovedEventType(), task.Task.totalCategorySubjectChangedEventType(), sortCallback=uicommand.ViewerSortByCommand(viewer=self, value='totalCategories'), renderCallback=lambda task: self.renderCategory(task, recursive=True), width=self.getColumnWidth('totalCategories'), **kwargs)]) effortOn = self.settings.getboolean('feature', 'effort') dependsOnEffortFeature = ['budget', 'totalBudget', 'timeSpent', 'totalTimeSpent', 'budgetLeft', 'totalBudgetLeft', 'hourlyFee', 'fixedFee', 'totalFixedFee', 'revenue', 'totalRevenue'] for name, columnHeader, renderCallback, eventType in [ ('startDate', _('Start date'), lambda task: render.date(task.startDate()), None), ('dueDate', _('Due date'), lambda task: render.date(task.dueDate()), None), ('timeLeft', _('Days left'), lambda task: render.daysLeft(task.timeLeft(), task.completed()), None), ('completionDate', _('Completion date'), lambda task: render.date(task.completionDate()), None), ('recurrence', _('Recurrence'), lambda task: render.recurrence(task.recurrence()), None), ('budget', _('Budget'), lambda task: render.budget(task.budget()), None), ('totalBudget', _('Total budget'), lambda task: render.budget(task.budget(recursive=True)), None), ('timeSpent', _('Time spent'), lambda task: render.timeSpent(task.timeSpent()), None), ('totalTimeSpent', _('Total time spent'), lambda task: render.timeSpent(task.timeSpent(recursive=True)), None), ('budgetLeft', _('Budget left'), lambda task: render.budget(task.budgetLeft()), None), ('totalBudgetLeft', _('Total budget left'), lambda task: render.budget(task.budgetLeft(recursive=True)), None), ('priority', _('Priority'), lambda task: render.priority(task.priority()), None), ('totalPriority', _('Overall priority'), lambda task: render.priority(task.priority(recursive=True)), None), ('hourlyFee', _('Hourly fee'), lambda task: render.amount(task.hourlyFee()), task.Task.hourlyFeeChangedEventType()), ('fixedFee', _('Fixed fee'), lambda task: render.amount(task.fixedFee()), None), ('totalFixedFee', _('Total fixed fee'), lambda task: render.amount(task.fixedFee(recursive=True)), None), ('revenue', _('Revenue'), lambda task: render.amount(task.revenue()), None), ('totalRevenue', _('Total revenue'), lambda task: render.amount(task.revenue(recursive=True)), None), ('reminder', _('Reminder'), lambda task: render.dateTime(task.reminder()), None)]: eventType = eventType or 'task.'+name if (name in dependsOnEffortFeature and effortOn) or name not in dependsOnEffortFeature: columns.append(widgets.Column(name, columnHeader, eventType, sortCallback=uicommand.ViewerSortByCommand(viewer=self, value=name), renderCallback=renderCallback, width=self.getColumnWidth(name), alignment=wx.LIST_FORMAT_RIGHT, **kwargs)) return columns