Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.19 KB | None | 0 0
  1.  
  2. class Book(Model):
  3.     __tablename__ = 'BookCart'
  4.     title = CharField(max_length=256)
  5.     authors = ManyToManyField('Author')
  6.     series = ForeignKey('Series', null=True)
  7.     sub_genres = ManyToManyField('SubGenre')
  8.  
  9.  
  10. class BookPublication(Model):
  11.     """ Abstract class for relate book and publication of two types (paper, electronic) """
  12.  
  13.     class Meta:
  14.         abstract = True
  15.  
  16.     book = ForeignKey('Book', null=False)
  17.     year_of_publishing = IntegerField()
  18.     annotation = TextField()
  19.  
  20.  
  21. class BookPublicationPaper(BookPublication):
  22.     __tablename__ = 'BookPaper'
  23.     isbn = IntegerField()
  24.     count_of_pages = IntegerField()
  25.     physical_type = CharField(max_length=64)
  26.     location = CharField(max_length=128)
  27.  
  28.  
  29. class BookPublicationElectronic(BookPublication):
  30.     __tablename__ = 'BookElectronic'
  31.     cover_local_path = FilePathField()
  32.     path_to_file = FilePathField()
  33.  
  34.  
  35. class OwnedBook(Model):
  36.     """ Book in your collection. For relation to quotes, diary, etc.    """
  37.     __tablename__ = 'OwnedBook'
  38.     publication = ForeignKey('BookPublication')
  39.     tags = ManyToManyField('Tag')
  40.     reviews = ManyToManyField('Review')
  41.     quote = ManyToManyField('Quote')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement