from datetime import datetime import sqlalchemy from flask_sqlalchemy import SQLAlchemy from flask_login import UserMixin ########################################### # Model classes for describing SQL tables # ########################################### # The "db" object gets bound to the Flask app in app.py. db = SQLAlchemy() # "prevodi" or "gigafida". class UploadRegular(db.Model): __tablename__ = 'upload_regular' id = db.Column(db.Integer, primary_key=True) upload_hash = db.Column(db.String, nullable=False) timestamp = db.Column(db.DateTime, default=datetime.utcnow, nullable=False) name = db.Column(db.String, nullable=False) org = db.Column(db.String, nullable=True) address = db.Column(db.String, nullable=True) zipcode = db.Column(db.String, nullable=True) email = db.Column(db.String, nullable=False) file_contract = db.Column(db.String, nullable=True) upload_file_hashes = db.Column(sqlalchemy.types.ARRAY(db.String), nullable=True) corpus_name = db.Column(db.String, nullable=False) class UploadPredavanja(db.Model): __tablename__ = 'upload_predavanja' id = db.Column(db.Integer, primary_key=True) upload_hash = db.Column(db.String, nullable=False) timestamp = db.Column(db.DateTime, default=datetime.utcnow, nullable=False) name = db.Column(db.String, nullable=False) address = db.Column(db.String, nullable=False) subject = db.Column(db.String, nullable=False) faculty = db.Column(db.String, nullable=False) email = db.Column(db.String, nullable=False) phone = db.Column(db.String, nullable=True) keywords = db.Column(db.String, nullable=False) agree_publish_future = db.Column(db.String, nullable=False) agree_machine_translation = db.Column(db.Boolean, default=False, nullable=False) agree_news_cjvt = db.Column(db.Boolean, default=False, nullable=False) file_contract = db.Column(db.String, nullable=True) upload_file_hashes = db.Column(sqlalchemy.types.ARRAY(db.String), nullable=True) class UploadSolar(db.Model): __tablename__ = 'upload_solar' id = db.Column(db.Integer, primary_key=True) upload_user = db.Column(db.Integer, sqlalchemy.ForeignKey('registered_user.id'), nullable=True) institution = db.Column(db.Integer, sqlalchemy.ForeignKey('institution.id'), nullable=True) upload_hash = db.Column(db.String, nullable=False) timestamp = db.Column(db.DateTime, default=datetime.utcnow, nullable=False) program = db.Column(db.String, nullable=True) subject = db.Column(db.String, nullable=True) subject_custom = db.Column(db.String, nullable=True) grade = db.Column(db.Integer, nullable=True) text_type = db.Column(db.String, nullable=True) text_type_custom = db.Column(db.String, nullable=True) school_year = db.Column(db.String, nullable=True) grammar_corrections = db.Column(db.String, nullable=True) upload_file_hashes = db.Column(sqlalchemy.types.ARRAY(db.String), nullable=True) class StampsSolar(db.Model): __tablename__ = 'stamps_solar' id = db.Column(db.Integer, primary_key=True) institution = db.Column(db.Integer, sqlalchemy.ForeignKey('institution.id'), nullable=True) name = db.Column(db.String, nullable=False) file_logo = db.Column(db.String, nullable=True) class ContractsSolar(db.Model): __tablename__ = 'contracts_solar' id = db.Column(db.Integer, primary_key=True) institution = db.Column(db.Integer, sqlalchemy.ForeignKey('institution.id'), nullable=False) upload_user = db.Column(db.Integer, sqlalchemy.ForeignKey('registered_user.id'), nullable=True) timestamp = db.Column(db.DateTime, default=datetime.utcnow, nullable=False) file_contract = db.Column(db.String, nullable=False) contract_type = db.Column(db.String, nullable=False) class CorpusAccess(db.Model): __tablename__ = 'corpus_access' id = db.Column(db.Integer, primary_key=True) user_id = db.Column(db.Integer, sqlalchemy.ForeignKey('registered_user.id'), nullable=False) corpus = db.Column(db.String, nullable=False) class RegisteredUser(UserMixin, db.Model): __tablename__ = 'registered_user' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String, nullable=False) email = db.Column(db.String, nullable=False) role = db.Column(db.String, nullable=False) pass_hash = db.Column(db.String, nullable=False) active = db.Column(db.Boolean, nullable=True) last_login = db.Column(db.DateTime, nullable=True) registered = db.Column(db.DateTime, nullable=True) institution = db.Column(db.Integer, sqlalchemy.ForeignKey('institution.id'), nullable=True) institution_moderator = db.Column(db.Boolean, default=False) class Institution(db.Model): __tablename__ = 'institution' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String, nullable=False) region = db.Column(db.String, nullable=False) file_contract = db.Column(db.String, nullable=True)