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) timestamp = db.Column(db.DateTime, default=datetime.utcnow) name = db.Column(db.String) org = db.Column(db.String) address = db.Column(db.String) zipcode = db.Column(db.String) email = db.Column(db.String) file_contract = db.Column(db.String) upload_file_hashes = db.Column(sqlalchemy.types.ARRAY(db.String)) corpus_name = db.Column(db.String) class UploadPredavanja(db.Model): __tablename__ = 'upload_predavanja' id = db.Column(db.Integer, primary_key=True) upload_hash = db.Column(db.String) timestamp = db.Column(db.DateTime, default=datetime.utcnow) name = db.Column(db.String) address = db.Column(db.String) subject = db.Column(db.String) faculty = db.Column(db.String) email = db.Column(db.String) phone = db.Column(db.String) keywords = db.Column(db.String) agree_publish = db.Column(db.Boolean) file_contract = db.Column(db.String) upload_file_hashes = db.Column(sqlalchemy.types.ARRAY(db.String)) 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')) institution = db.Column(db.Integer, sqlalchemy.ForeignKey('institution.id')) upload_hash = db.Column(db.String) timestamp = db.Column(db.DateTime, default=datetime.utcnow) program = db.Column(db.String) subject = db.Column(db.String) subject_custom = db.Column(db.String) grade = db.Column(db.Integer) text_type = db.Column(db.String) text_type_custom = db.Column(db.String) school_year = db.Column(db.String) grammar_corrections = db.Column(db.String) upload_file_hashes = db.Column(sqlalchemy.types.ARRAY(db.String)) class RegisteredUser(UserMixin, db.Model): __tablename__ = 'registered_user' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String) email = db.Column(db.String) role = db.Column(db.String) pass_hash = db.Column(db.String) active = db.Column(db.Boolean) last_login = db.Column(db.DateTime) registered = db.Column(db.DateTime) institution = db.Column(db.Integer, sqlalchemy.ForeignKey('institution.id')) class Institution(db.Model): __tablename__ = 'institution' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String) region = db.Column(db.String) file_contract = db.Column(db.String)