本文整理汇总了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},
)
示例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))
示例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",
})
示例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))
示例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))
示例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),
)
示例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",
})
示例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))