def edit_timeline(request, slug, template_name="package/timeline_form.html"):
project = get_object_or_404(Project, slug=slug)
if not request.user.profile.can_edit_package(project):
return HttpResponseForbidden("permission denied")
if request.POST:
formset = TimelineEventFormSet(data=request.POST, project=project,)
else:
formset = TimelineEventFormSet(project=project, queryset=TimelineEvent.objects.filter(project=project))
if formset.is_valid():
formset.save()
messages.add_message(request, messages.INFO, 'Project updated successfully')
return HttpResponseRedirect(reverse("package", kwargs={"slug": project.slug}))
return render(request, template_name, {
"formset": formset,
"package": project,
"action": "Save",
})
评论列表
文章目录