def add_feature(request, grid_slug, template_name="grid/add_feature.html"): """Adds a feature to the grid, accepts GET and POST requests. Requires user to be logged in Template context: * ``form`` - instance of :class:`grid.forms.FeatureForm` form * ``grid`` - instance of :class:`grid.models.Grid` model """ if not request.user.get_profile().can_add_grid_feature: return HttpResponseForbidden("permission denied") grid = get_object_or_404(Grid, slug=grid_slug) feature = Feature() form = FeatureForm(request.POST or None, instance=feature) if form.is_valid(): feature = Feature( grid=grid, title=request.POST['title'], description = request.POST['description'] ) feature.save() return HttpResponseRedirect(reverse('grid', kwargs={'slug':feature.grid.slug})) return render(request, template_name, { 'form': form,'grid':grid })
def edit_feature(request, id, template_name="grid/edit_feature.html"): feature = get_object_or_404(Feature, id=id) form = FeatureForm(request.POST or None, instance=feature) if form.is_valid(): feature = form.save() return HttpResponseRedirect(reverse("grid", kwargs={"slug": feature.grid.slug})) return render_to_response( template_name, {"form": form, "grid": feature.grid}, context_instance=RequestContext(request) )
def add_feature(request, grid_slug, template_name="grid/add_feature.html"): grid = get_object_or_404(Grid, slug=grid_slug) feature = Feature() form = FeatureForm(request.POST or None, instance=feature) if form.is_valid(): feature = Feature(grid=grid, title=request.POST["title"], description=request.POST["description"]) feature.save() return HttpResponseRedirect(reverse("grid", kwargs={"slug": feature.grid.slug})) return render_to_response(template_name, {"form": form, "grid": grid}, context_instance=RequestContext(request))
def edit_feature(request, id, template_name="grid/edit_feature.html"): feature = get_object_or_404(Feature, id=id) form = FeatureForm(request.POST or None, instance=feature) if form.is_valid(): feature = form.save() return HttpResponseRedirect(reverse('grid', kwargs={'slug': feature.grid.slug})) return render_to_response(template_name, { 'form': form, 'grid': feature.grid }, context_instance=RequestContext(request))
def edit_feature(request, id, template_name="grid/update_feature.html"): """edits feature on a grid - this view has the same semantics as :func:`grid.views.add_feature`. Requires the user to be logged in. """ if not request.user.get_profile().can_edit_grid_feature: return HttpResponseForbidden("permission denied") feature = get_object_or_404(Feature, id=id) form = FeatureForm(request.POST or None, instance=feature) if form.is_valid(): feature = form.save() return HttpResponseRedirect(reverse('grid', kwargs={'slug': feature.grid.slug})) return render(request, template_name, {'form': form, 'grid': feature.grid})
def edit_feature(request, id, template_name="grid/edit_feature.html"): """edits feature on a grid - this view has the same semantics as :func:`grid.views.add_feature`. Requires the user to be logged in. """ if not request.user.get_profile().can_edit_grid_feature: return HttpResponseForbidden("permission denied") feature = get_object_or_404(Feature, id=id) form = FeatureForm(request.POST or None, instance=feature) if form.is_valid(): feature = form.save() return HttpResponseRedirect(reverse("grid", kwargs={"slug": feature.grid.slug})) return render(request, template_name, {"form": form, "grid": feature.grid})
def add_feature(request, grid_slug, template_name="grid/add_feature.html"): grid = get_object_or_404(Grid, slug=grid_slug) feature = Feature() form = FeatureForm(request.POST or None, instance=feature) if form.is_valid(): feature = Feature(grid=grid, title=request.POST['title'], description=request.POST['description']) feature.save() return HttpResponseRedirect( reverse('grid', kwargs={'slug': feature.grid.slug})) return render_to_response(template_name, { 'form': form, 'grid': grid }, context_instance=RequestContext(request))
def edit_feature(request, id, template_name="grid/edit_feature.html"): """edits feature on a grid - this view has the same semantics as :func:`grid.views.add_feature`. Requires the user to be logged in. """ feature = get_object_or_404(Feature, id=id) form = FeatureForm(request.POST or None, instance=feature) if form.is_valid(): feature = form.save() return HttpResponseRedirect(reverse('grid', kwargs={'slug': feature.grid.slug})) return render_to_response(template_name, { 'form': form, 'grid': feature.grid }, context_instance=RequestContext(request))
def edit_feature(request, id, template_name="grid/edit_feature.html"): """edits feature on a grid - this view has the same semantics as :func:`grid.views.add_feature`. Requires the user to be logged in. """ feature = get_object_or_404(Feature, id=id) form = FeatureForm(request.POST or None, instance=feature) if form.is_valid(): feature = form.save() return HttpResponseRedirect( reverse('grid', kwargs={'slug': feature.grid.slug})) return render_to_response(template_name, { 'form': form, 'grid': feature.grid }, context_instance=RequestContext(request))