added path type via new path.py to avoid more circular imports
This commit is contained in:
30
path.py
Normal file
30
path.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from flask_wtf import FlaskForm
|
||||
from main import db, app, ma
|
||||
from sqlalchemy import Sequence
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
|
||||
# pylint: disable=no-member
|
||||
|
||||
################################################################################
|
||||
# Class describing File in the database, and via sqlalchemy, connected to the DB as well
|
||||
# This has to match one-for-one the DB table
|
||||
################################################################################
|
||||
class PathType(db.Model):
|
||||
__tablename__ = "path_type"
|
||||
id = db.Column(db.Integer, db.Sequence('path_type_id_seq'), primary_key=True )
|
||||
name = db.Column(db.String, unique=True, nullable=False )
|
||||
|
||||
def __repr__(self):
|
||||
return "<id: {}, name={}>".format(self.id, self.name )
|
||||
|
||||
class Path(db.Model):
|
||||
__tablename__ = "path"
|
||||
id = db.Column(db.Integer, db.Sequence('path_id_seq'), primary_key=True )
|
||||
type_id = db.Column(db.Integer, db.ForeignKey("path_type.id"))
|
||||
type = db.relationship("PathType")
|
||||
path_prefix = db.Column(db.String, unique=True, nullable=False )
|
||||
num_files = db.Column(db.Integer)
|
||||
|
||||
def __repr__(self):
|
||||
return f"<id: {self.id}, path_prefix: {self.path_prefix}, num_files={self.num_files}>"
|
||||
|
||||
Reference in New Issue
Block a user