Exemple #1
0
def manager_faq_edit_category(request, category):
    try:
        category = FaqCategory.objects.get(pk=category)
    except FaqCategory.DoesNotExist:
        raise Http404
    check = get_acl_for_model(Faq)
    if check.manager_faq(category.faq, request.user):
        if request.method == 'POST':
            form = FaqQuestionCategoryForm(request,
                                           request.POST,
                                           instance=category)
            if form.is_valid():
                form.save()
                return HttpResponseRedirect(
                    reverse('manager_faq_list_categories',
                            args=[category.faq_id]))
            else:
                form = FaqQuestionCategoryForm(request,
                                               request.POST,
                                               instance=category)
        else:
            form = FaqQuestionCategoryForm(request, instance=category)

        context = RequestContext(request)
        extra_context = {'form': form, 'curcategory': category}
        extra_context['curfaq'] = category.faq
        return render_to_response('faq/edit_category.html',
                                  extra_context,
                                  context_instance=context)
    else:
        return HttpResponseRedirect('/')
Exemple #2
0
def manager_faq_add_category(request, faq):
    try:
        faq = Faq.objects.get(pk=faq)
    except Faq.DoesNotExist:
        raise Http404
    check = get_acl_for_model(Faq)
    if check.manager_faq(faq, request.user):
        initial_data = {}
        initial_data['faq'] = faq
        if request.method == 'POST':
            form = FaqQuestionCategoryForm(request,
                                           request.POST,
                                           initial=initial_data)
            if form.is_valid():
                form.save()
                return HttpResponseRedirect(
                    reverse('manager_faq_list_categories', args=[faq.pk]))
            else:
                form = FaqQuestionCategoryForm(request,
                                               request.POST,
                                               initial=initial_data)
        else:
            form = FaqQuestionCategoryForm(request, initial=initial_data)

        context = RequestContext(request)
        extra_context = {'form': form, 'curcategory': False}
        extra_context['curfaq'] = Faq.objects.get(pk=faq.pk)
        return render_to_response('faq/edit_category.html',
                                  extra_context,
                                  context_instance=context)
    else:
        return HttpResponseRedirect('/')
Exemple #3
0
def manager_faq_add_category(request, faq):
    try:
        faq = Faq.objects.get(pk=faq)
    except Faq.DoesNotExist:
        raise Http404
    check = get_acl_for_model(Faq)
    if check.manager_faq(faq, request.user):
        initial_data = {}
        initial_data["faq"] = faq
        if request.method == "POST":
            form = FaqQuestionCategoryForm(request, request.POST, initial=initial_data)
            if form.is_valid():
                form.save()
                return HttpResponseRedirect(reverse("manager_faq_list_categories", args=[faq.pk]))
            else:
                form = FaqQuestionCategoryForm(request, request.POST, initial=initial_data)
        else:
            form = FaqQuestionCategoryForm(request, initial=initial_data)

        context = RequestContext(request)
        extra_context = {"form": form, "curcategory": False}
        extra_context["curfaq"] = Faq.objects.get(pk=faq.pk)
        return render_to_response("faq/edit_category.html", extra_context, context_instance=context)
    else:
        return HttpResponseRedirect("/")
Exemple #4
0
def manager_faq_edit_category(request, category):
    try:
        category = FaqCategory.objects.get(pk=category)
    except FaqCategory.DoesNotExist:
        raise Http404
    check = get_acl_for_model(Faq)
    if check.manager_faq(category.faq, request.user):
        if request.method == "POST":
            form = FaqQuestionCategoryForm(request, request.POST, instance=category)
            if form.is_valid():
                form.save()
                return HttpResponseRedirect(reverse("manager_faq_list_categories", args=[category.faq_id]))
            else:
                form = FaqQuestionCategoryForm(request, request.POST, instance=category)
        else:
            form = FaqQuestionCategoryForm(request, instance=category)

        context = RequestContext(request)
        extra_context = {"form": form, "curcategory": category}
        extra_context["curfaq"] = category.faq
        return render_to_response("faq/edit_category.html", extra_context, context_instance=context)
    else:
        return HttpResponseRedirect("/")