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


Python Task.set_user_from_request方法代码示例

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


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

示例1: task_add_to_milestone

# 需要导入模块: from models import Task [as 别名]
# 或者: from models.Task import set_user_from_request [as 别名]
def task_add_to_milestone(request, milestone_id=None, response_format='html'):
    """Task add to preselected project"""

    milestone = None
    if milestone_id:
        milestone = get_object_or_404(Milestone, pk=milestone_id)
        if not request.user.profile.has_permission(milestone, mode='x'):
            milestone = None

    project = milestone.project
    project_id = milestone.project.id

    if request.POST:
        if 'cancel' not in request.POST:
            task = Task()
            form = TaskForm(request.user.profile, None,
                            project_id, milestone_id, request.POST, instance=task)
            if form.is_valid():
                task = form.save()
                task.set_user_from_request(request)
                return HttpResponseRedirect(reverse('projects_task_view', args=[task.id]))
        else:
            return HttpResponseRedirect(reverse('projects_milestone_view', args=[milestone.id]))
    else:
        form = TaskForm(
            request.user.profile, None, project_id, milestone_id)

    context = _get_default_context(request)
    context.update({'form': form,
                    'project': project,
                    'milestone': milestone})

    return render_to_response('projects/task_add_to_milestone', context,
                              context_instance=RequestContext(request), response_format=response_format)
开发者ID:tovmeod,项目名称:anaf,代码行数:36,代码来源:views.py

示例2: task_add_subtask

# 需要导入模块: from models import Task [as 别名]
# 或者: from models.Task import set_user_from_request [as 别名]
def task_add_subtask(request, task_id=None, response_format='html'):
    """New subtask form"""

    parent = None
    if task_id:
        parent = get_object_or_404(Task, pk=task_id)
        if not request.user.profile.has_permission(parent, mode='x'):
            parent = None

    if request.POST:
        if 'cancel' not in request.POST:
            task = Task()
            form = TaskForm(
                request.user.profile, parent, None, None, request.POST, instance=task)
            if form.is_valid():
                task = form.save()
                task.set_user_from_request(request)
                return HttpResponseRedirect(reverse('projects_task_view', args=[parent.id]))
        else:
            return HttpResponseRedirect(reverse('projects_task_view', args=[parent.id]))
    else:
        form = TaskForm(request.user.profile, parent, None, None)

    context = _get_default_context(request)
    context.update({'form': form,
                    'task': parent})

    return render_to_response('projects/task_add_subtask', context,
                              context_instance=RequestContext(request), response_format=response_format)
开发者ID:tovmeod,项目名称:anaf,代码行数:31,代码来源:views.py

示例3: task_add

# 需要导入模块: from models import Task [as 别名]
# 或者: from models.Task import set_user_from_request [as 别名]
def task_add(request, response_format='html'):
    """New task form"""

    if request.POST:
        if 'cancel' not in request.POST:
            task = Task()
            form = TaskForm(
                request.user.profile, None, None, None, request.POST, instance=task)
            if form.is_valid():
                task = form.save()
                task.set_user_from_request(request)
                return HttpResponseRedirect(reverse('projects_task_view', args=[task.id]))
        else:
            return HttpResponseRedirect(reverse('projects'))
    else:
        form = TaskForm(request.user.profile, None, None, None)

    context = _get_default_context(request)
    context.update({'form': form})

    return render_to_response('projects/task_add', context,
                              context_instance=RequestContext(request), response_format=response_format)
开发者ID:tovmeod,项目名称:anaf,代码行数:24,代码来源:views.py


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