<s> from elixir import * <EOL> from utils import get_or_create <EOL> from pdb import set_trace <EOL> class Task ( Entity ) : <EOL> title = Field ( Unicode ( <NUM_LIT> ) , required = True ) <EOL> note = Field ( UnicodeText ) <EOL> tags = ManyToMany ( '<STR_LIT>' ) <EOL> priority = Field ( Float , default = <NUM_LIT:1> , required = True ) <EOL> done = Field ( Boolean , default = False , required = True ) <EOL> using_options ( tablename = '<STR_LIT>' , order_by = '<STR_LIT>' ) <EOL> def __unicode__ ( self ) : <EOL> return u'<STR_LIT>' % ( <EOL> self . title , self . priority , self . done and '<STR_LIT>' or '<STR_LIT>' , '<STR_LIT:U+002CU+0020>' . join ( map ( unicode , self . tags ) ) ) <EOL> def __repr__ ( self ) : <EOL> return u'<STR_LIT>' % ( self . title , '<STR_LIT:U+002CU+0020>' . join ( map ( unicode , self . tags ) ) ) <EOL> def setTags ( self , tags ) : <EOL> self . tags = [ get_or_create ( Tag , title = tag ) for tag in tags ] <EOL> class Tag ( Entity ) : <EOL> title = Field ( Unicode ( <NUM_LIT> ) , required = True , unique = True ) <EOL> tasks = ManyToMany ( '<STR_LIT>' ) <EOL> using_options ( tablename = '<STR_LIT>' , order_by = '<STR_LIT:title>' ) <EOL> def __unicode__ ( self ) : <EOL> return self . title <EOL> def __repr__ ( self ) : <EOL> return u'<STR_LIT>' % self . title <EOL> @ property <EOL> def open_tasks ( self ) : <EOL> return [ t for t in self . tasks if not t . done ] <EOL> @ property <EOL> def closed_tasks ( self ) : <EOL> return [ t for t in self . tasks if t . done ] </s>
