@permission_required("core.manage_shop")
def export_inline(request, export_id, category_id,
    template_name="manage/export/export_inline.html"):
    """Returns categories and products for given export id and category id.
    """
    export = Export.objects.get(pk=export_id)
    selected_products = export.products.all()

    products = []
    for product in Product.objects.filter(sub_type__in=[STANDARD_PRODUCT, PRODUCT_WITH_VARIANTS], categories__in=[category_id], active=True):

        if product.is_standard():
            type = "P"
        else:
            type = "V"

        products.append({
            "id": product.id,
            "name": product.get_name(),
            "checked": product in selected_products,
            "type": type,
        })

    categories = []
    for category in Category.objects.filter(parent=category_id):

        # Options
        options = []

        try:
            category_option = CategoryOption.objects.get(export=export, category=category)
        except CategoryOption.DoesNotExist:
            variants_option = None
        else:
            variants_option = category_option.variants_option

        for option in CATEGORY_VARIANTS_CHOICES:
            options.append({
                "name": option[1],
                "value": option[0],
                "selected": option[0] == variants_option,
            })

        checked, klass = _get_category_state(export, category)

        categories.append({
            "id": category.id,
            "name": category.name,
            "checked": checked,
            "klass": klass,
            "options": options,
        })

    result = render_to_string(template_name, RequestContext(request, {
        "categories": categories,
        "products": products,
        "export_id": export_id,
    }))

    html = ((category_id % "#sub-categories-%s", result),)

    return HttpResponse(
        json.dumps({"html": html}), content_type='application/json')
dataset/ETHPy150Open diefenbach/django-lfs/lfs/manage/views/export.py/export_inline/swapped operands of `%`