本文整理汇总了Python中Task.Task.fields方法的典型用法代码示例。如果您正苦于以下问题:Python Task.fields方法的具体用法?Python Task.fields怎么用?Python Task.fields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Task.Task
的用法示例。
在下文中一共展示了Task.fields方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: showHistory
# 需要导入模块: from Task import Task [as 别名]
# 或者: from Task.Task import fields [as 别名]
def showHistory(tasks, describeTask):
if isinstance(tasks, Task):
tasks = [tasks]
revs = [task.getRevisions() for task in tasks]
revs = [rev for l in revs for rev in l] # Flatten
revs.sort(key = lambda rev: rev.timestamp) # Sort ascending by timestamp
revMap = dict([((rev.id, rev.revision), rev) for rev in revs]) # Map (id, revision #) to the revision
print "<div class=\"revision-history\">"
fields = (set(Task.fields()) | set(['assigned'])) - set(['creatorid', 'timestamp', 'revision'])
prevDay = None
for rev in revs:
day = date.fromtimestamp(rev.timestamp)
if not prevDay or prevDay != day:
print "<h2 class=\"daymarker\">%s</h2>" % day.strftime("%d %b %Y").lstrip('0')
prevDay = day
if rev.revision == 1:
created(rev, None, describeTask)
if rev.deleted:
deleted(rev, None, describeTask)
continue
oldRev = revMap[(rev.id, rev.revision - 1)]
changedFields = filter(lambda f: oldRev.__getattribute__(f) != rev.__getattribute__(f), fields)
# If hours is the only changed field, output it. Otherwise it will be attached to the first change
if 'hours' in changedFields:
if changedFields == ['hours']:
hoursChanged(rev, oldRev, describeTask)
changedFields.remove('hours')
for field in changedFields:
if field == 'status':
statusChanged(rev, oldRev, describeTask)
elif field == 'name':
renamed(rev, oldRev, describeTask)
elif field == 'deleted':
if rev.deleted:
deleted(rev, oldRev, describeTask)
else:
undeleted(rev, oldRev, describeTask)
elif field == 'assigned':
reassigned(rev, oldRev, describeTask)
elif field == 'assignedids':
pass # Handled by 'assigned'
elif field == 'goalid':
goalChanged(rev, oldRev, describeTask)
elif field == 'groupid':
pass # Switching groups doesn't really matter
else:
unrecognizedChange(rev, oldRev, field, describeTask)