-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmeeting_item.py
More file actions
78 lines (59 loc) · 2.02 KB
/
Copy pathmeeting_item.py
File metadata and controls
78 lines (59 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
from __future__ import annotations
import uuid
from sqlalchemy import Column, Text, ForeignKey
from sqlalchemy.orm import relationship
from onegov.core.orm import Base
from onegov.core.orm.types import UUID
from onegov.parliament.models import Meeting
from onegov.search import ORMSearchable
from typing import TYPE_CHECKING
if TYPE_CHECKING:
import uuid
from onegov.parliament.models.political_business import PoliticalBusiness
class MeetingItem(Base, ORMSearchable):
__tablename__ = 'par_meeting_items'
es_public = True
es_properties = {
'title': {'type': 'text'},
'number': {'type': 'text'}
}
@property
def es_suggestion(self) -> str:
return self.title
#: Internal ID
id: Column[uuid.UUID] = Column(
UUID, # type:ignore[arg-type]
primary_key=True,
default=uuid.uuid4,
)
#: The title of the meeting item
title: Column[str] = Column(Text, nullable=False)
#: number of the meeting item
number: Column[str | None] = Column(Text, nullable=True)
#: political business id
political_business_id: Column[uuid.UUID | None] = Column(
UUID, # type:ignore[arg-type]
ForeignKey('par_political_businesses.id'),
)
political_business: relationship[PoliticalBusiness | None] = relationship(
'PoliticalBusiness',
foreign_keys=[political_business_id]
)
#: link ID only used for mapping after import
political_business_link_id: Column[str | None] = Column(
Text, nullable=True)
#: The id of the meeting
meeting_id: Column[uuid.UUID] = Column(
UUID, # type:ignore[arg-type]
ForeignKey('par_meetings.id'),
nullable=False
)
#: The meeting
meeting: relationship[Meeting] = relationship(
Meeting,
back_populates='meeting_items'
)
def display_name(self) -> str:
return f'{self.number} {self.title}' if self.number else self.title
def __repr__(self) -> str:
return f'<Meeting Item {self.number} {self.title}>'