<s> from django . core import exceptions <EOL> from django . db import IntegrityError <EOL> from oscar . apps . offer . models import Benefit , Condition <EOL> from oscar . core . loading import get_model <EOL> Range = get_model ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def _class_path ( klass ) : <EOL> return '<STR_LIT>' % ( klass . __module__ , klass . __name__ ) <EOL> def create_range ( range_class ) : <EOL> """<STR_LIT>""" <EOL> if not hasattr ( range_class , '<STR_LIT:name>' ) : <EOL> raise exceptions . ValidationError ( <EOL> "<STR_LIT>" ) <EOL> if range_class . name . __class__ . __name__ == '<STR_LIT>' : <EOL> raise exceptions . ValidationError ( <EOL> "<STR_LIT>" ) <EOL> try : <EOL> return Range . objects . create ( <EOL> name = range_class . name , proxy_class = _class_path ( range_class ) ) <EOL> except IntegrityError : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> def create_condition ( condition_class , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> return Condition . objects . create ( <EOL> proxy_class = _class_path ( condition_class ) , ** kwargs ) <EOL> def create_benefit ( benefit_class , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if benefit_class . description is Benefit . description : <EOL> raise RuntimeError ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> return Benefit . objects . create ( <EOL> proxy_class = _class_path ( benefit_class ) , ** kwargs ) </s>
