Manage ASL magazines and their articles.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
asl-articles/asl_articles/models.py

72 lines
3.1 KiB

""" Define the database models. """
from asl_articles import db
#pylint: disable=no-member
# ---------------------------------------------------------------------
class Publisher( db.Model ):
"""Define the Publisher model."""
publ_id = db.Column( db.Integer, primary_key=True )
publ_name = db.Column( db.String(100), nullable=False )
publ_description = db.Column( db.String(1000), nullable=True )
publ_url = db.Column( db.String(500), nullable=True )
# NOTE: time_created should be non-nullable, but getting this to work on SQlite and Postgres
# is more trouble than it's worth :-/
time_created = db.Column( db.TIMESTAMP(timezone=True), nullable=True )
time_updated = db.Column( db.TIMESTAMP(timezone=True), nullable=True )
#
children = db.relationship( "Publication", backref="parent", passive_deletes=True )
def __repr__( self ):
return "<Publisher:{}|{}>".format( self.publ_id, self.publ_name )
# ---------------------------------------------------------------------
class Publication( db.Model ):
"""Define the Publication model."""
pub_id = db.Column( db.Integer, primary_key=True )
pub_name = db.Column( db.String(100), nullable=False )
pub_edition = db.Column( db.String(100), nullable=True )
pub_description = db.Column( db.String(1000), nullable=True )
pub_url = db.Column( db.String(500), nullable=True )
pub_tags = db.Column( db.String(1000), nullable=True )
publ_id = db.Column( db.Integer,
db.ForeignKey( Publisher.__table__.c.publ_id, ondelete="CASCADE" ),
nullable=True
)
# NOTE: time_created should be non-nullable, but getting this to work on SQlite and Postgres
# is more trouble than it's worth :-/
time_created = db.Column( db.TIMESTAMP(timezone=True), nullable=True )
time_updated = db.Column( db.TIMESTAMP(timezone=True), nullable=True )
#
children = db.relationship( "Article", backref="parent", passive_deletes=True )
def __repr__( self ):
return "<Publication:{}|{}>".format( self.pub_id, self.pub_name )
# ---------------------------------------------------------------------
class Article( db.Model ):
"""Define the Article model."""
article_id = db.Column( db.Integer, primary_key=True )
article_title = db.Column( db.String(200), nullable=False )
article_subtitle = db.Column( db.String(200), nullable=True )
article_snippet = db.Column( db.String(5000), nullable=True )
article_url = db.Column( db.String(500), nullable=True )
article_tags = db.Column( db.String(1000), nullable=True )
pub_id = db.Column( db.Integer,
db.ForeignKey( Publication.__table__.c.pub_id, ondelete="CASCADE" ),
nullable=True
)
# NOTE: time_created should be non-nullable, but getting this to work on SQlite and Postgres
# is more trouble than it's worth :-/
time_created = db.Column( db.TIMESTAMP(timezone=True), nullable=True )
time_updated = db.Column( db.TIMESTAMP(timezone=True), nullable=True )
def __repr__( self ):
return "<Article:{}|{}>".format( self.article_id, self.article_title )