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


Python Task.loadAll方法代码示例

本文整理汇总了Python中Task.Task.loadAll方法的典型用法代码示例。如果您正苦于以下问题:Python Task.loadAll方法的具体用法?Python Task.loadAll怎么用?Python Task.loadAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Task.Task的用法示例。


在下文中一共展示了Task.loadAll方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getTasks

# 需要导入模块: from Task import Task [as 别名]
# 或者: from Task.Task import loadAll [as 别名]
	def getTasks(self, orderby = 'seq', includeDeleted = False):
		from Task import Task
		tasks = Task.loadAll(sprintid = self.id, orderby = orderby)
		# This is filtered here instead of in Task.loadAll to prevent loading old revisions
		if not includeDeleted:
			tasks = filter(lambda t: not t.deleted, tasks)
		return tasks
开发者ID:mrozekma,项目名称:Sprint,代码行数:9,代码来源:Sprint.py

示例2: userTasks

# 需要导入模块: from Task import Task [as 别名]
# 或者: from Task.Task import loadAll [as 别名]
def userTasks(handler, username):
	handler.title('User tasks')
	user = User.load(username = username)
	if not user:
		ErrorBox.die("User tasks", "No user named <b>%s</b>" % stripTags(username))

	tasks = [task.id for task in Task.loadAll() if user in task.assigned and task.stillOpen() and task.sprint.isActive()]
	if len(tasks) == 0:
		ErrorBox.die("User tasks", "%s has no open tasks in active sprints" % user)

	redirect("/tasks/%s" % ','.join(map(str, tasks)))
开发者ID:mrozekma,项目名称:Sprint,代码行数:13,代码来源:users.py

示例3: sprintCleanup

# 需要导入模块: from Task import Task [as 别名]
# 或者: from Task.Task import loadAll [as 别名]
def sprintCleanup():
	for sprint in Sprint.loadAll():
		if 'deleted' in sprint.flags:
			sprint.delete(deep = True)
			print "Deleted sprint %d (%s: %s)<br>" % (sprint.id, sprint.project.safe.name, sprint.safe.name)
			continue

		if (not sprint.isOver()) or 'cleaned-up' in sprint.flags:
			continue
		tasks = Task.loadAll(sprintid = sprint.id, deleted = False)
		tasks = filter(lambda task: task.stillOpen(), tasks)

		for task in tasks:
			task.status = 'deferred'
			task.creator = sprint.owner
			task.timestamp = sprint.end
			task.revise()

		sprint.flags.add('cleaned-up')
		sprint.save()
		print "Cleaned up sprint %d (%s: %s): %s deferred<br>" % (sprint.id, sprint.project.safe.name, sprint.safe.name, pluralize(len(tasks), 'task', 'tasks'))
开发者ID:mrozekma,项目名称:Sprint,代码行数:23,代码来源:Cron.py

示例4: sprintPost

# 需要导入模块: from Task import Task [as 别名]
# 或者: from Task.Task import loadAll [as 别名]
def sprintPost(handler, sprintid, p_id, p_rev_id, p_field, p_value):
	def die(msg):
		print msg
		done()

	handler.wrappers = False
	sprintid = to_int(sprintid, 'sprintid', die)
	p_id = to_int(p_id, 'id', die)
	p_rev_id = to_int(p_rev_id, 'rev_id', die)

	if not handler.session['user']:
		die("You must be logged in to modify tasks")

	sprint = Sprint.load(sprintid)
	if not sprint or sprint.isHidden(handler.session['user']):
		die("There is no sprint with ID %d" % sprintid)
	elif not (sprint.isActive() or sprint.isPlanning()):
		die("Unable to modify inactive sprint")
	elif not sprint.canEdit(handler.session['user']):
		die("You don't have permission to modify this sprint")

	# Special case group moves; p_id is the group ID, not task
	task = None
	if p_field != 'groupmove':
		task = Task.load(p_id)
		if not task:
			die("Task %d does not exist" % p_id)
		if task.sprint != sprint:
			die("Attempting to modify task outside the specified sprint")
		if task.revision != p_rev_id: #TODO Implement collision support
			die("Collision with %s detected. Changes not saved" % task.creator)

	if p_value.strip() == '':
		die("Value cannot be empty")

	if p_field in ['status', 'name', 'goal', 'assigned', 'hours', 'deleted']:
		for case in switch(p_field):
			if case('status') or case('name'):
				parsedValue = p_value
				break
			elif case('goal'):
				parsedValue = None
				if p_value != '0':
					parsedValue = Goal.load(to_int(p_value, 'goal', die))
					if not parsedValue:
						die("Unknown goal: <b>%s</b>" % stripTags(p_value))
					if parsedValue.sprint != sprint:
						die("Attempting to use goal outside the specified sprint")
				break
			elif case('assigned'):
				parsedValue = set(User.load(username = username) for username in p_value.split(' '))
				if not all(parsedValue):
					die("Unknown user(s): <b>%s</b>" % stripTags(p_value))
				break
			elif case('hours'):
				parsedValue = int(p_value)
				break
			elif case('deleted'):
				parsedValue = True if p_value == 'true' else False if p_value == 'false' else die("Bad value for field 'deleted'")
				break

		if task.__getattribute__(p_field) != parsedValue: # Only save if the field has changed
			task.__setattr__(p_field, parsedValue)

			# Is this within the 5-minute window, by the same user?
			# If we're in pre-planning, the task's timestamp will be in the future, so (ts - task.timestamp) will be negative, which satisfies the check
			if task.creator == handler.session['user'] and (dateToTs(getNow()) - task.timestamp) < 5*60:
				task.save()
			else:
				task.saveRevision(handler.session['user'])

			Event.taskUpdate(handler, task, p_field, parsedValue)

	elif p_field == 'taskmove':
		if ':' not in p_value:
			die("Malformed value")
		newGroupID, newSeq = map(lambda i: to_int(i, 'value', die), p_value.split(':', 1))
		newGroup = Group.load(newGroupID)
		if not newGroup:
			die("No group with ID %d" % newGroupID)
		maxSeq = len(Task.loadAll(groupid = newGroup.id))
		if task.group != newGroup:
			maxSeq += 1
		if not 1 <= newSeq <= maxSeq:
			die("Bad sequence number")

		task.move(newSeq, newGroup)

	elif p_field == 'groupmove':
		group = Group.load(p_id)
		if not group:
			die("Group %d does not exist" % p_id)
		if group.sprint != sprint:
			die("Attempting to modify group outside the specified sprint")

		newSeq = to_int(p_value, 'value', die)
		if not 1 <= newSeq <= len(sprint.getGroups()):
			die("Bad sequence number")

		group.move(newSeq)
#.........这里部分代码省略.........
开发者ID:mrozekma,项目名称:Sprint,代码行数:103,代码来源:sprints.py


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