<s> from sellmo . apps . product . models import Product <EOL> from sellmo . apps . pricing . helpers import price_field_names <EOL> from sellmo . contrib . category . admin import ( ProductCategoryListFilter , <EOL> ProductCategoriesMixin ) <EOL> from sellmo . contrib . variation . admin import ( VariantAttributeMixin , <EOL> ProductVariationMixin ) <EOL> from sellmo . contrib . attribute . admin import ProductAttributeMixin <EOL> from sellmo . contrib . tax . admin import ProductTaxClassesMixin <EOL> from sellmo . contrib . discount . admin import ProductDiscountsMixin <EOL> from sellmo . contrib . product . pricing . qty_pricing . models import ProductQtyPrice <EOL> from sellmo . contrib . product . subtypes . simple_product . models import SimpleProduct <EOL> from sellmo . contrib . product . subtypes . configurable_product . models import ConfigurableProduct <EOL> from sellmo . contrib . variation . models import ( SimpleProductVariant , <EOL> ConfigurableProductVariant ) <EOL> from django . contrib import admin <EOL> from django . db import models <EOL> from django . contrib . contenttypes . models import ContentType <EOL> from django . utils . translation import ugettext_lazy as _ <EOL> from sorl . thumbnail import get_thumbnail <EOL> from extras . admin . polymorphism import PolymorphicParentModelAdmin , PolymorphicChildModelAdmin <EOL> import logging <EOL> logger = logging . getLogger ( __name__ ) <EOL> class ProductQtyPriceInline ( admin . TabularInline ) : <EOL> model = ProductQtyPrice <EOL> class ProductChildAdmin ( <EOL> ProductTaxClassesMixin , <EOL> ProductDiscountsMixin , <EOL> ProductCategoriesMixin , <EOL> ProductAttributeMixin , <EOL> ProductVariationMixin , <EOL> PolymorphicChildModelAdmin ) : <EOL> base_model = Product <EOL> inlines = [ ProductQtyPriceInline ] <EOL> fieldsets = ( <EOL> ( _ ( "<STR_LIT>" ) , { <EOL> '<STR_LIT>' : ( '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> } ) , <EOL> ( _ ( "<STR_LIT>" ) , { <EOL> '<STR_LIT>' : ( tuple ( price_field_names ( '<STR_LIT>' , multi_currency = True , components = None ) ) , '<STR_LIT>' , '<STR_LIT>' ) <EOL> } ) , <EOL> ( _ ( "<STR_LIT>" ) , { <EOL> '<STR_LIT>' : ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , ) <EOL> } ) , <EOL> ( _ ( "<STR_LIT>" ) , { <EOL> '<STR_LIT>' : ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , ) <EOL> } ) , <EOL> ) <EOL> filter_horizontal = [ '<STR_LIT>' ] <EOL> prepopulated_fields = { <EOL> '<STR_LIT>' : ( '<STR_LIT:name>' , ) , <EOL> } <EOL> raw_id_fields = [ '<STR_LIT>' ] <EOL> autocomplete_lookup_fields = { <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> } <EOL> class VariantInline ( VariantAttributeMixin , admin . StackedInline ) : <EOL> fieldsets = ( <EOL> ( _ ( "<STR_LIT>" ) , { <EOL> '<STR_LIT>' : ( '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , ) <EOL> } ) , <EOL> ( _ ( "<STR_LIT>" ) , { <EOL> '<STR_LIT>' : ( '<STR_LIT>' , ) <EOL> } ) , <EOL> ( _ ( "<STR_LIT>" ) , { <EOL> '<STR_LIT>' : ( tuple ( price_field_names ( '<STR_LIT>' , multi_currency = True , components = None ) ) , ) <EOL> } ) , <EOL> ) <EOL> class ProductParentAdmin ( PolymorphicParentModelAdmin ) : <EOL> base_model = Product <EOL> polymorphic_list = False <EOL> list_display = [ '<STR_LIT>' ] <EOL> list_display_links = [ '<STR_LIT>' ] <EOL> search_fields = [ '<STR_LIT>' ] <EOL> child_models = [ ] <EOL> list_display = [ '<STR_LIT>' , '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> list_display_links = [ '<STR_LIT:name>' , '<STR_LIT>' ] <EOL> list_editable = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> list_filter = [ ProductCategoryListFilter , '<STR_LIT>' , '<STR_LIT>' ] <EOL> search_fields = [ '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> def get_queryset ( self , queryset ) : <EOL> return Product . objects . variants ( exclude = True ) <EOL> def thumbnail ( self , instance ) : <EOL> if instance . main_image : <EOL> try : <EOL> thumbnail = get_thumbnail ( instance . main_image , '<STR_LIT>' , crop = '<STR_LIT>' , quality = <NUM_LIT:100> ) <EOL> return '<STR_LIT>' % ( thumbnail . url ) <EOL> except IOError as ex : <EOL> logger . warning ( ex ) <EOL> return '<STR_LIT>' <EOL> thumbnail . allow_tags = True <EOL> thumbnail . short_description = _ ( "<STR_LIT>" ) <EOL> admin . site . register ( Product , ProductParentAdmin ) <EOL> class SimpleVariantInline ( VariantInline ) : <EOL> model = SimpleProductVariant <EOL> fk_name = '<STR_LIT>' <EOL> class SimpleProductAdmin ( ProductChildAdmin ) : <EOL> inlines = ProductChildAdmin . inlines + [ SimpleVariantInline ] <EOL> class ConfigurableVariantInline ( VariantInline ) : <EOL> model = ConfigurableProductVariant <EOL> fk_name = '<STR_LIT>' <EOL> class ConfigurableProductAdmin ( ProductChildAdmin ) : <EOL> inlines = ProductChildAdmin . inlines + [ ConfigurableVariantInline ] <EOL> ProductParentAdmin . child_models += [ <EOL> ( SimpleProduct , SimpleProductAdmin ) , <EOL> ( ConfigurableProduct , ConfigurableProductAdmin ) ] </s>
