Пример #1
0
def manage_static_block(request,
                        id,
                        template_name="manage/static_block/static_block.html"):
    """Displays the main form to manage static blocks.
    """
    sb = get_object_or_404(StaticBlock, pk=id)
    if request.method == "POST":
        form = StaticBlockForm(instance=sb, data=request.POST)
        if form.is_valid():
            form.save()
            return muecke.core.utils.set_message_cookie(
                url=reverse("muecke_manage_static_block", kwargs={"id":
                                                                  sb.id}),
                msg=_(u"Static block has been saved."),
            )
    else:
        form = StaticBlockForm(instance=sb)

    return render_to_response(
        template_name,
        RequestContext(
            request, {
                "static_block": sb,
                "static_blocks": StaticBlock.objects.all(),
                "files": files(request, sb),
                "form": form,
                "current_id": int(id),
            }))
Пример #2
0
def add_static_block(request, template_name="manage/static_block/add_static_block.html"):
    """Provides a form to add a new static block.
    """
    if request.method == "POST":
        form = StaticBlockForm(data=request.POST)
        if form.is_valid():
            new_sb = form.save()
            return muecke.core.utils.set_message_cookie(
                url=reverse("muecke_manage_static_block", kwargs={"id": new_sb.id}),
                msg=_(u"Static block has been added."),
            )
    else:
        form = StaticBlockForm()

    return render_to_response(template_name, RequestContext(request, {
        "form": form,
        "static_blocks": StaticBlock.objects.all(),
        "came_from": request.REQUEST.get("came_from", reverse("muecke_manage_static_blocks")),
    }))
Пример #3
0
def add_static_block(request,
                     template_name="manage/static_block/add_static_block.html"
                     ):
    """Provides a form to add a new static block.
    """
    if request.method == "POST":
        form = StaticBlockForm(data=request.POST)
        if form.is_valid():
            new_sb = form.save()
            return muecke.core.utils.set_message_cookie(
                url=reverse("muecke_manage_static_block",
                            kwargs={"id": new_sb.id}),
                msg=_(u"Static block has been added."),
            )
    else:
        form = StaticBlockForm()

    return render_to_response(
        template_name,
        RequestContext(
            request, {
                "form":
                form,
                "static_blocks":
                StaticBlock.objects.all(),
                "came_from":
                request.REQUEST.get("came_from",
                                    reverse("muecke_manage_static_blocks")),
            }))
Пример #4
0
def manage_static_block(request, id, template_name="manage/static_block/static_block.html"):
    """Displays the main form to manage static blocks.
    """
    sb = get_object_or_404(StaticBlock, pk=id)
    if request.method == "POST":
        form = StaticBlockForm(instance=sb, data=request.POST)
        if form.is_valid():
            form.save()
            return muecke.core.utils.set_message_cookie(
                url=reverse("muecke_manage_static_block", kwargs={"id": sb.id}),
                msg=_(u"Static block has been saved."),
            )
    else:
        form = StaticBlockForm(instance=sb)

    return render_to_response(template_name, RequestContext(request, {
        "static_block": sb,
        "static_blocks": StaticBlock.objects.all(),
        "files": files(request, sb),
        "form": form,
        "current_id": int(id),
    }))