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


Python PackageForm.save方法代码示例

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


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

示例1: add_package

# 需要导入模块: from package.forms import PackageForm [as 别名]
# 或者: from package.forms.PackageForm import save [as 别名]
def add_package(request, template_name="package/package_form.html"):

    if not request.user.get_profile().can_add_package:
        return HttpResponseForbidden("permission denied")

    new_package = Package()
    form = PackageForm(request.POST or None, instance=new_package)

    package_extenders = build_package_extenders(request)

    if form.is_valid():
        new_package = form.save()
        new_package.created_by = request.user
        new_package.last_modified_by = request.user
        new_package.save()
        new_package.fetch_metadata()
        new_package.fetch_commits()

        # stick in package_extender form processing
        for package_extender in package_extenders:
            if package_extender["form"].is_valid():
                package_extender["form"].save()
        return HttpResponseRedirect(reverse("package", kwargs={"slug": new_package.slug}))

    return render(
        request,
        template_name,
        {"form": form, "repo_data": repo_data_for_js(), "action": "add", "package_extenders": package_extenders},
    )
开发者ID:jefftriplett,项目名称:opencomparison,代码行数:31,代码来源:views.py

示例2: add_new_grid_package

# 需要导入模块: from package.forms import PackageForm [as 别名]
# 或者: from package.forms.PackageForm import save [as 别名]
def add_new_grid_package(request, grid_slug, template_name="package/package_form.html"):
    """Add a package to a grid that isn't yet represented on the site."""
    
    if not request.user.get_profile().can_add_grid_package:
        return HttpResponseForbidden("permission denied")

    grid = get_object_or_404(Grid, slug=grid_slug)
    
    new_package = Package()
    form = PackageForm(request.POST or None, instance=new_package)
    
    if form.is_valid():
        new_package = form.save()
        GridPackage.objects.create(
            grid=grid, 
            package=new_package
        )
        return HttpResponseRedirect(reverse("grid", kwargs={"slug":grid_slug}))
    
    return render_to_response(template_name, {
        "form": form,
        "repo_data": repo_data_for_js(),
        "action": "add",
        },
        context_instance=RequestContext(request))
开发者ID:benracine,项目名称:Vispack,代码行数:27,代码来源:views.py

示例3: edit_package

# 需要导入模块: from package.forms import PackageForm [as 别名]
# 或者: from package.forms.PackageForm import save [as 别名]
def edit_package(request, slug, template_name="package/package_form.html"):

    if not request.user.get_profile().can_edit_package:
        return HttpResponseForbidden("permission denied")

    package = get_object_or_404(Package, slug=slug)
    form = PackageForm(request.POST or None, instance=package)

    package_extenders = build_package_extenders(request)

    if form.is_valid():
        modified_package = form.save()
        modified_package.last_modified_by = request.user
        modified_package.save()
        # stick in package_extender form processing
        for package_extender in package_extenders:
            if package_extender['form'].is_valid():
                package_extender['form'].save()
        return HttpResponseRedirect(reverse("package", kwargs={"slug": modified_package.slug}))

    return render(request, template_name, {
        "form": form,
        "package": package,
        "repo_data": repo_data_for_js(),
        "action": "edit",
        })
开发者ID:cypreess,项目名称:opencomparison,代码行数:28,代码来源:views.py

示例4: edit_package

# 需要导入模块: from package.forms import PackageForm [as 别名]
# 或者: from package.forms.PackageForm import save [as 别名]
def edit_package(request, slug, template_name="package/package_form.html"):
    
    package = get_object_or_404(Package, slug=slug)
    form = PackageForm(request.POST or None, instance=package)
    
    if form.is_valid():
        form.save()
        return HttpResponseRedirect(reverse("package", kwargs={"slug": package.slug}))
    
    return render_to_response(template_name, {
        "form": form,
        "package": package,
        "repos": repos_for_js(),
        "action": "edit",
        },
        context_instance=RequestContext(request))
开发者ID:rootart,项目名称:scaredofrabbits,代码行数:18,代码来源:views.py

示例5: add_package

# 需要导入模块: from package.forms import PackageForm [as 别名]
# 或者: from package.forms.PackageForm import save [as 别名]
def add_package(request, template_name="package/package_form.html"):
    
    new_package = Package()
    form = PackageForm(request.POST or None, instance=new_package)
    
    if form.is_valid():
        new_package = form.save()
        return HttpResponseRedirect(reverse("package", kwargs={"slug":new_package.slug}))
    
    return render_to_response(template_name, {
        "form": form,
        "repos": repos_for_js(),
        "action": "add",
        },
        context_instance=RequestContext(request))
开发者ID:rootart,项目名称:scaredofrabbits,代码行数:17,代码来源:views.py

示例6: add_package

# 需要导入模块: from package.forms import PackageForm [as 别名]
# 或者: from package.forms.PackageForm import save [as 别名]
def add_package(request, template_name="package/package_form.html"):

    new_package = Package()
    form = PackageForm(request.POST or None, instance=new_package)

    if form.is_valid():
        new_package = form.save()
        new_package.created_by = request.user
        new_package.last_modified_by = request.user
        new_package.save()
        new_package.fetch_metadata()
        return HttpResponseRedirect(reverse("package", kwargs={"slug": new_package.slug}))

    return render_to_response(
        template_name,
        {"form": form, "repo_data": repo_data_for_js(), "action": "add"},
        context_instance=RequestContext(request),
    )
开发者ID:f4nt,项目名称:packaginator,代码行数:20,代码来源:views.py

示例7: edit_package

# 需要导入模块: from package.forms import PackageForm [as 别名]
# 或者: from package.forms.PackageForm import save [as 别名]
def edit_package(request, slug, template_name="package/package_form.html"):

    if not request.user.get_profile().can_edit_package:
        return HttpResponseForbidden("permission denied")

    package = get_object_or_404(Package, slug=slug)
    form = PackageForm(request.POST or None, instance=package)

    if form.is_valid():
        modified_package = form.save()
        modified_package.last_modified_by = request.user
        modified_package.save()
        messages.add_message(request, messages.INFO, 'Package updated successfully')
        return HttpResponseRedirect(reverse("package", kwargs={"slug": modified_package.slug}))

    return render(request, template_name, {
        "form": form,
        "package": package,
        "repo_data": repo_data_for_js(),
        "action": "edit",
        })
开发者ID:mshamber,项目名称:opencomparison,代码行数:23,代码来源:views.py

示例8: add_new_grid_package

# 需要导入模块: from package.forms import PackageForm [as 别名]
# 或者: from package.forms.PackageForm import save [as 别名]
def add_new_grid_package(request, grid_slug, template_name="package/package_form.html"):
    
    grid = get_object_or_404(Grid, slug=grid_slug)
    
    new_package = Package()
    form = PackageForm(request.POST or None, instance=new_package)
    
    if form.is_valid():
        new_package = form.save()
        GridPackage.objects.create(
            grid=grid, 
            package=new_package
        )
        return HttpResponseRedirect(reverse("grid", kwargs={"slug":grid_slug}))
    
    return render_to_response(template_name, {
        "form": form,
        "repo_data": repo_data_for_js(),
        "action": "add",
        },
        context_instance=RequestContext(request))
开发者ID:FlaviuSim,项目名称:packaginator,代码行数:23,代码来源:views.py


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