Exemple #1
0
def manage_property_group(request, id, template_name="manage/property_groups/property_group.html"):
    """Edits property group with given id.
    """
    property_group = get_object_or_404(PropertyGroup, pk=id)
    if request.method == "POST":
        form = PropertyGroupForm(instance=property_group, data=request.POST)
        if form.is_valid():
            form.save()
            return lfs.core.utils.set_message_cookie(
                url=reverse("lfs_manage_property_group", kwargs={"id": property_group.id}),
                msg=_(u"Property group has been saved."),
            )
    else:
        form = PropertyGroupForm(instance=property_group)

    return render_to_response(
        template_name,
        RequestContext(
            request,
            {
                "property_group": property_group,
                "property_groups": PropertyGroup.objects.all(),
                "properties": properties_inline(request, id),
                "products": products_tab(request, id),
                "form": form,
                "current_id": int(id),
            },
        ),
    )
Exemple #2
0
def add_property_group(request, template_name="manage/property_groups/add_property_group.html"):
    """Adds a new property group
    """
    if request.method == "POST":
        form = PropertyGroupForm(data=request.POST)
        if form.is_valid():
            property_group = form.save()
            return lfs.core.utils.set_message_cookie(
                url=reverse("lfs_manage_property_group", kwargs={"id": property_group.id}),
                msg=_(u"Property group has been added."),
            )
    else:
        form = PropertyGroupForm()

    return render_to_response(
        template_name,
        RequestContext(
            request,
            {
                "form": form,
                "property_groups": PropertyGroup.objects.all(),
                "came_from": request.REQUEST.get("came_from", reverse("lfs_manage_property_groups")),
            },
        ),
    )
Exemple #3
0
def manage_property_group(
        request,
        id,
        template_name="manage/property_groups/property_group.html"):
    """Edits property group with given id.
    """
    property_group = get_object_or_404(PropertyGroup, pk=id)
    if request.method == "POST":
        form = PropertyGroupForm(instance=property_group, data=request.POST)
        if form.is_valid():
            form.save()
            return lfs.core.utils.set_message_cookie(
                url=reverse("lfs_manage_property_group",
                            kwargs={"id": property_group.id}),
                msg=_(u"Property group has been saved."),
            )
    else:
        form = PropertyGroupForm(instance=property_group)

    return render_to_response(
        template_name,
        RequestContext(
            request, {
                "property_group": property_group,
                "property_groups": PropertyGroup.objects.all(),
                "properties": properties_inline(request, id),
                "products": products_tab(request, id),
                "form": form,
                "current_id": int(id),
            }))
Exemple #4
0
def add_property_group(
        request,
        template_name="manage/property_groups/add_property_group.html"):
    """Adds a new property group
    """
    if request.method == "POST":
        form = PropertyGroupForm(data=request.POST)
        if form.is_valid():
            property_group = form.save()
            return lfs.core.utils.set_message_cookie(
                url=reverse("lfs_manage_property_group",
                            kwargs={"id": property_group.id}),
                msg=_(u"Property group has been added."),
            )
    else:
        form = PropertyGroupForm()

    return render_to_response(
        template_name,
        RequestContext(
            request, {
                "form":
                form,
                "property_groups":
                PropertyGroup.objects.all(),
                "came_from":
                request.REQUEST.get("came_from",
                                    reverse("lfs_manage_property_groups")),
            }))