2021-03-24 10:05:36 +00:00
|
|
|
from datetime import datetime
|
|
|
|
import sqlalchemy
|
|
|
|
from flask_sqlalchemy import SQLAlchemy
|
2021-05-05 12:26:26 +00:00
|
|
|
from flask_login import UserMixin
|
|
|
|
|
2021-03-24 10:05:36 +00:00
|
|
|
|
|
|
|
###########################################
|
|
|
|
# Model classes for describing SQL tables #
|
|
|
|
###########################################
|
|
|
|
|
|
|
|
# The "db" object gets bound to the Flask app in app.py.
|
|
|
|
db = SQLAlchemy()
|
|
|
|
|
|
|
|
|
2021-05-17 12:33:53 +00:00
|
|
|
# "prevodi" or "gigafida".
|
|
|
|
class UploadRegular(db.Model):
|
|
|
|
__tablename__ = 'upload_regular'
|
2021-03-24 10:05:36 +00:00
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
2021-05-24 08:15:54 +00:00
|
|
|
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)
|
2021-05-05 12:26:26 +00:00
|
|
|
|
|
|
|
|
2021-05-17 12:33:53 +00:00
|
|
|
class UploadPredavanja(db.Model):
|
|
|
|
__tablename__ = 'upload_predavanja'
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
2021-05-24 08:15:54 +00:00
|
|
|
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)
|
2021-05-17 12:33:53 +00:00
|
|
|
|
|
|
|
|
2021-05-05 12:26:26 +00:00
|
|
|
class UploadSolar(db.Model):
|
|
|
|
__tablename__ = 'upload_solar'
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
2021-05-24 08:15:54 +00:00
|
|
|
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)
|
2021-05-05 12:26:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
class RegisteredUser(UserMixin, db.Model):
|
|
|
|
__tablename__ = 'registered_user'
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
2021-05-24 08:15:54 +00:00
|
|
|
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)
|
2021-05-05 12:26:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Institution(db.Model):
|
|
|
|
__tablename__ = 'institution'
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
2021-05-24 08:15:54 +00:00
|
|
|
name = db.Column(db.String, nullable=False)
|
|
|
|
region = db.Column(db.String, nullable=False)
|
|
|
|
file_contract = db.Column(db.String, nullable=True)
|
2021-03-24 10:05:36 +00:00
|
|
|
|