def admin_edit_faq(request, faq): if request.user.is_superuser: c = Faq.objects.get(pk=faq) if request.method == "POST": form = FaqForm(request.POST, instance=c) if form.is_valid(): form.save() return HttpResponseRedirect(reverse("admin_list_categories")) else: form = FaqForm(instance=c) context = RequestContext(request) extra_context = {"form": form, "curfaq": c} return render_to_response("faq/edit_faq.html", extra_context, context_instance=context) else: return HttpResponseRedirect("/")
def admin_add_faq(request): if request.user.is_superuser: if request.method == "POST": form = FaqForm(request.POST) if form.is_valid(): faq = form.save(commit=False) faq.owner = request.user faq.save() return HttpResponseRedirect(reverse("list_faqs")) else: form = FaqForm(request.POST) else: form = FaqForm() context = RequestContext(request) extra_context = {"form": form, "curfaq": False} return render_to_response("faq/edit_faq.html", extra_context, context_instance=context) else: return HttpResponseRedirect("/")
def admin_add_faq(request): if request.user.is_superuser: if request.method == 'POST': form = FaqForm(request.POST) if form.is_valid(): faq = form.save(commit=False) faq.owner = request.user faq.save() return HttpResponseRedirect(reverse('list_faqs')) else: form = FaqForm(request.POST) else: form = FaqForm() context = RequestContext(request) extra_context = {'form': form, 'curfaq': False} return render_to_response('faq/edit_faq.html', extra_context, context_instance=context) else: return HttpResponseRedirect('/')
def admin_edit_faq(request, faq): if request.user.is_superuser: c = Faq.objects.get(pk=faq) if request.method == 'POST': form = FaqForm(request.POST, instance=c) if form.is_valid(): form.save() return HttpResponseRedirect(reverse('admin_list_categories')) else: form = FaqForm(instance=c) context = RequestContext(request) extra_context = {'form': form, 'curfaq': c} return render_to_response('faq/edit_faq.html', extra_context, context_instance=context) else: return HttpResponseRedirect('/')