<s> from functools import partial <EOL> from sellmo . contrib . attribute . admin import BaseProductAttributeMixin <EOL> from django import forms <EOL> from django . forms import ValidationError <EOL> from django . forms . models import ModelForm <EOL> from django . contrib import admin <EOL> from django . utils . translation import ugettext_lazy as _ <EOL> from django . utils . text import capfirst <EOL> from django . utils import six <EOL> from django . contrib . admin . sites import NotRegistered <EOL> from django . contrib . contenttypes . models import ContentType <EOL> from . forms import ( <EOL> VariantAttributeFormFactory , VariantAttributeFormMixin , <EOL> ProductVariationFormFactory , ProductVariationFormMixin <EOL> ) <EOL> class VariantAttributeMixin ( BaseProductAttributeMixin ) : <EOL> def get_form ( self , request , obj = None , ** kwargs ) : <EOL> kwargs [ '<STR_LIT>' ] = ( <EOL> self . get_attribute_formfactory ( <EOL> request , <EOL> VariantAttributeFormFactory , <EOL> prefix = '<STR_LIT>' , <EOL> mixin = VariantAttributeFormMixin , <EOL> obj = obj , <EOL> ** kwargs <EOL> ) . factory ( ) <EOL> ) <EOL> return super ( VariantAttributeMixin , self ) . get_form ( <EOL> request , <EOL> obj = obj , <EOL> ** kwargs <EOL> ) <EOL> def get_formset ( self , request , obj = None , ** kwargs ) : <EOL> kwargs [ '<STR_LIT>' ] = ( <EOL> self . get_attribute_formfactory ( <EOL> request , <EOL> VariantAttributeFormFactory , <EOL> prefix = '<STR_LIT>' , <EOL> mixin = VariantAttributeFormMixin , <EOL> obj = obj , <EOL> ** kwargs <EOL> ) . factory ( ) <EOL> ) <EOL> return super ( VariantAttributeMixin , self ) . get_formset ( <EOL> request , <EOL> obj = obj , <EOL> ** kwargs <EOL> ) <EOL> def get_fieldsets ( self , request , obj = None ) : <EOL> fieldsets = super ( VariantAttributeMixin , self ) . get_fieldsets ( <EOL> request , obj <EOL> ) <EOL> fields = ( <EOL> self . get_attribute_formfactory ( <EOL> request , <EOL> VariantAttributeFormFactory , <EOL> prefix = '<STR_LIT>' , <EOL> mixin = VariantAttributeFormMixin , <EOL> obj = obj <EOL> ) . get_attribute_formfield_names ( ) <EOL> ) <EOL> fieldsets += ( ( _ ( "<STR_LIT>" ) , { '<STR_LIT>' : fields } ) , ) <EOL> return fieldsets <EOL> class ProductVariationMixin ( BaseProductAttributeMixin ) : <EOL> def get_form ( self , request , obj = None , ** kwargs ) : <EOL> kwargs [ '<STR_LIT>' ] = ( <EOL> self . get_attribute_formfactory ( <EOL> request , <EOL> ProductVariationFormFactory , <EOL> prefix = '<STR_LIT>' , <EOL> mixin = ProductVariationFormMixin , <EOL> obj = obj , <EOL> ** kwargs <EOL> ) . factory ( ) <EOL> ) <EOL> return super ( ProductVariationMixin , self ) . get_form ( <EOL> request , <EOL> obj = obj , <EOL> ** kwargs <EOL> ) <EOL> def save_model ( self , request , obj , form , change ) : <EOL> obj . save ( ) <EOL> form . save_variations ( ) <EOL> def get_fieldsets ( self , request , obj = None ) : <EOL> fieldsets = super ( ProductVariationMixin , self ) . get_fieldsets ( <EOL> request , obj <EOL> ) <EOL> fields = ( <EOL> self . get_attribute_formfactory ( <EOL> request , <EOL> ProductVariationFormFactory , <EOL> prefix = '<STR_LIT>' , <EOL> mixin = ProductVariationFormMixin , <EOL> obj = obj <EOL> ) . get_attribute_formfield_names ( ) <EOL> ) <EOL> fieldsets += ( ( _ ( "<STR_LIT>" ) , { '<STR_LIT>' : fields } ) , ) <EOL> return fieldsets </s>
