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


Python Task.get方法代码示例

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


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

示例1: get

# 需要导入模块: from model import Task [as 别名]
# 或者: from model.Task import get [as 别名]
 def get(self, *args, **kwargs):
     tid = kwargs.get('tid')
     mode = kwargs.get('mode')
     if not tid:
         raise HTTPError(404)
     p_users = Auth.find_project_users(pid=self.pid)
     self.p_users = [{'id': auth.user_id, 'name': auth.user_name} for auth in p_users]
     self.json_p_users = json.dumps(self.p_users)
     task = Task.get(id=tid)
     if not mode:  # 任务详细信息
         # get comment
         task_comments = Comment.find(task_id=task.id, order_by='created')
         # get change log
         task_logs = TaskLog.find(task_id=task.id, order_by='created desc')
         # focus
         focus = TaskFocus.check_focus(task_id=task.id, user_id=self.user.id)
         return self.render('task.html',
                            task=task,
                            auth=self.auth,
                            logs=task_logs,
                            comments=task_comments,
                            focus=focus)
     if mode == 'solve':  # 标记解决任务
         if not task.is_done:
             task.status = Task._status_solved
             task.save()
             TaskLog.new(
                 task_id=task.id,
                 desc=json.dumps([]),
                 note=u'标记为解决',
                 updater_id=self.user.id,
                 updater_name=self.user.name,
             )
         return self.redirect('/%s/%s/%s' % (self.pid, 'task', task.id))
     if mode == 'edit':  # 编辑任务
         # 用户列表去除已经分配的用户
         users = [u for u in self.p_users if u['id'] not in task.assigned_ids]
         json_p_users = json.dumps(users)
         task_data = task.dictify()
         task_data['assigneds'] = json.dumps(task.assigned_users)
         return self.render(
             'task-new.html',
             task=task_data,
             auth=self.auth,
             json_users=json_p_users,
             statuses=self.statuses,
             types=self.types,
             priorities=self.priorities,
             errors={},
             update=True)
     if mode == 'focus':  # 关注任务
         TaskFocus.focus(
             task=task,
             user=self.user,
             pid=self.pid,
             pname=self.auth.project_name,
         )
         return self.redirect('/%s/%s/%s' % (self.pid, 'task', task.id))
开发者ID:Geew,项目名称:issue-task,代码行数:60,代码来源:view.py

示例2: txn

# 需要导入模块: from model import Task [as 别名]
# 或者: from model.Task import get [as 别名]
 def txn():
     level = root_task.hierarchy_level() + 1 if root_task else 0
     query = TaskIndex.all(keys_only=True).\
         ancestor(Domain.key_from_name(domain_identifier)).\
         filter('assignees =', user.identifier()).\
         filter('level =', level)
     if root_task:
         query.filter('hierarchy =', root_task.identifier())
     fetched = query.fetch(limit)
     tasks = Task.get([key.parent() for key in fetched])
     return tasks
开发者ID:wadevries,项目名称:sps,代码行数:13,代码来源:api.py

示例3: get_all_subtasks

# 需要导入模块: from model import Task [as 别名]
# 或者: from model.Task import get [as 别名]
def get_all_subtasks(domain, task, limit=50, depth_limit=None):
    """
    Returns a list of all subtasks of the given task, in the order
    as a pre-order traversal through the task hierarchy.

    This function will perform one query for each level of the subtask
    hierarchy.

    Args:
        domain: The domain identifier string.
        task: An instance of the Task model.
        limit: The maximum number of subtasks to return.
        depth_limit: The maximum depth of subtasks in the task
            hierarchy.

    Returns:
        A list with all subtasks of the given task.

    Raises:
        ValueError: The depth_limit or limit are not positive integers
    """
    if not depth_limit:
        #  ListProperties cannot contain more than 5000 elements anyway
        depth_limit = 5000
    if depth_limit < 0 or limit < 0:
        raise ValueError("Invalid limits")

    task_level = task.level
    tasks = []
    for depth in range(depth_limit):
        query = TaskIndex.all(keys_only=True).\
            ancestor(Domain.key_from_name(domain)).\
            filter('level = ', task_level + depth + 1).\
            filter('hierarchy = ', task.identifier())
        fetched = query.fetch(limit)
        tasks.extend(Task.get([key.parent() for key in fetched]))
        limit = limit - len(fetched)
        if not fetched or limit < 1:
            break               # stop

    # Sort the tasks on completion status and then on time, as this is
    # not possible in the query.
    def task_cmp(t1, t2):
        if t1.completed != t2.completed:
            return cmp(t1.completed, t2.completed)
        return -cmp(t1.time, t2.time)

    tasks.sort(cmp=task_cmp)
    return _group_tasks(tasks)
开发者ID:edrijver,项目名称:sps,代码行数:51,代码来源:api.py

示例4: post

# 需要导入模块: from model import Task [as 别名]
# 或者: from model.Task import get [as 别名]
 def post(self, *args, **kwargs):
     tid = kwargs.get('tid')
     if not tid:
         raise HTTPError(404)
     task = Task.get(id=tid)
     form = CommentForm(self.request.arguments)
     # set form data
     form.from_user_id.data = self.user.id
     form.from_user_name.data = self.user.name
     form.to_user_id.data = task.creator_id
     form.to_user_name.data = task.creator_name
     form.task_id.data = task.id
     form.task_title.data = task.title
     # 分析content 识别链接, 识别@
     # 链接 <a>url</a>
     content, at_users = analyse_content(form.content.data)
     print '****************content: ', repr(content)
     form.type.data = Comment._type_at if at_users else Comment._type_reply
     form.content.data = content
     if form.validate():
         comment = Comment.new(**form.data)
         # 评论消息 自己回复自己或者自己@自己不发消息
         if int(self.user.id) != int(task.creator_id):
             Message.set(
                 user_id=task.creator_id,
                 from_user=self.user,
                 task=task,
                 pid=self.pid,
                 pname=self.auth.project_name,
                 type='apply',
                 content=content,
             )
         # @消息
         for name in at_users:
             user = User.get(name=name, status=User._status_ok)
             if user and user.id != int(self.user.id):
                 Message.set(
                     user_id=user.id,
                     from_user=self.user,
                     task=task,
                     pid=self.pid,
                     pname=self.auth.project_name,
                     type='@',
                     content=content,
                 )
         return self.redirect('/%s/task/%s' % (self.pid, task.id))
     else:
         return self.render('comment.html', errors=form.errors, auth=self.auth, task=task)
开发者ID:Geew,项目名称:issue-task,代码行数:50,代码来源:view.py


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