Source code for toardb.contacts.models_organisation

# SPDX-FileCopyrightText: 2021 Forschungszentrum Jülich GmbH
# SPDX-License-Identifier: MIT

"""
class Organisation (Base)
=========================
"""
from sqlalchemy import CheckConstraint, Column, Integer, String, Sequence, ForeignKey
from toardb.base import Base

ORGANISATIONS_ID_SEQ = Sequence('organisations_id_seq')  # define sequence explicitly
[docs]class Organisation(Base): """ Table "public.organisations" +-----------------+-------------------------+-----------+----------+-------------------------------------------+ | Column | Type | Collation | Nullable | Default | +=================+=========================+===========+==========+===========================================+ | id | integer | | not null | nextval('organisations_id_seq'::regclass) | +-----------------+-------------------------+-----------+----------+-------------------------------------------+ | name | character varying(32) | | not null | | +-----------------+-------------------------+-----------+----------+-------------------------------------------+ | longname | character varying(256) | | not null | | +-----------------+-------------------------+-----------+----------+-------------------------------------------+ | kind | integer | | not null | | +-----------------+-------------------------+-----------+----------+-------------------------------------------+ | city | character varying(64) | | not null | | +-----------------+-------------------------+-----------+----------+-------------------------------------------+ | postcode | character varying(16) | | not null | | +-----------------+-------------------------+-----------+----------+-------------------------------------------+ | street_address | character varying(128) | | not null | | +-----------------+-------------------------+-----------+----------+-------------------------------------------+ | country | integer | | not null | -1 | +-----------------+-------------------------+-----------+----------+-------------------------------------------+ | homepage | character varying(200) | | not null | | +-----------------+-------------------------+-----------+----------+-------------------------------------------+ | contact_url | character varying(200) | | not null | '' | +-----------------+-------------------------+-----------+----------+-------------------------------------------+ | attribution | character varying(3000) | | not null | '' | +-----------------+-------------------------+-----------+----------+-------------------------------------------+ Indexes: "organisations_pkey" PRIMARY KEY, btree (id) Check constraints: "organisations_kind_check" CHECK (kind >= 0) Foreign-key constraints: "organisations_kind_fk_ok_vocabulary_enum_val" FOREIGN KEY (kind) REFERENCES ok_vocabulary(enum_val) "organisations_country_fk_cn_vocabulary_enum_val" FOREIGN KEY (country) REFERENCES cn_vocabulary(enum_val) """ __tablename__ = 'organisations' __table_args__ = ( CheckConstraint('kind >= 0'), ) id = Column(Integer, ORGANISATIONS_ID_SEQ, primary_key=True, server_default=ORGANISATIONS_ID_SEQ.next_value()) name = Column(String(32), nullable=False) longname = Column(String(256), nullable=False) kind = Column(ForeignKey('ok_vocabulary.enum_val'), nullable=False) city = Column(String(64), nullable=False) postcode = Column(String(16), nullable=False) street_address = Column(String(128), nullable=False) country = Column(ForeignKey('cn_vocabulary.enum_val'), nullable=False) homepage = Column(String(200), nullable=False) contact_url = Column(String(200), nullable=False) attribution = Column(String(3000), nullable=False)
# ok_vocabulary = relationship('OkVocabulary') # cn_vocabulary = relationship('CnVocabulary')