@permission_required("core.manage_shop")
def update_category_variants_option(request, export_id, category_id):
    """Stores / deletes options for the variants handling of category with
    given id.
    """
    try:
        variants_option = int(request.POST.get("variants_option"))
    except __HOLE__:
        variants_option = 0

    try:
        category = Category.objects.get(pk=category_id)
    except Category.DoesNotExist:
        return HttpResponse("")

    try:
        export = Export.objects.get(pk=export_id)
    except Export.DoesNotExist:
        return HttpResponse("")

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

    if variants_option == CATEGORY_VARIANTS_NONE:
        if category_option:
            category_option.delete()
    else:
        if category_option is None:
            CategoryOption.objects.create(
                export=export, category=category, variants_option=variants_option)
        else:
            category_option.variants_option = variants_option
            category_option.save()

    return HttpResponse("")
dataset/ETHPy150Open diefenbach/django-lfs/lfs/manage/views/export.py/update_category_variants_option