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


Python Task.approving_roles方法代码示例

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


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

示例1: create_task

# 需要导入模块: from models import Task [as 别名]
# 或者: from models.Task import approving_roles [as 别名]
def create_task(request, group_id):
    '''
    INPUT
    Takes in a submission of the create task form, gathering the Title,
    Description, Deadline, Assignee, and optional Points arguments.  Also takes
    the Group ID and Assigner ID implicitly from the page request.

    OUTPUT
    Creates a new Task entry in the database associated with all relevant
    parties, adding it to the Tasks for each Member assigned.
    '''

    # Grab the information of the creator group & member

    # Grab the basic stuff associated with the Task.  When's it due, what is it, what has to be returned,
    # any special comments.
    name = request.form['name']
    deadline = request.form['deadline'] if request.form['deadline'] != None else None
    description = request.form['description'] if request.form['description'] != None else None
    deliverable = request.form['deliverable'] if request.form['deliverable'] != None else None
    comments = request.form['comments'] if request.form['comments'] != None else None

    # Create the task using the information we picked out of the form.
    new_task = Task(name=name, group_id=group_id, description=description, deadline=deadline,
                    deliverable=deliverable, comments=comments)

    # Now we need to set all our ForeignKey associations.  First, make lists of all the Members and Roles
    # which are supposed to be true now.
    new_approving_members = [Member.query.filter_by(group_id=group_id, codename=membername)
                             for membername in request.form['approving_members']]
    new_delivering_members = [Member.query.filter_by(group_id, codename=membername)
                              for membername in request.form['delivering_members']]

    new_approving_roles = [Role.query.get(int(role_id)) for role_id in request.form['approving_roles']]
    new_delivering_roles = [Role.query.get(int(role_id)) for role_id in request.form['delivering_roles']]

    # Then, set all of these relations to be set as described by the form.
    new_task.approving_members = new_approving_members
    new_task.approving_roles = new_approving_roles
    new_task.delivering_members = new_delivering_members
    new_task.delivering_roles = new_delivering_roles

    # Finally, correct the approving_members and delivering_members relations to only contain Members
    # who have one of the Roles specified in the approving_roles and delivering_roles relations.
    new_task.update_approvers_by_roles()
    new_task.update_deliverers_by_roles()

    # Add and save our work.
    db_session.add(new_task)
    db_session.commit()
    return new_task
开发者ID:john-osullivan,项目名称:groupbot,代码行数:53,代码来源:task.py


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