<s> from django . db import models <EOL> from django . db . models import permalink <EOL> from django . conf import settings <EOL> from django . contrib . auth . models import User <EOL> from basic . people . models import Person <EOL> class Genre ( models . Model ) : <EOL> """<STR_LIT>""" <EOL> title = models . CharField ( max_length = <NUM_LIT:100> ) <EOL> slug = models . SlugField ( unique = True ) <EOL> class Meta : <EOL> db_table = '<STR_LIT>' <EOL> ordering = ( '<STR_LIT:title>' , ) <EOL> def __unicode__ ( self ) : <EOL> return '<STR_LIT:%s>' % self . title <EOL> @ permalink <EOL> def get_absolute_url ( self ) : <EOL> return ( '<STR_LIT>' , None , { '<STR_LIT>' : self . slug } ) <EOL> class Publisher ( models . Model ) : <EOL> """<STR_LIT>""" <EOL> title = models . CharField ( max_length = <NUM_LIT:100> ) <EOL> prefix = models . CharField ( max_length = <NUM_LIT:20> , blank = True ) <EOL> slug = models . SlugField ( unique = True ) <EOL> website = models . URLField ( blank = True ) <EOL> class Meta : <EOL> db_table = '<STR_LIT>' <EOL> ordering = ( '<STR_LIT:title>' , ) <EOL> def __unicode__ ( self ) : <EOL> return '<STR_LIT:%s>' % self . full_title <EOL> @ property <EOL> def full_title ( self ) : <EOL> return '<STR_LIT>' % ( self . prefix , self . title ) <EOL> @ permalink <EOL> def get_absolute_url ( self ) : <EOL> return ( '<STR_LIT>' , None , { '<STR_LIT>' : self . slug } ) <EOL> class Book ( models . Model ) : <EOL> """<STR_LIT>""" <EOL> title = models . CharField ( max_length = <NUM_LIT:255> ) <EOL> prefix = models . CharField ( max_length = <NUM_LIT:20> , blank = True ) <EOL> subtitle = models . CharField ( blank = True , max_length = <NUM_LIT:255> ) <EOL> slug = models . SlugField ( unique = True ) <EOL> authors = models . ManyToManyField ( Person , limit_choices_to = { '<STR_LIT>' : '<STR_LIT>' } , related_name = '<STR_LIT>' ) <EOL> isbn = models . CharField ( max_length = <NUM_LIT> , blank = True ) <EOL> pages = models . PositiveSmallIntegerField ( blank = True , null = True , default = <NUM_LIT:0> ) <EOL> publisher = models . ForeignKey ( Publisher , blank = True , null = True ) <EOL> published = models . DateField ( blank = True , null = True ) <EOL> cover = models . FileField ( upload_to = '<STR_LIT>' , blank = True ) <EOL> description = models . TextField ( blank = True ) <EOL> genre = models . ManyToManyField ( Genre , blank = True ) <EOL> created = models . DateTimeField ( auto_now_add = True ) <EOL> modified = models . DateTimeField ( auto_now = True ) <EOL> class Meta : <EOL> db_table = '<STR_LIT>' <EOL> ordering = ( '<STR_LIT:title>' , ) <EOL> def __unicode__ ( self ) : <EOL> return '<STR_LIT:%s>' % self . full_title <EOL> @ property <EOL> def full_title ( self ) : <EOL> if self . prefix : <EOL> return '<STR_LIT>' % ( self . prefix , self . title ) <EOL> else : <EOL> return '<STR_LIT:%s>' % self . title <EOL> @ permalink <EOL> def get_absolute_url ( self ) : <EOL> return ( '<STR_LIT>' , None , { '<STR_LIT>' : self . slug } ) <EOL> @ property <EOL> def amazon_url ( self ) : <EOL> if self . isbn : <EOL> try : <EOL> return '<STR_LIT>' % ( self . isbn , settings . AMAZON_AFFILIATE_EXTENTION ) <EOL> except : <EOL> return '<STR_LIT>' % self . isbn <EOL> return '<STR_LIT>' <EOL> class Highlight ( models . Model ) : <EOL> """<STR_LIT>""" <EOL> user = models . ForeignKey ( User ) <EOL> book = models . ForeignKey ( Book ) <EOL> highlight = models . TextField ( ) <EOL> page = models . CharField ( blank = True , max_length = <NUM_LIT:20> ) <EOL> created = models . DateTimeField ( auto_now_add = True ) <EOL> modified = models . DateTimeField ( auto_now = True ) <EOL> class Meta : <EOL> db_table = '<STR_LIT>' <EOL> def __unicode__ ( self ) : <EOL> return '<STR_LIT:%s>' % self . highlight <EOL> @ permalink <EOL> def get_absolute_url ( self ) : <EOL> return ( '<STR_LIT>' , None , { '<STR_LIT>' : self . book . slug } ) <EOL> class Page ( models . Model ) : <EOL> """<STR_LIT>""" <EOL> user = models . ForeignKey ( User ) <EOL> book = models . ForeignKey ( Book ) <EOL> current_page = models . PositiveSmallIntegerField ( default = <NUM_LIT:0> ) <EOL> created = models . DateTimeField ( auto_now_add = True ) <EOL> class Meta : <EOL> db_table = '<STR_LIT>' <EOL> ordering = ( '<STR_LIT>' , ) <EOL> def __unicode__ ( self ) : <EOL> return '<STR_LIT:%s>' % self . current_page </s>
