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() # Entries for uploads to corpora, that have no authentication. E.g. "prevodi" or "gigafida". class UploadUnauthenticated(db.Model): __tablename__ = 'upload_unauthenticated' id = db.Column(db.Integer, primary_key=True) upload_hash = db.Column(db.String) timestamp = db.Column(db.DateTime, default=datetime.utcnow) form_name = db.Column(db.String) form_org = db.Column(db.String) form_address = db.Column(db.String) form_zipcode = db.Column(db.String) form_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 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) corpus_name = db.Column(db.String) form_program = db.Column(db.String) form_subject = db.Column(db.String) form_grade = db.Column(db.Integer) form_text_type = db.Column(db.String) form_school_year = db.Column(db.String) form_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)