class Question(Base): __tablename__ = 'question' __table_args__ = {'extend_existing': True} id = db.Column(db.Integer(), primary_key=True) application_form_id = db.Column(db.Integer(), db.ForeignKey('application_form.id'), nullable=False) section_id = db.Column(db.Integer(), db.ForeignKey('section.id'), nullable=False) type = db.Column(db.String(), nullable=False) description = db.Column(db.String(), nullable=True) headline = db.Column(db.String(), nullable=False) placeholder = db.Column(db.String(), nullable=True) validation_regex = db.Column(db.String(), nullable=True) validation_text = db.Column(db.String(), nullable=True) order = db.Column(db.Integer(), nullable=False) options = db.Column(db.JSON(), nullable=True) is_required = db.Column(db.Boolean(), nullable=False) depends_on_question_id = db.Column(db.Integer(), db.ForeignKey('question.id'), nullable=True) show_for_values = db.Column(db.JSON(), nullable=True) def __init__(self, application_form_id, section_id, headline, placeholder, order, questionType, validation_regex, validation_text=None, is_required = True, description = None, options = None): self.application_form_id = application_form_id self.section_id = section_id self.headline = headline self.placeholder = placeholder self.order = order self.type = questionType self.description = description self.options = options self.is_required = is_required self.validation_regex = validation_regex self.validation_text = validation_text
class Request(db.Model): id = db.Column(db.Integer, primary_key=True) uuid = db.Column(db.String(36), unique=True, nullable=False, index=True) form = db.Column(db.JSON()) # POST data in request body headers = db.Column(db.JSON()) # HTTP request headers args = db.Column(db.JSON()) # url arguments url = db.Column(db.String(3000)) # url, incl arguments data = db.Column( db.String(10000) ) # request data in case it came with a mimetype Werkzeug doesn't handle files = db.Column(db.JSON()) # metadata of uploaded files remote_addr = db.Column(db.String(100)) # IP address of client method = db.Column(db.String(7)) # HTTP method used endpoint = db.Column( db.String(50)) # name of flask endpoint handling the request timestamp = db.Column(db.DateTime, index=True, default=datetime.utcnow) def __repr__(self): return "<Request %s>" % self.uuid def todict(self): return { 'id': self.id, 'uuid': self.uuid, 'form': self.form, 'headers': self.headers, 'args': self.args, 'url': self.url, 'data': self.data, 'files': self.files, 'remote_addr': self.remote_addr, 'method': self.method, 'endpoint': self.endpoint, 'timestamp': self.timestamp }
class Question(Base): __tablename__ = 'question' __table_args__ = {'extend_existing': True} id = db.Column(db.Integer(), primary_key=True) application_form_id = db.Column(db.Integer(), db.ForeignKey('application_form.id'), nullable=False) section_id = db.Column(db.Integer(), db.ForeignKey('section.id'), nullable=False) type = db.Column(db.String(), nullable=False) description = db.Column(db.String(), nullable=True) headline = db.Column(db.String(), nullable=False) placeholder = db.Column(db.String(), nullable=True) validation_regex = db.Column(db.String(), nullable=True) validation_text = db.Column(db.String(), nullable=True) order = db.Column(db.Integer(), nullable=False) options = db.Column(db.JSON(), nullable=True) is_required = db.Column(db.Boolean(), nullable=False) depends_on_question_id = db.Column(db.Integer(), db.ForeignKey('question.id'), nullable=True) show_for_values = db.Column(db.JSON(), nullable=True) key = db.Column(db.String(255), nullable=True)
class CmsOrganizationBuildings(db.Model): """Модель общей информации об архиве.""" id = db.Column(db.Integer, primary_key=True) # noqa: ignore=A003 name = db.Column(db.String(50), comment="Имя здания") road_map = db.Column(db.String(500), comment="Карта проезда") work_time = db.Column(db.JSON(none_as_null=True), comment="Режимы работы") employee_contacts = db.Column(db.JSON(none_as_null=True), comment="Контакты сотрудников") additional_info = db.Column(db.JSON(none_as_null=True), comment="Дополнительная информация") organization_id = db.Column(db.Integer, db.ForeignKey('cms_organization.id'), nullable=False) def __repr__(self): """Форматирование представления экземпляра класса.""" return "Здание: «%s»" % (self.name) def __init__(self, name, road_map=None, organization_id=None, work_time=None, employee_contacts=None): """Конструктор класса.""" self.name = name self.road_map = None if road_map is None else road_map self.organization_id = CmsOrganization.query.first( ).id if organization_id is None else organization_id self.work_time = [] if work_time is None else work_time self.employee_contacts = [] if work_time is None else work_time
class Data(db.Model): __tablename__ = 'data' id = db.Column(db.Integer, primary_key=True, autoincrement=True) name = db.Column(db.String(32), index=True) content = db.Column(db.JSON()) setting = db.Column(db.JSON()) def __repr__(self): return '<name> %s' % self.name
class WeblogEvent(db.Model): id = db.Column(db.Integer(), primary_key=True) fargateTaskArn = db.Column(db.String()) # remaining fields are directly from weblog POST data runName = db.Column(db.String()) runId = db.Column(db.String()) event = db.Column(db.String()) utcTime = db.Column(db.DateTime(timezone=True)) metadataField = db.Column(db.JSON()) trace = db.Column(db.JSON())
class Video(db.Model): __tablename__ = 'video' __table_args__ = {'extend_existing': True} id = db.Column(db.Integer, primary_key=True) vid = db.Column(db.String, nullable=False) uid = db.Column(db.String, unique=False, nullable=False) status = db.Column(db.Enum('wait', 'processing', 'complete', name='video_type'), nullable=False, default=False) reply_gif = db.Column(db.JSON(none_as_null=True), nullable=True, unique=False) thumbnails_path = db.Column(db.JSON(none_as_null=True), unique=False, nullable=True)
class Article(db.Model): id = db.Column(db.Integer, primary_key=True) uuid = db.Column(db.String(16), unique=True, index=True, default=guid) data = db.Column(db.JSON()) meta = db.Column(db.JSON()) status =db.Column(db.Integer(), default=0, index=True) created = db.Column(db.DateTime, default=datetime.utcnow) modified = db.Column(db.DateTime, default=datetime.utcnow) user_id = db.Column(db.Integer, db.ForeignKey('user.id')) def __repr__(self): return '<Article {}>'.format(self.uuid)
class Organisation(Base): __tablename__ = "organisation" __table_args__ = {'extend_existing': True} id = db.Column(db.Integer(), primary_key=True) name = db.Column(db.String(50), nullable=False) system_name = db.Column(db.String(50), nullable=False) small_logo = db.Column(db.String(100), nullable=False) large_logo = db.Column(db.String(100), nullable=False) icon_logo = db.Column(db.String(100), nullable=False) domain = db.Column(db.String(100), nullable=False) url = db.Column(db.String(100), nullable=False) email_from = db.Column(db.String(100), nullable=True) system_url = db.Column(db.String(100), nullable=False) privacy_policy = db.Column(db.String(100), nullable=False) languages = db.Column(db.JSON(), nullable=False) def __init__(self, name, system_name, small_logo, large_logo, icon_logo, domain, url, email_from, system_url, privacy_policy, languages): self.name = name self.small_logo = small_logo self.large_logo = large_logo self.icon_logo = icon_logo self.domain = domain self.system_name = system_name self.url = url self.email_from = email_from self.system_url = system_url self.privacy_policy = privacy_policy self.languages = languages
class data(db.Model): id = db.Column(db.String(20), primary_key=True) cloud = db.Column(db.String(12), index=True) jsond = db.Column(db.JSON(1000), index=True) def __repr__(self): return '<User %r>' % (self.sn)
class User(UserMixin, db.Model): __tablename__ = 'USERS' id = db.Column(db.Integer, primary_key=True) user = db.Column(db.String(20), unique=True) email = db.Column(db.String(50), unique=True) password = db.Column(db.String(500)) data = db.Column(db.JSON()) def __init__(self, user, email, password, data): self.user = user self.password = password self.email = email self.data = data def __repr__(self): return '<User %r>' % (self.id) def save(self): # inject self into db session db.session.add(self) # commit change and save the object db.session.commit() return self
class SectionTranslation(Base): __tablename__ = 'section_translation' __table_args__ = {'extend_existing': True} id = db.Column(db.Integer(), primary_key=True) section_id = db.Column(db.Integer(), db.ForeignKey('section.id'), nullable=False) language = db.Column(db.String(2), nullable=False) name = db.Column(db.String(255), nullable=False) description = db.Column(db.String(), nullable=False) show_for_values = db.Column(db.JSON(), nullable=True) section = db.relationship('Section', foreign_keys=[section_id]) def __init__(self, section_id, language, name, description, show_for_values=None): self.section_id = section_id self.language = language self.name = name self.description = description self.show_for_values = show_for_values
class SectionTranslation(db.Model): __tablename__ = 'section_translation' __table_args__ = tuple([ db.UniqueConstraint('section_id', 'language', name='uq_section_id_language') ]) id = db.Column(db.Integer(), primary_key=True) section_id = db.Column(db.Integer(), db.ForeignKey('section.id'), nullable=False) language = db.Column(db.String(2), nullable=False) name = db.Column(db.String(255), nullable=False) description = db.Column(db.String(), nullable=False) show_for_values = db.Column(db.JSON(), nullable=True) section = db.relationship('Section', foreign_keys=[section_id]) def __init__(self, section_id, language, name, description, show_for_values=None): self.section_id = section_id self.language = language self.name = name self.description = description self.show_for_values = show_for_values
class Hotel(db.Model): __tablename__ = 'hotels' id = db.Column(db.Integer,primary_key=True) name = db.Column(db.String()) start_date = db.Column(db.Date) final_date = db.Column(db.Date) price = db.Column(db.String(16)) alternative = db.Column(db.JSON()) #alternative = db.column(JSON) def __init__(self,name,start_date,final_date,price,alternative): self.name = name self.start_date = start_date self.final_date = final_date self.price = price self.alternative = alternative def __repr__(self): return f'name = {self.name}' def to_json(self): return { 'name':self.name, 'start_date':self.start_date, 'final_date':self.final_date, 'price':self.price, 'alternative':self.alternative }
class EcsEvent(db.Model): id = db.Column(db.Integer(), primary_key=True) # either of these may be null as some events are fargate and some AWS Batch fargateTaskArn = db.Column(db.String()) taskArn = db.Column(db.String()) # ECS event data fields data = db.Column(db.JSON())
class Role(db.Model): __tablename__ = 'roles' id = db.Column(db.Integer, primary_key=True) organisation_id = db.Column(db.Integer, db.ForeignKey('organisation.id')) description = db.Column(db.Text) specialism_id = db.Column(db.ForeignKey('specialisms.id')) responsibilities = db.Column(db.Text) region_id = db.Column(db.Integer, db.ForeignKey('regions.id')) private_office = db.Column(db.Boolean, default=False) skills = db.Column(db.JSON()) specialism = db.relationship('Specialism', lazy='select', backref='specialist_roles') organisation = db.relationship('Organisation', lazy='select') region = db.relationship('Region', lazy='select') def wanted_skills(self): """This function takes the JSON formatted text from the column for this preference form and compares it with the skills in the Skill table. It returns the name of the matching skill. This is for formatting and output purposes - analysing equality or comparisons is done with integers for speed.""" skills_dict = json.loads(self.skills) specialism_id = self.specialism.id skill_id_and_name = dict( Skill.query.with_entities(Skill.id, Skill.description).filter(Skill.specialism == specialism_id). \ all()) return [skill_id_and_name[skill] for preference, skill in skills_dict.items()]
class Check(db.Model): id = db.Column(db.Integer, primary_key=True) order_id = db.Column(db.Integer, nullable=False) printer_id = db.Column(db.Integer, db.ForeignKey('printer.id')) check_type = db.Column(db.String(30)) order = db.Column(db.JSON()) status = db.Column(db.String(30), default='new') pdf_file = db.Column(db.String(256))
class Setting(db.Model): id = db.Column(db.Integer, primary_key=True) data = db.Column(db.JSON()) modified = db.Column(db.DateTime, default=datetime.utcnow) user_id = db.Column(db.Integer, db.ForeignKey("user.id")) def __repr__(self): return '<Setting {}>'.format(self.user_id)
class GraphSetting(db.Model): __tablename__ = 'graphSetting' id = db.Column(db.Integer, primary_key=True, autoincrement=True) name = db.Column(db.String(32), index=True) note = db.Column(db.String(500), index=True) setting = db.Column(db.JSON()) def __repr__(self): return '<name> %s' % self.name
class Table(db.Model): id = db.Column(db.Integer, primary_key=True) string_example = db.Column(db.String(128)) boolean_example = db.Column(db.Boolean()) integer_example = db.Column(db.Integer) json_example = db.Column(db.JSON()) user_id = db.Column(db.Integer, db.ForeignKey('user.id')) def __repr__(self): return '<Table {}>'.format(self.name)
class QuestionTranslation(db.Model): __tablename__ = 'question_translation' __table_args__ = tuple([ db.UniqueConstraint('question_id', 'language', name='uq_question_id_language') ]) id = db.Column(db.Integer(), primary_key=True) question_id = db.Column(db.Integer(), db.ForeignKey('question.id'), nullable=False) language = db.Column(db.String(2), nullable=False) headline = db.Column(db.String(), nullable=False) description = db.Column(db.String(), nullable=True) placeholder = db.Column(db.String(), nullable=True) validation_regex = db.Column(db.String(), nullable=True) validation_text = db.Column(db.String(), nullable=True) options = db.Column(db.JSON(), nullable=True) show_for_values = db.Column(db.JSON(), nullable=True) question = db.relationship('Question', foreign_keys=[question_id]) def __init__(self, question_id, language, headline, description=None, placeholder=None, validation_regex=None, validation_text=None, options=None, show_for_values=None): self.question_id = question_id self.language = language self.headline = headline self.description = description self.placeholder = placeholder self.validation_regex = validation_regex self.validation_text = validation_text self.options = options self.show_for_values = show_for_values
class DecisionTree(db.Model): __tablename__ = 'decision_trees' id = db.Column(db.Integer, primary_key=True) tree = db.Column(db.JSON(none_as_null=True)) def __init__(self, tree): self.tree = tree def serialize(self): return {'id': self.id, 'tree': self.tree}
class ExamForm(db.Model): id = db.Column(db.Integer, primary_key=True, nullable=False) form_description = db.Column(db.JSON(), nullable=False, default="{}") parent_user_id = db.Column(db.Integer, db.ForeignKey("user.id"), nullable=False) proctor_id = db.Column(db.Integer, db.ForeignKey("proctor_session.id")) exam_responses = db.relationship("ExamResponse", backref="exam_form", lazy='dynamic') def __repr__(self): return f' - {self.id} {self.form_description}'
class Preferences(db.Model, Base): id = db.Column(db.Integer, primary_key=True) candidate_id = db.Column(db.ForeignKey('users.id')) open_date = db.Column(db.DateTime()) close_date = db.Column(db.DateTime()) completed_date = db.Column(db.DateTime()) completed = db.Column(db.Boolean(), default=False) skills = db.Column(db.JSON()) # using JSON for now because I don't know how many skills will be in table want_private_office = db.Column(db.Boolean(), default=False) locations = db.Column(db.JSON()) organisation = db.Column(db.JSON()) url = db.Column(db.String(64), default='main.submit_preferences') def has_form_to_complete(self, cid): form = Preferences.query.filter(self.candidate_id == cid, self.completed == False).all() return form def wanted_skills(self) -> List[str]: """This function takes the JSON formatted text from the column for this preference form and compares it with the skills in the Skill table. It returns the name of the matching skill. This is for formatting and output purposes - analysing equality or comparisons is done with integers for speed.""" skills_dict = json.loads(self.skills) specialism_id = self.owner.specialism.id skill_id_and_name = dict( Skill.query.with_entities(Skill.id, Skill.description).filter(Skill.specialism == specialism_id). \ all()) return [skill_id_and_name[skill] for preference, skill in skills_dict.items()] def wanted_organisations(self): """This function examines the 'wanted organisations' stored as integers in JSON code and returns their names for display""" orgs_dict = json.loads(self.organisation) organisation_id_and_name = dict( Organisation.query.with_entities(Organisation.id, Organisation.name).all() ) return [organisation_id_and_name[org] for preference, org in orgs_dict.items()] def __repr__(self): return 'Belongs to Candidate {}'.format(self.owner)
class Mosque(db.Model): __tablename__ = 'mosques' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String()) lat = db.Column(db.String()) lon = db.Column(db.String()) FA = db.Column(db.String()) ZU = db.Column(db.String()) AS = db.Column(db.String()) MA = db.Column(db.String()) IS = db.Column(db.String()) contact = db.Column(db.String()) image_folder_name = db.Column(db.String()) uploader_id = db.Column(db.String()) image_names = db.Column(db.JSON()) def __init__(self, name, lat, lon, FA, ZU, AS, MA, IS, contact, image_folder_name, uploader_id, image_names): self.name = name self.lat = lat self.lon = lon self.FA = FA self.ZU = ZU self.AS = AS self.MA = MA self.IS = IS self.contact = contact self.image_folder_name = image_folder_name self.uploader_id = uploader_id self.image_names = image_names def __repr__(self): return '<id {}>'.format(self.id) def serialize(self): return { 'id': self.id, 'name': self.name, 'lat': self.lat, 'lon': self.lon, 'FA': self.FA, 'ZU': self.ZU, 'AS': self.AS, 'MA': self.MA, 'IS': self.IS, 'contact': self.contact, 'image_folder_name': self.image_folder_name, 'uploader_id': self.uploader_id, 'image_names': self.image_names }
class RegistrationQuestion(Base): __tablename__ = "registration_question" __table_args__ = {'extend_existing': True} id = db.Column(db.Integer(), primary_key=True) registration_form_id = db.Column(db.Integer(), db.ForeignKey("registration_form.id"), nullable=False) section_id = db.Column(db.Integer(), db.ForeignKey("registration_section.id"), nullable=False) type = db.Column(db.String(), nullable=False) description = db.Column(db.String(), nullable=False) headline = db.Column(db.String(), nullable=False) placeholder = db.Column(db.String(), nullable=False) validation_regex = db.Column(db.String(), nullable=True) validation_text = db.Column(db.String(), nullable=True) order = db.Column(db.Integer(), nullable=False) options = db.Column(db.JSON(), nullable=True) is_required = db.Column(db.Boolean(), nullable=False) required_value = db.Column(db.String(), nullable=True) depends_on_question_id = db.Column( db.Integer(), db.ForeignKey("registration_question.id"), nullable=True) hide_for_dependent_value = db.Column(db.String(), nullable=True) def __init__(self, registration_form_id, section_id, headline, placeholder, order, type, validation_regex, validation_text=None, is_required=True, description='', options=None): self.registration_form_id = registration_form_id self.section_id = section_id self.headline = headline self.placeholder = placeholder self.order = order self.type = type self.description = description self.options = options self.is_required = is_required self.validation_regex = validation_regex self.validation_text = validation_text
class QuestionTranslation(Base): __tablename__ = 'question_translation' __table_args__ = {'extend_existing': True} id = db.Column(db.Integer(), primary_key=True) question_id = db.Column(db.Integer(), db.ForeignKey('question.id'), nullable=False) language = db.Column(db.String(2), nullable=False) headline = db.Column(db.String(), nullable=False) description = db.Column(db.String(), nullable=True) placeholder = db.Column(db.String(), nullable=True) validation_regex = db.Column(db.String(), nullable=True) validation_text = db.Column(db.String(), nullable=True) options = db.Column(db.JSON(), nullable=True) show_for_values = db.Column(db.JSON(), nullable=True) def __init__( self, question_id, language, headline, description=None, placeholder=None, validation_regex=None, validation_text=None, options=None, show_for_values=None ): self.question_id = question_id self.language = language self.headline = headline self.description = description self.placeholder = placeholder self.validation_regex = validation_regex self.validation_text = validation_text self.options = options self.show_for_values = show_for_values
class Intake(db.Model): """ Intake model. Intakes are created when the app receives a recording, indicating that a patient has taken medication. """ id = db.Column(db.Integer, primary_key=True) s3_url = db.Column(db.String(500), unique=True, nullable=True) recording_data = db.Column(db.JSON(), unique=False, nullable=True) timestamp = db.Column(db.DateTime(), unique=False, nullable=False) on_time = db.Column(db.Boolean(), unique=False, nullable=False) # Foreign key prescription_id = db.Column(db.Integer, db.ForeignKey("prescription.id"), nullable=False)
class CmsOrganization(db.Model): """Модель общей информации об архиве.""" id = db.Column(db.Integer, primary_key=True) # noqa: ignore=A003 full_company_name = db.Column(db.String(200), comment="Полное наименование организации") company_name = db.Column(db.String(50), comment="Наименование организации") requisites = db.Column(db.JSON(none_as_null=True), comment="Реквизиты организации") buildings = db.relationship('CmsOrganizationBuildings', backref='organization', lazy='dynamic') def __repr__(self): """Форматирование представления экземпляра класса.""" return "Организация: «%s»" % (self.company_name)
class Artist(db.Model): __tablename__ = 'artists' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String, nullable=False) genres = db.Column(db.JSON(), nullable=False) city = db.Column(db.String(120)) state = db.Column(db.String(120)) phone = db.Column(db.String(120)) genres = db.Column(db.String(120)) image_link = db.Column(db.String(500)) website = db.Column(db.String(120)) facebook_link = db.Column(db.String(120)) seeking_venue = db.Column(db.Boolean, nullable=False, default=False) seeking_description = db.Column(db.String(), nullable=True) shows = db.relationship('Show', backref='artist', lazy=True)