Coverage for toardb/contacts/models_organisation.py: 100%

17 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2025-11-03 20:32 +0000

1# SPDX-FileCopyrightText: 2021 Forschungszentrum Jülich GmbH 

2# SPDX-License-Identifier: MIT 

3 

4""" 

5class Organisation (Base) 

6========================= 

7""" 

8from sqlalchemy import CheckConstraint, Column, Integer, String, Sequence, ForeignKey 

9from toardb.base import Base 

10 

11ORGANISATIONS_ID_SEQ = Sequence('organisations_id_seq') # define sequence explicitly 

12class Organisation(Base): 

13 """ 

14 Table "public.organisations" 

15 

16 +-----------------+-------------------------+-----------+----------+-------------------------------------------+ 

17 | Column | Type | Collation | Nullable | Default | 

18 +=================+=========================+===========+==========+===========================================+ 

19 | id | integer | | not null | nextval('organisations_id_seq'::regclass) | 

20 +-----------------+-------------------------+-----------+----------+-------------------------------------------+ 

21 | name | character varying(32) | | not null | | 

22 +-----------------+-------------------------+-----------+----------+-------------------------------------------+ 

23 | longname | character varying(256) | | not null | | 

24 +-----------------+-------------------------+-----------+----------+-------------------------------------------+ 

25 | kind | integer | | not null | | 

26 +-----------------+-------------------------+-----------+----------+-------------------------------------------+ 

27 | city | character varying(64) | | not null | | 

28 +-----------------+-------------------------+-----------+----------+-------------------------------------------+ 

29 | postcode | character varying(16) | | not null | | 

30 +-----------------+-------------------------+-----------+----------+-------------------------------------------+ 

31 | street_address | character varying(128) | | not null | | 

32 +-----------------+-------------------------+-----------+----------+-------------------------------------------+ 

33 | country | integer | | not null | -1 | 

34 +-----------------+-------------------------+-----------+----------+-------------------------------------------+ 

35 | homepage | character varying(200) | | not null | | 

36 +-----------------+-------------------------+-----------+----------+-------------------------------------------+ 

37 | contact_url | character varying(200) | | not null | '' | 

38 +-----------------+-------------------------+-----------+----------+-------------------------------------------+ 

39 | attribution | character varying(3000) | | not null | '' | 

40 +-----------------+-------------------------+-----------+----------+-------------------------------------------+ 

41 

42 Indexes: 

43 "organisations_pkey" PRIMARY KEY, btree (id) 

44 Check constraints: 

45 "organisations_kind_check" CHECK (kind >= 0) 

46 Foreign-key constraints: 

47 "organisations_kind_fk_ok_vocabulary_enum_val" FOREIGN KEY (kind) REFERENCES ok_vocabulary(enum_val) 

48 "organisations_country_fk_cn_vocabulary_enum_val" FOREIGN KEY (country) REFERENCES cn_vocabulary(enum_val) 

49 """ 

50 __tablename__ = 'organisations' 

51 __table_args__ = ( 

52 CheckConstraint('kind >= 0'), 

53 ) 

54 

55 id = Column(Integer, ORGANISATIONS_ID_SEQ, primary_key=True, server_default=ORGANISATIONS_ID_SEQ.next_value()) 

56 name = Column(String(32), nullable=False) 

57 longname = Column(String(256), nullable=False) 

58 kind = Column(ForeignKey('ok_vocabulary.enum_val'), nullable=False) 

59 city = Column(String(64), nullable=False) 

60 postcode = Column(String(16), nullable=False) 

61 street_address = Column(String(128), nullable=False) 

62 country = Column(ForeignKey('cn_vocabulary.enum_val'), nullable=False) 

63 homepage = Column(String(200), nullable=False) 

64 contact_url = Column(String(200), nullable=False) 

65 attribution = Column(String(3000), nullable=False) 

66 

67# ok_vocabulary = relationship('OkVocabulary') 

68# cn_vocabulary = relationship('CnVocabulary')