Coverage for src/couchers/models/static.py: 100%

17 statements  

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

1from geoalchemy2 import Geometry 

2from sqlalchemy import BigInteger, Column, Index, String 

3 

4from couchers.models.base import Base 

5 

6 

7class Language(Base): 

8 """ 

9 Table of allowed languages (a subset of ISO639-3) 

10 """ 

11 

12 __tablename__ = "languages" 

13 

14 # ISO639-3 language code, in lowercase, e.g. fin, eng 

15 code = Column(String(3), primary_key=True) 

16 

17 # the english name 

18 name = Column(String, nullable=False, unique=True) 

19 

20 

21class TimezoneArea(Base): 

22 __tablename__ = "timezone_areas" 

23 id = Column(BigInteger, primary_key=True) 

24 

25 tzid = Column(String) 

26 geom = Column(Geometry(geometry_type="MULTIPOLYGON", srid=4326), nullable=False) 

27 

28 __table_args__ = ( 

29 Index( 

30 "ix_timezone_areas_geom_tzid", 

31 geom, 

32 tzid, 

33 postgresql_using="gist", 

34 ), 

35 ) 

36 

37 

38class Region(Base): 

39 """ 

40 Table of regions 

41 """ 

42 

43 __tablename__ = "regions" 

44 

45 # iso 3166-1 alpha3 code in uppercase, e.g. FIN, USA 

46 code = Column(String(3), primary_key=True) 

47 

48 # the name, e.g. Finland, United States 

49 # this is the display name in English, should be the "common name", not "Republic of Finland" 

50 name = Column(String, nullable=False, unique=True)