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


Python Task.save_from_re方法代码示例

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


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

示例1: create_task

# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import save_from_re [as 别名]
def create_task(task_title, user):
    """
    Creates the task with the `task_title` and assigns the `user` to
    `assigned_users` if `assigned_users` is empty.
    """
    task = Task()
    task.save_from_re(task_title)

    # If user was not yet assigned use the email user.
    if len(task.assigned_users.all()) == 0:
        task.assigned_users.add(user)

    return task
开发者ID:abhi-shete,项目名称:fedup,代码行数:15,代码来源:fetch_mail.py

示例2: read_create

# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import save_from_re [as 别名]
def read_create(request, filter_type=None, filter_id=None):
    '''
    Gets all the tasks given the filter_type. If filter_type is none it returns all 
    uncompleted Tasks. It also creates a Task.
    '''
    # Create Task
    if request.method == 'POST':
        task = request.POST.get('task')
        notes = request.POST.get('notes')
        if task:
            new_task = Task()
            new_task.notes = notes
            new_task.save_from_re(task)
            return HttpResponse('success')

    # Get Tasks
    else:
        tasks = Task.objects.order_by('-created')

        # GET has a parameted, completed, which is used to fetch all completed tasks.
        if request.GET.get('completed'):
            tasks = tasks.filter(completed=True)
        else:
            tasks = tasks.filter(completed=False)

        if filter_type == 'user':
            user = User.objects.get(id=filter_id)
            tasks = tasks.filter(assigned_users=user)

        elif filter_type == 'tag':
            tag = Tag.objects.get(id=filter_id)
            tasks = tasks.filter(tag=tag)

        elif filter_type == 'list':
            task_list = TaskList.objects.get(id=filter_id)
            tasks = tasks.filter(task_list=task_list)


        return render_to_response('tasks/index.html', 
                                    {'tasks': tasks}, 
                                    context_instance=RequestContext(request))
开发者ID:abhi-shete,项目名称:fedup,代码行数:43,代码来源:views.py


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