当前位置: 首页>>代码示例>>Python>>正文


Python Task.fields方法代码示例

本文整理汇总了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)
开发者ID:mrozekma,项目名称:Sprint,代码行数:56,代码来源:History.py


注:本文中的Task.Task.fields方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。