-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmeeting.py
More file actions
105 lines (80 loc) · 2.86 KB
/
Copy pathmeeting.py
File metadata and controls
105 lines (80 loc) · 2.86 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
from __future__ import annotations
import uuid
from sqlalchemy import Column, Text, ForeignKey
from sqlalchemy.orm import RelationshipProperty, relationship
from onegov.core.orm import Base
from onegov.core.orm.mixins import ContentMixin
from onegov.core.orm.types import UUID, MarkupText, UTCDateTime
from onegov.file import AssociatedFiles
from onegov.search import ORMSearchable
from typing import TYPE_CHECKING
if TYPE_CHECKING:
import uuid
from datetime import datetime
from markupsafe import Markup
from onegov.parliament.models.political_business import (
PoliticalBusiness,
)
from onegov.parliament.models.meeting_item import MeetingItem
class Meeting(Base, ContentMixin, ORMSearchable, AssociatedFiles):
__tablename__ = 'par_meetings'
type: Column[str] = Column(
Text,
nullable=False,
default=lambda: 'generic'
)
__mapper_args__ = {
'polymorphic_on': type,
'polymorphic_identity': 'generic',
}
es_public = True
es_properties = {'title_text': {'type': 'text'}}
@property
def es_suggestion(self) -> str:
return self.title
@property
def title_text(self) -> str:
return f'{self.title} ({self.start_datetime})'
#: Internal ID
id: Column[uuid.UUID] = Column(
UUID, # type:ignore[arg-type]
primary_key=True,
default=uuid.uuid4,
)
#: The title of the meeting
title: Column[str] = Column(Text, nullable=False)
#: date and time of the meeting start
start_datetime: Column[datetime | None]
start_datetime = Column(UTCDateTime, nullable=True)
#: date and time of the meeting end
end_datetime: Column[datetime | None]
end_datetime = Column(UTCDateTime, nullable=True)
#: location address of meeting
address: Column[Markup] = Column(MarkupText, nullable=False)
description: Column[Markup | None] = Column(MarkupText, nullable=True)
#: political business id
political_business_id: Column[uuid.UUID | None] = Column(
UUID, # type:ignore[arg-type]
ForeignKey('par_political_businesses.id'),
)
# FIXME: is this used or covered by meeting_items?
#: list of political businesses, "Traktanden"
political_businesses: RelationshipProperty[PoliticalBusiness] = (
relationship(
'PoliticalBusiness',
back_populates='meetings',
order_by='PoliticalBusiness.number',
primaryjoin='Meeting.political_business_id == '
'PoliticalBusiness.id',
)
)
#: The meeting items
meeting_items: relationship[list[MeetingItem]]
meeting_items = relationship(
'MeetingItem',
cascade='all, delete-orphan',
back_populates='meeting',
order_by='asc(MeetingItem.number)'
)
def __repr__(self) -> str:
return f'<Meeting {self.title}, {self.start_datetime}>'