def add_voucher_group(request, template_name="manage/voucher/add_voucher_group.html"): """Adds a voucher group """ if request.method == "POST": form = VoucherGroupAddForm(data=request.POST) if form.is_valid(): voucher_group = form.save(commit=False) voucher_group.creator = request.user voucher_group.save() url = reverse("lfs_manage_voucher_group", kwargs={"id": voucher_group.id}) return HttpResponseRedirect(url) else: form = VoucherGroupAddForm() return render_to_response(template_name, RequestContext(request, { "form": form, "voucher_groups": VoucherGroup.objects.all(), "came_from": request.REQUEST.get("came_from", reverse("lfs_manage_vouchers")), }))
def add_voucher_group(request, template_name="manage/voucher/add_voucher_group.html"): """Adds a voucher group """ if request.method == "POST": form = VoucherGroupAddForm(data=request.POST) if form.is_valid(): voucher_group = form.save(commit=False) voucher_group.creator = request.user voucher_group.save() url = reverse("lfs_manage_voucher_group", kwargs={"id": voucher_group.id}) return HttpResponseRedirect(url) else: form = VoucherGroupAddForm() return render_to_response( template_name, RequestContext( request, { "form": form, "voucher_groups": VoucherGroup.objects.all(), "came_from": (request.POST if request.method == 'POST' else request.GET).get("came_from", reverse("lfs_manage_vouchers")), }))