class Advisor(db.Model): __tablename__ = 'advisor' id = db.Column(db.Integer, primary_key=True) user_id = db.Column(db.Integer, nullable=False) department_id = db.Column(db.Integer, nullable=True) employment_date=db.Column(db.Date, nullable=True) dismissal_date=db.Column(db.Date, nullable=True)
class Expression(db.Model): __tablename__ = 'expression' id_expression = db.Column(db.Integer, primary_key=True) expression_name = db.Column(db.String(20), nullable=False) created_at = db.Column(db.DateTime, default=datetime.datetime.now()) def __repr__(self): return '<expression {0}>'.format(self.expression_name)
class Admin(db.Model): __tablename__ = 'admin' id_admin = db.Column(db.Integer, primary_key=True) username = db.Column(db.String, unique=True, nullable=False) password = db.Column(db.String, nullable=False) def __repr__(self): return '<Admin {0}>'.format(self.username)
class User(db.Model): __tablename__ = 'user' id_user = db.Column(db.Integer, primary_key=True) username = db.Column(db.String, unique=True, nullable=False) password = db.Column(db.String, nullable=False) created_at = db.Column(db.DateTime, default=datetime.datetime.now()) def __repr__(self): return '<User {0}>'.format(self.username)
class Detection(db.Model): __tablename__ = 'detection' id_detection = db.Column(db.Integer, primary_key=True) id_result_detection = db.Column(db.Integer, db.ForeignKey('result_detection.id_result_detection')) id_photo = db.Column(db.Integer, db.ForeignKey('photos.id_photo')) time_detected = db.Column(db.Float, nullable=False) result_expression = db.Column(db.Integer, db.ForeignKey('expression.id_expression')) def __repr__(self): return '<Detection {0}>'.format(self.id_detection)
class DetectionPhoto(db.Model): __tablename__ = 'detection_photo' id_detection_photo = db.Column(db.Integer, primary_key=True) id_result_detection = db.Column( db.Integer, db.ForeignKey('result_detection.id_result_detection')) id_photo = db.Column(db.Integer, db.ForeignKey('photos.id_photo')) result_expression = db.Column(db.Integer, db.ForeignKey('expression.id_expression')) def __repr__(self): return '<Detection Photo {0}>'.format(self.id_detection_photo)
class ResultDetection(db.Model): __tablename__ = 'result_detection' id_result_detection = db.Column(db.Integer, primary_key=True) created_at = db.Column(db.DateTime, default=datetime.datetime.now()) id_user = db.Column(db.Integer, db.ForeignKey('user.id_user')) def get_id_result_detection(self): return self.id def __repr__(self): return '<ResultDetection {0}>'.format(self.id_result_detection)
class EditableHTML(db.Model): id = db.Column(db.Integer, primary_key=True) editor_name = db.Column(db.String(100), unique=True) value = db.Column(db.Text) @staticmethod def get_editable_html(editor_name): editable_html_obj = EditableHTML.query.filter_by( editor_name=editor_name).first() if editable_html_obj is None: editable_html_obj = EditableHTML(editor_name=editor_name, value='') return editable_html_obj
class Post(db.Model): __tablename__ = 'posts' id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(140)) slug = db.Column(db.String(80)) content = db.Column(db.Text) created = db.Column(db.DateTime) modified = db.Column(db.DateTime) def __init__(self, title, content): self.title = title self.slug = slugify(title) self.content = content self.created = datetime.datetime.now() self.modified = datetime.datetime.now() def __repr__(self): return '<Post %r>' % self.id @property def serialize(self): return { 'id': self.id, 'title': self.title, 'slug': self.slug, 'created': self.created.strftime("%s"), 'modified': self.modified.strftime("%s") }
class UserDepartment(db.Model): __tablename__ = 'user_department' id = db.Column(db.Integer, primary_key=True) user_id = db.Column(db.Integer, nullable=False) department_id = db.Column(db.Integer, nullable=True) post = db.Column(db.VARCHAR(200), nullable=False) employment_date = db.Column(db.Date, nullable=True) dismissal_date = db.Column(db.Date, nullable=True) __table_args__ = (db.ForeignKeyConstraint( ['user_id'], ['user.id'], name='users_tag_maps_department_id_fk'), )
class User(db.Model, ConfigModel, UserMixin): __tablename__ = 'auth_user' date_joined = db.Column(db.DateTime, default=datetime.datetime.utcnow()) id = Column(Integer, primary_key=True, autoincrement=True) email = Column(String, default="") first_name = Column(String, default="") last_name = Column(String, default="") username = Column(String, nullable=False) password = Column(String, nullable=False) is_superuser = Column(Boolean, default=False) is_staff = Column(Boolean, default=False) is_active = Column(Boolean, default=True) def __init__(self, username, password): from project import bcrypt self.username = username self.password = bcrypt.generate_password_hash(password, 13).decode()
class User(db.Model): __tablename__ = 'user' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.VARCHAR(200), nullable=False) surname = db.Column(db.VARCHAR(200), nullable=False) email = db.Column(db.VARCHAR(200), nullable=False, unique=True) phone = db.Column(db.VARCHAR(200), nullable=False) password = db.Column(db.VARCHAR(200), nullable=False) user_departments = db.relationship('UserDepartment') def get_role(self): return UserDepartment.query.filter(UserDepartment.user_id == self.id).filter( UserDepartment.dismissal_date == None).first().post
class Photos(db.Model): __tablename__ = 'photos' id_photo = db.Column(db.Integer, primary_key=True) photo_name = db.Column(db.String(100), nullable=False) photo_url = db.Column(db.String(255), nullable=False, unique=True) source_url = db.Column(db.String(255), nullable=True, unique=True) comment_impression = db.Column(db.Integer, db.ForeignKey('expression.id_expression')) created_at = db.Column(db.DateTime, default=datetime.datetime.now()) def get_id_photo(self): return self.id_photo def __repr__(self): return '<Photos {0}>'.format(self.photo_name)
class Colors(db.Model, ConfigModel, UserMixin): __tablename__ = 'colors' date_joined = db.Column(db.DateTime, default=datetime.datetime.utcnow()) id = Column(Integer, primary_key=True, autoincrement=True) name = Column(String, nullable=False)
class Department(db.Model): __tablename__ = 'department' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.VARCHAR(200), nullable=False) parent_id = db.Column(db.Integer, nullable=True) level = db.Column(db.Integer, nullable=False)