<commit_before># -*- coding:utf-8 -*-
from django.conf import settings
from django.contrib import admin
import django.db.models
from django.db.models.query import EmptyQuerySet

from satchless.contrib.pricing import simpleqty
import satchless.product.models
import satchless.product.admin
import sale.models

from . import models
from . import widgets

class TranslationInline(admin.StackedInline):
    extra = 1
    max_num = len(settings.LANGUAGES) - 1


class CategoryTranslationInline(TranslationInline):
    model = models.CategoryTranslation


class ImageInline(admin.TabularInline):
    formfield_overrides = {
        django.db.models.ImageField: { 'widget': widgets.AdminImageWidget },
    }


class ProductForm(satchless.product.admin.ProductForm):
    def __init__(self, *args, **kwargs):
        super(ProductForm, self).__init__(*args, **kwargs)
        if self.instance.id:
            self.fields['main_image'].queryset = (models.ProductImage.objects
                                                        .filter(product=self.instance))
        else:
            self.fields['main_image'].queryset = EmptyQuerySet(model=models.ProductImage)


class ProductAdmin(satchless.product.admin.ProductAdmin):
    form = ProductForm


class ProductImageInline(ImageInline):
    extra = 4
    max_num = 4
    model = models.ProductImage
    sortable_field_name = "order"


class PriceInline(admin.TabularInline):
    model = simpleqty.models.ProductPrice


class DiscountInline(admin.TabularInline):
    model = sale.models.DiscountGroup.products.through
    max_num = 1


class CardiganVariantInline(admin.TabularInline):
    model = models.CardiganVariant


class CardiganTranslationInline(TranslationInline):
    model = models.CardiganTranslation


class CardiganAdmin(ProductAdmin):
    inlines = [CardiganTranslationInline, CardiganVariantInline, ProductImageInline]


class DressVariantInline(admin.TabularInline):
    model = models.DressVariant


class DressTranslationInline(TranslationInline):
    model = models.DressTranslation


class DressAdmin(ProductAdmin):
    inlines = [DressTranslationInline, DressVariantInline, PriceInline,
               DiscountInline, ProductImageInline]<commit_msg>Demo shop: use the correct form for price inline<commit_after># -*- coding:utf-8 -*-
from django.conf import settings
from django.contrib import admin
import django.db.models
from django.db.models.query import EmptyQuerySet

from satchless.contrib.pricing import simpleqty
import satchless.product.models
import satchless.product.admin
import sale.models

from . import models
from . import widgets

class TranslationInline(admin.StackedInline):
    extra = 1
    max_num = len(settings.LANGUAGES) - 1


class CategoryTranslationInline(TranslationInline):
    model = models.CategoryTranslation


class ImageInline(admin.TabularInline):
    formfield_overrides = {
        django.db.models.ImageField: { 'widget': widgets.AdminImageWidget },
    }


class ProductForm(satchless.product.admin.ProductForm):
    def __init__(self, *args, **kwargs):
        super(ProductForm, self).__init__(*args, **kwargs)
        if self.instance.id:
            self.fields['main_image'].queryset = (models.ProductImage.objects
                                                        .filter(product=self.instance))
        else:
            self.fields['main_image'].queryset = EmptyQuerySet(model=models.ProductImage)


class ProductAdmin(satchless.product.admin.ProductAdmin):
    form = ProductForm


class ProductImageInline(ImageInline):
    extra = 4
    max_num = 4
    model = models.ProductImage
    sortable_field_name = "order"


class PriceInline(admin.TabularInline):
    model = simpleqty.models.ProductPrice
    form = simpleqty.admin.ProductPriceForm


class DiscountInline(admin.TabularInline):
    model = sale.models.DiscountGroup.products.through
    max_num = 1


class CardiganVariantInline(admin.TabularInline):
    model = models.CardiganVariant


class CardiganTranslationInline(TranslationInline):
    model = models.CardiganTranslation


class CardiganAdmin(ProductAdmin):
    inlines = [CardiganTranslationInline, CardiganVariantInline, ProductImageInline]


class DressVariantInline(admin.TabularInline):
    model = models.DressVariant


class DressTranslationInline(TranslationInline):
    model = models.DressTranslation


class DressAdmin(ProductAdmin):
    inlines = [DressTranslationInline, DressVariantInline, PriceInline,
               DiscountInline, ProductImageInline]
{'fraction_non_alphanumeric': 0.08512524939037908, 'fraction_numerical': 0.002660164043449346, 'mean_word_length': 3.9473684210526314, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6420287', 'n_tokens_mistral': 1251, 'n_tokens_neox': 1255, 'n_words': 249}