<s> from django . utils . translation import ugettext_lazy as _ <EOL> class Base ( object ) : <EOL> """<STR_LIT>""" <EOL> code = '<STR_LIT>' <EOL> message = '<STR_LIT>' <EOL> dispatch_date = None <EOL> @ property <EOL> def short_message ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . message <EOL> @ property <EOL> def is_available_to_buy ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . is_purchase_permitted ( <NUM_LIT:1> ) [ <NUM_LIT:0> ] <EOL> def is_purchase_permitted ( self , quantity ) : <EOL> """<STR_LIT>""" <EOL> return False , _ ( "<STR_LIT>" ) <EOL> class Unavailable ( Base ) : <EOL> """<STR_LIT>""" <EOL> code = '<STR_LIT>' <EOL> message = _ ( "<STR_LIT>" ) <EOL> class Available ( Base ) : <EOL> """<STR_LIT>""" <EOL> code = '<STR_LIT>' <EOL> message = _ ( "<STR_LIT>" ) <EOL> def is_purchase_permitted ( self , quantity ) : <EOL> return True , "<STR_LIT>" <EOL> class StockRequired ( Base ) : <EOL> """<STR_LIT>""" <EOL> CODE_IN_STOCK = '<STR_LIT>' <EOL> CODE_OUT_OF_STOCK = '<STR_LIT>' <EOL> def __init__ ( self , num_available ) : <EOL> self . num_available = num_available <EOL> def is_purchase_permitted ( self , quantity ) : <EOL> if self . num_available <= <NUM_LIT:0> : <EOL> return False , _ ( "<STR_LIT>" ) <EOL> if quantity > self . num_available : <EOL> msg = _ ( "<STR_LIT>" ) % { <EOL> '<STR_LIT>' : self . num_available } <EOL> return False , msg <EOL> return True , "<STR_LIT>" <EOL> @ property <EOL> def code ( self ) : <EOL> if self . num_available > <NUM_LIT:0> : <EOL> return self . CODE_IN_STOCK <EOL> return self . CODE_OUT_OF_STOCK <EOL> @ property <EOL> def short_message ( self ) : <EOL> if self . num_available > <NUM_LIT:0> : <EOL> return _ ( "<STR_LIT>" ) <EOL> return _ ( "<STR_LIT>" ) <EOL> @ property <EOL> def message ( self ) : <EOL> if self . num_available > <NUM_LIT:0> : <EOL> return _ ( "<STR_LIT>" ) % self . num_available <EOL> return _ ( "<STR_LIT>" ) </s>
