f3-data-models 0.1.3__tar.gz → 0.1.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {f3_data_models-0.1.3 → f3_data_models-0.1.5}/PKG-INFO +2 -1
- {f3_data_models-0.1.3 → f3_data_models-0.1.5}/f3_data_models/models.py +277 -300
- {f3_data_models-0.1.3 → f3_data_models-0.1.5}/pyproject.toml +2 -1
- {f3_data_models-0.1.3 → f3_data_models-0.1.5}/README.md +0 -0
- {f3_data_models-0.1.3 → f3_data_models-0.1.5}/f3_data_models/__init__.py +0 -0
- {f3_data_models-0.1.3 → f3_data_models-0.1.5}/f3_data_models/utils.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: f3-data-models
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.5
|
4
4
|
Summary: The data schema and models for F3 Nation applications.
|
5
5
|
Home-page: https://github.com/F3-Nation/f3-data-models
|
6
6
|
License: MIT
|
@@ -22,6 +22,7 @@ Requires-Dist: sphinx-multiversion (>=0.2.4,<0.3.0)
|
|
22
22
|
Requires-Dist: sphinx-rtd-theme (>=3.0.2,<4.0.0)
|
23
23
|
Requires-Dist: sqlalchemy (>=2.0.36,<3.0.0)
|
24
24
|
Requires-Dist: sqlalchemy-schemadisplay (>=2.0,<3.0)
|
25
|
+
Requires-Dist: sqlmodel (>=0.0.22,<0.0.23)
|
25
26
|
Project-URL: Documentation, https://github.io/F3-Nation/f3-data-models
|
26
27
|
Project-URL: Repository, https://github.com/F3-Nation/f3-data-models
|
27
28
|
Description-Content-Type: text/markdown
|
@@ -1,5 +1,5 @@
|
|
1
1
|
from datetime import datetime, date, time
|
2
|
-
from typing import Any, Dict,
|
2
|
+
from typing import Any, Dict, Optional
|
3
3
|
from sqlalchemy import (
|
4
4
|
JSON,
|
5
5
|
TEXT,
|
@@ -9,39 +9,44 @@ from sqlalchemy import (
|
|
9
9
|
DateTime,
|
10
10
|
ForeignKey,
|
11
11
|
Integer,
|
12
|
-
UniqueConstraint,
|
13
12
|
func,
|
14
13
|
)
|
15
14
|
from typing_extensions import Annotated
|
16
|
-
from sqlalchemy.orm import
|
15
|
+
from sqlalchemy.orm import (
|
16
|
+
DeclarativeBase,
|
17
|
+
mapped_column,
|
18
|
+
Mapped,
|
19
|
+
)
|
17
20
|
|
18
21
|
# Custom Annotations
|
19
22
|
time_notz = Annotated[time, TIME]
|
20
23
|
text = Annotated[str, TEXT]
|
24
|
+
intpk = Annotated[int, mapped_column(Integer, primary_key=True, autoincrement=True)]
|
25
|
+
dt_create = Annotated[
|
26
|
+
datetime, mapped_column(DateTime, server_default=func.timezone("utc", func.now()))
|
27
|
+
]
|
28
|
+
dt_update = Annotated[
|
29
|
+
datetime,
|
30
|
+
mapped_column(
|
31
|
+
DateTime,
|
32
|
+
server_default=func.timezone("utc", func.now()),
|
33
|
+
server_onupdate=func.timezone("utc", func.now()),
|
34
|
+
),
|
35
|
+
]
|
21
36
|
|
22
37
|
|
23
38
|
class Base(DeclarativeBase):
|
24
39
|
"""
|
25
|
-
Base class for all models, providing common
|
40
|
+
Base class for all models, providing common methods.
|
26
41
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
42
|
+
Methods:
|
43
|
+
get_id: Get the primary key of the model.
|
44
|
+
get: Get the value of a specified attribute.
|
45
|
+
to_json: Convert the model instance to a JSON-serializable dictionary.
|
46
|
+
__repr__: Get a string representation of the model instance.
|
47
|
+
_update: Update the model instance with the provided fields.
|
31
48
|
"""
|
32
49
|
|
33
|
-
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
34
|
-
# created: Mapped[datetime] = dt_create
|
35
|
-
# updated: Mapped[datetime] = dt_update
|
36
|
-
created: Mapped[datetime] = mapped_column(
|
37
|
-
DateTime, server_default=func.timezone("utc", func.now())
|
38
|
-
)
|
39
|
-
updated: Mapped[datetime] = mapped_column(
|
40
|
-
DateTime,
|
41
|
-
server_default=func.timezone("utc", func.now()),
|
42
|
-
onupdate=func.timezone("utc", func.now()),
|
43
|
-
)
|
44
|
-
|
45
50
|
type_annotation_map = {
|
46
51
|
Dict[str, Any]: JSON,
|
47
52
|
}
|
@@ -112,26 +117,24 @@ class SlackSpace(Base):
|
|
112
117
|
Model representing a Slack workspace.
|
113
118
|
|
114
119
|
Attributes:
|
120
|
+
id (int): Primary Key of the model.
|
115
121
|
team_id (str): The Slack-internal unique identifier for the Slack team.
|
116
122
|
workspace_name (Optional[str]): The name of the Slack workspace.
|
117
123
|
bot_token (Optional[str]): The bot token for the Slack workspace.
|
118
124
|
settings (Optional[Dict[str, Any]]): Slack Bot settings for the Slack workspace.
|
119
|
-
|
120
|
-
|
121
|
-
org (Org): The organization associated with this Slack workspace.
|
125
|
+
created (datetime): The timestamp when the record was created.
|
126
|
+
updated (datetime): The timestamp when the record was last updated.
|
122
127
|
"""
|
123
128
|
|
124
129
|
__tablename__ = "slack_spaces"
|
125
130
|
|
131
|
+
id: Mapped[intpk]
|
126
132
|
team_id: Mapped[str] = mapped_column(VARCHAR, unique=True)
|
127
133
|
workspace_name: Mapped[Optional[str]]
|
128
134
|
bot_token: Mapped[Optional[str]]
|
129
135
|
settings: Mapped[Optional[Dict[str, Any]]]
|
130
|
-
|
131
|
-
|
132
|
-
org: Mapped["Org"] = relationship(
|
133
|
-
back_populates="slack_space", secondary="org_x_slack", lazy="joined"
|
134
|
-
)
|
136
|
+
created: Mapped[dt_create]
|
137
|
+
updated: Mapped[dt_update]
|
135
138
|
|
136
139
|
|
137
140
|
class OrgType(Base):
|
@@ -139,14 +142,20 @@ class OrgType(Base):
|
|
139
142
|
Model representing an organization type / level. 1=AO, 2=Region, 3=Area, 4=Sector
|
140
143
|
|
141
144
|
Attributes:
|
145
|
+
id (int): Primary Key of the model.
|
142
146
|
name (str): The name of the organization type.
|
143
147
|
description (Optional[text]): A description of the organization type.
|
148
|
+
created (datetime): The timestamp when the record was created.
|
149
|
+
updated (datetime): The timestamp when the record was last updated.
|
144
150
|
"""
|
145
151
|
|
146
152
|
__tablename__ = "org_types"
|
147
153
|
|
154
|
+
id: Mapped[intpk]
|
148
155
|
name: Mapped[str]
|
149
156
|
description: Mapped[Optional[text]]
|
157
|
+
created: Mapped[dt_create]
|
158
|
+
updated: Mapped[dt_update]
|
150
159
|
|
151
160
|
|
152
161
|
class EventCategory(Base):
|
@@ -154,19 +163,20 @@ class EventCategory(Base):
|
|
154
163
|
Model representing an event category. These are immutable cateogies that we will define at the Nation level.
|
155
164
|
|
156
165
|
Attributes:
|
166
|
+
id (int): Primary Key of the model.
|
157
167
|
name (str): The name of the event category.
|
158
168
|
description (Optional[text]): A description of the event category.
|
159
|
-
|
169
|
+
created (datetime): The timestamp when the record was created.
|
170
|
+
updated (datetime): The timestamp when the record was last updated.
|
160
171
|
"""
|
161
172
|
|
162
173
|
__tablename__ = "event_categories"
|
163
174
|
|
175
|
+
id: Mapped[intpk]
|
164
176
|
name: Mapped[str]
|
165
177
|
description: Mapped[Optional[text]]
|
166
|
-
|
167
|
-
|
168
|
-
back_populates="event_category"
|
169
|
-
)
|
178
|
+
created: Mapped[dt_create]
|
179
|
+
updated: Mapped[dt_update]
|
170
180
|
|
171
181
|
|
172
182
|
class Role(Base):
|
@@ -174,14 +184,20 @@ class Role(Base):
|
|
174
184
|
Model representing a role. A role is a set of permissions that can be assigned to users.
|
175
185
|
|
176
186
|
Attributes:
|
187
|
+
id (int): Primary Key of the model.
|
177
188
|
name (str): The name of the role.
|
178
189
|
description (Optional[text]): A description of the role.
|
190
|
+
created (datetime): The timestamp when the record was created.
|
191
|
+
updated (datetime): The timestamp when the record was last updated.
|
179
192
|
"""
|
180
193
|
|
181
194
|
__tablename__ = "roles"
|
182
195
|
|
196
|
+
id: Mapped[intpk]
|
183
197
|
name: Mapped[str]
|
184
198
|
description: Mapped[Optional[text]]
|
199
|
+
created: Mapped[dt_create]
|
200
|
+
updated: Mapped[dt_update]
|
185
201
|
|
186
202
|
|
187
203
|
class Permission(Base):
|
@@ -189,14 +205,20 @@ class Permission(Base):
|
|
189
205
|
Model representing a permission.
|
190
206
|
|
191
207
|
Attributes:
|
208
|
+
id (int): Primary Key of the model.
|
192
209
|
name (str): The name of the permission.
|
193
210
|
description (Optional[text]): A description of the permission.
|
211
|
+
created (datetime): The timestamp when the record was created.
|
212
|
+
updated (datetime): The timestamp when the record was last updated.
|
194
213
|
"""
|
195
214
|
|
196
215
|
__tablename__ = "permissions"
|
197
216
|
|
217
|
+
id: Mapped[intpk]
|
198
218
|
name: Mapped[str]
|
199
219
|
description: Mapped[Optional[text]]
|
220
|
+
created: Mapped[dt_create]
|
221
|
+
updated: Mapped[dt_update]
|
200
222
|
|
201
223
|
|
202
224
|
class Role_x_Permission(Base):
|
@@ -206,23 +228,13 @@ class Role_x_Permission(Base):
|
|
206
228
|
Attributes:
|
207
229
|
role_id (int): The ID of the associated role.
|
208
230
|
permission_id (int): The ID of the associated permission.
|
209
|
-
role (Role): The role associated with this relationship.
|
210
|
-
permission (Permission): The permission associated with this relationship.
|
211
231
|
"""
|
212
232
|
|
213
233
|
__tablename__ = "roles_x_permissions"
|
214
|
-
__table_args__ = (
|
215
|
-
UniqueConstraint("role_id", "permission_id", name="_role_permission_uc"),
|
216
|
-
)
|
217
234
|
|
218
|
-
role_id: Mapped[int] = mapped_column(ForeignKey("roles.id"))
|
219
|
-
permission_id: Mapped[int] = mapped_column(
|
220
|
-
|
221
|
-
role: Mapped["Role"] = relationship(
|
222
|
-
back_populates="role_x_permission", lazy="joined"
|
223
|
-
)
|
224
|
-
permissions: Mapped[List["Permission"]] = relationship(
|
225
|
-
back_populates="role_x_permission", lazy="joined"
|
235
|
+
role_id: Mapped[int] = mapped_column(ForeignKey("roles.id"), primary_key=True)
|
236
|
+
permission_id: Mapped[int] = mapped_column(
|
237
|
+
ForeignKey("permissions.id"), primary_key=True
|
226
238
|
)
|
227
239
|
|
228
240
|
|
@@ -234,27 +246,13 @@ class Role_x_User_x_Org(Base):
|
|
234
246
|
role_id (int): The ID of the associated role.
|
235
247
|
user_id (int): The ID of the associated user.
|
236
248
|
org_id (int): The ID of the associated organization.
|
237
|
-
role (Role): The role associated with this relationship.
|
238
|
-
user (User): The user associated with this relationship.
|
239
|
-
org (Org): The organization associated with this relationship.
|
240
249
|
"""
|
241
250
|
|
242
251
|
__tablename__ = "roles_x_users_x_org"
|
243
|
-
__table_args__ = (
|
244
|
-
UniqueConstraint("role_id", "user_id", "org_id", name="_role_user_org_uc"),
|
245
|
-
)
|
246
252
|
|
247
|
-
role_id: Mapped[int] = mapped_column(ForeignKey("roles.id"))
|
248
|
-
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"))
|
249
|
-
org_id: Mapped[int] = mapped_column(ForeignKey("orgs.id"))
|
250
|
-
|
251
|
-
role: Mapped["Role"] = relationship(
|
252
|
-
back_populates="role_x_user_x_org", lazy="joined"
|
253
|
-
)
|
254
|
-
user: Mapped["User"] = relationship(
|
255
|
-
back_populates="role_x_user_x_org", lazy="joined"
|
256
|
-
)
|
257
|
-
org: Mapped["Org"] = relationship(back_populates="role_x_user_x_org", lazy="joined")
|
253
|
+
role_id: Mapped[int] = mapped_column(ForeignKey("roles.id"), primary_key=True)
|
254
|
+
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"), primary_key=True)
|
255
|
+
org_id: Mapped[int] = mapped_column(ForeignKey("orgs.id"), primary_key=True)
|
258
256
|
|
259
257
|
|
260
258
|
class Org(Base):
|
@@ -262,6 +260,7 @@ class Org(Base):
|
|
262
260
|
Model representing an organization. The same model is used for all levels of organization (AOs, Regions, etc.).
|
263
261
|
|
264
262
|
Attributes:
|
263
|
+
id (int): Primary Key of the model.
|
265
264
|
parent_id (Optional[int]): The ID of the parent organization.
|
266
265
|
org_type_id (int): The ID of the organization type.
|
267
266
|
default_location_id (Optional[int]): The ID of the default location.
|
@@ -276,13 +275,13 @@ class Org(Base):
|
|
276
275
|
instagram (Optional[str]): The organization's Instagram handle.
|
277
276
|
last_annual_review (Optional[date]): The date of the last annual review.
|
278
277
|
meta (Optional[Dict[str, Any]]): Additional metadata for the organization.
|
279
|
-
|
280
|
-
|
281
|
-
locations (List[Location]): The locations associated with the organization.
|
278
|
+
created (datetime): The timestamp when the record was created.
|
279
|
+
updated (datetime): The timestamp when the record was last updated.
|
282
280
|
"""
|
283
281
|
|
284
282
|
__tablename__ = "orgs"
|
285
283
|
|
284
|
+
id: Mapped[intpk]
|
286
285
|
parent_id: Mapped[Optional[int]] = mapped_column(ForeignKey("orgs.id"))
|
287
286
|
org_type_id: Mapped[int] = mapped_column(ForeignKey("org_types.id"))
|
288
287
|
default_location_id: Mapped[Optional[int]]
|
@@ -297,16 +296,8 @@ class Org(Base):
|
|
297
296
|
instagram: Mapped[Optional[str]]
|
298
297
|
last_annual_review: Mapped[Optional[date]]
|
299
298
|
meta: Mapped[Optional[Dict[str, Any]]]
|
300
|
-
|
301
|
-
|
302
|
-
"Org", remote_side="Org.id", back_populates="child_orgs"
|
303
|
-
)
|
304
|
-
child_orgs: Mapped[List["Org"]] = relationship(
|
305
|
-
"Org", back_populates="parent_org", join_depth=3
|
306
|
-
)
|
307
|
-
locations: Mapped[List["Location"]] = relationship(
|
308
|
-
back_populates="org", lazy="joined"
|
309
|
-
)
|
299
|
+
created: Mapped[dt_create]
|
300
|
+
updated: Mapped[dt_update]
|
310
301
|
|
311
302
|
|
312
303
|
class EventType(Base):
|
@@ -314,23 +305,24 @@ class EventType(Base):
|
|
314
305
|
Model representing an event type. Event types can be shared by regions or not, and should roll up into event categories.
|
315
306
|
|
316
307
|
Attributes:
|
308
|
+
id (int): Primary Key of the model.
|
317
309
|
name (str): The name of the event type.
|
318
310
|
description (Optional[text]): A description of the event type.
|
319
311
|
acronyms (Optional[str]): Acronyms associated with the event type.
|
320
312
|
category_id (int): The ID of the associated event category.
|
321
|
-
|
313
|
+
created (datetime): The timestamp when the record was created.
|
314
|
+
updated (datetime): The timestamp when the record was last updated.
|
322
315
|
"""
|
323
316
|
|
324
317
|
__tablename__ = "event_types"
|
325
318
|
|
319
|
+
id: Mapped[intpk]
|
326
320
|
name: Mapped[str]
|
327
321
|
description: Mapped[Optional[text]]
|
328
322
|
acronyms: Mapped[Optional[str]]
|
329
323
|
category_id: Mapped[int] = mapped_column(ForeignKey("event_categories.id"))
|
330
|
-
|
331
|
-
|
332
|
-
back_populates="event_types", lazy="joined"
|
333
|
-
)
|
324
|
+
created: Mapped[dt_create]
|
325
|
+
updated: Mapped[dt_update]
|
334
326
|
|
335
327
|
|
336
328
|
class EventType_x_Event(Base):
|
@@ -340,23 +332,13 @@ class EventType_x_Event(Base):
|
|
340
332
|
Attributes:
|
341
333
|
event_id (int): The ID of the associated event.
|
342
334
|
event_type_id (int): The ID of the associated event type.
|
343
|
-
event (Event): The event associated with this relationship.
|
344
|
-
event_type (EventType): The event type associated with this relationship.
|
345
335
|
"""
|
346
336
|
|
347
337
|
__tablename__ = "events_x_event_types"
|
348
|
-
__table_args__ = (
|
349
|
-
UniqueConstraint("event_id", "event_type_id", name="_event_event_type_uc"),
|
350
|
-
)
|
351
|
-
|
352
|
-
event_id: Mapped[int] = mapped_column(ForeignKey("events.id"))
|
353
|
-
event_type_id: Mapped[int] = mapped_column(ForeignKey("event_types.id"))
|
354
338
|
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
event_type: Mapped["EventType"] = relationship(
|
359
|
-
back_populates="events_x_event_types", lazy="joined"
|
339
|
+
event_id: Mapped[int] = mapped_column(ForeignKey("events.id"), primary_key=True)
|
340
|
+
event_type_id: Mapped[int] = mapped_column(
|
341
|
+
ForeignKey("event_types.id"), primary_key=True
|
360
342
|
)
|
361
343
|
|
362
344
|
|
@@ -367,24 +349,16 @@ class EventType_x_Org(Base):
|
|
367
349
|
Attributes:
|
368
350
|
event_type_id (int): The ID of the associated event type.
|
369
351
|
org_id (int): The ID of the associated organization.
|
370
|
-
is_default (bool): Whether this is the default event type for the organization.
|
371
|
-
event_type (EventType): The event type associated with this relationship.
|
372
|
-
org (Org): The organization associated with this relationship.
|
352
|
+
is_default (bool): Whether this is the default event type for the organization. Default is False.
|
373
353
|
"""
|
374
354
|
|
375
355
|
__tablename__ = "event_types_x_org"
|
376
|
-
__table_args__ = (
|
377
|
-
UniqueConstraint("event_type_id", "org_id", name="_event_type_org_uc"),
|
378
|
-
)
|
379
356
|
|
380
|
-
event_type_id: Mapped[int] = mapped_column(
|
381
|
-
|
382
|
-
is_default: Mapped[bool]
|
383
|
-
|
384
|
-
event_type: Mapped["EventType"] = relationship(
|
385
|
-
back_populates="event_type_x_org", lazy="joined"
|
357
|
+
event_type_id: Mapped[int] = mapped_column(
|
358
|
+
ForeignKey("event_types.id"), primary_key=True
|
386
359
|
)
|
387
|
-
|
360
|
+
org_id: Mapped[int] = mapped_column(ForeignKey("orgs.id"), primary_key=True)
|
361
|
+
is_default: Mapped[bool] = mapped_column(Boolean, default=False)
|
388
362
|
|
389
363
|
|
390
364
|
class EventTag(Base):
|
@@ -392,16 +366,22 @@ class EventTag(Base):
|
|
392
366
|
Model representing an event tag. These are used to mark special events, such as anniversaries or special workouts.
|
393
367
|
|
394
368
|
Attributes:
|
369
|
+
id (int): Primary Key of the model.
|
395
370
|
name (str): The name of the event tag.
|
396
371
|
description (Optional[text]): A description of the event tag.
|
397
372
|
color (Optional[str]): The color used for the calendar.
|
373
|
+
created (datetime): The timestamp when the record was created.
|
374
|
+
updated (datetime): The timestamp when the record was last updated.
|
398
375
|
"""
|
399
376
|
|
400
377
|
__tablename__ = "event_tags"
|
401
378
|
|
379
|
+
id: Mapped[intpk]
|
402
380
|
name: Mapped[str]
|
403
381
|
description: Mapped[Optional[text]]
|
404
382
|
color: Mapped[Optional[str]]
|
383
|
+
created: Mapped[dt_create]
|
384
|
+
updated: Mapped[dt_update]
|
405
385
|
|
406
386
|
|
407
387
|
class EventTag_x_Event(Base):
|
@@ -411,23 +391,13 @@ class EventTag_x_Event(Base):
|
|
411
391
|
Attributes:
|
412
392
|
event_id (int): The ID of the associated event.
|
413
393
|
event_tag_id (int): The ID of the associated event tag.
|
414
|
-
event (Event): The event associated with this relationship.
|
415
|
-
event_tag (EventTag): The event tag associated with this relationship.
|
416
394
|
"""
|
417
395
|
|
418
396
|
__tablename__ = "event_tags_x_events"
|
419
|
-
__table_args__ = (
|
420
|
-
UniqueConstraint("event_id", "event_tag_id", name="_event_event_tag_uc"),
|
421
|
-
)
|
422
|
-
|
423
|
-
event_id: Mapped[int] = mapped_column(ForeignKey("events.id"))
|
424
|
-
event_tag_id: Mapped[int] = mapped_column(ForeignKey("event_tags.id"))
|
425
397
|
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
event_tag: Mapped["EventTag"] = relationship(
|
430
|
-
back_populates="event_tag_x_event", lazy="joined"
|
398
|
+
event_id: Mapped[int] = mapped_column(ForeignKey("events.id"), primary_key=True)
|
399
|
+
event_tag_id: Mapped[int] = mapped_column(
|
400
|
+
ForeignKey("event_tags.id"), primary_key=True
|
431
401
|
)
|
432
402
|
|
433
403
|
|
@@ -438,24 +408,16 @@ class EventTag_x_Org(Base):
|
|
438
408
|
Attributes:
|
439
409
|
event_tag_id (int): The ID of the associated event tag.
|
440
410
|
org_id (int): The ID of the associated organization.
|
441
|
-
color_override (Optional[str]): The color override for the event tag (if the region wants to use something other than the default).
|
442
|
-
event_tag (EventTag): The event tag associated with this relationship.
|
443
|
-
org (Org): The organization associated with this relationship.
|
411
|
+
color_override (Optional[str]): The calendar color override for the event tag (if the region wants to use something other than the default).
|
444
412
|
"""
|
445
413
|
|
446
414
|
__tablename__ = "event_tags_x_org"
|
447
|
-
__table_args__ = (
|
448
|
-
UniqueConstraint("event_tag_id", "org_id", name="_event_tag_org_uc"),
|
449
|
-
)
|
450
|
-
|
451
|
-
event_tag_id: Mapped[int] = mapped_column(ForeignKey("event_tags.id"))
|
452
|
-
org_id: Mapped[int] = mapped_column(ForeignKey("orgs.id"))
|
453
|
-
color_override: Mapped[Optional[str]]
|
454
415
|
|
455
|
-
|
456
|
-
|
416
|
+
event_tag_id: Mapped[int] = mapped_column(
|
417
|
+
ForeignKey("event_tags.id"), primary_key=True
|
457
418
|
)
|
458
|
-
|
419
|
+
org_id: Mapped[int] = mapped_column(ForeignKey("orgs.id"), primary_key=True)
|
420
|
+
color_override: Mapped[Optional[str]]
|
459
421
|
|
460
422
|
|
461
423
|
class Org_x_Slack(Base):
|
@@ -465,22 +427,14 @@ class Org_x_Slack(Base):
|
|
465
427
|
Attributes:
|
466
428
|
org_id (int): The ID of the associated organization.
|
467
429
|
slack_space_id (str): The ID of the associated Slack workspace.
|
468
|
-
slack_space (SlackSpace): The Slack workspace associated with this relationship.
|
469
|
-
org (Org): The organization associated with this relationship.
|
470
430
|
"""
|
471
431
|
|
472
432
|
__tablename__ = "org_x_slack"
|
473
|
-
__table_args__ = (
|
474
|
-
UniqueConstraint("org_id", "slack_space_id", name="_org_slack_uc"),
|
475
|
-
)
|
476
433
|
|
477
|
-
org_id: Mapped[int] = mapped_column(ForeignKey("orgs.id"))
|
478
|
-
slack_space_id: Mapped[str] = mapped_column(
|
479
|
-
|
480
|
-
slack_space: Mapped["SlackSpace"] = relationship(
|
481
|
-
back_populates="org_x_slack", lazy="joined"
|
434
|
+
org_id: Mapped[int] = mapped_column(ForeignKey("orgs.id"), primary_key=True)
|
435
|
+
slack_space_id: Mapped[str] = mapped_column(
|
436
|
+
ForeignKey("slack_spaces.id"), primary_key=True
|
482
437
|
)
|
483
|
-
org: Mapped["Org"] = relationship(back_populates="org_x_slack", lazy="joined")
|
484
438
|
|
485
439
|
|
486
440
|
class Location(Base):
|
@@ -488,6 +442,7 @@ class Location(Base):
|
|
488
442
|
Model representing a location. Locations are expected to belong to a single organization (region).
|
489
443
|
|
490
444
|
Attributes:
|
445
|
+
id (int): Primary Key of the model.
|
491
446
|
org_id (int): The ID of the associated organization.
|
492
447
|
name (str): The name of the location.
|
493
448
|
description (Optional[text]): A description of the location.
|
@@ -500,11 +455,13 @@ class Location(Base):
|
|
500
455
|
address_zip (Optional[str]): The ZIP code of the location.
|
501
456
|
address_country (Optional[str]): The country of the location.
|
502
457
|
meta (Optional[Dict[str, Any]]): Additional metadata for the location.
|
503
|
-
|
458
|
+
created (datetime): The timestamp when the record was created.
|
459
|
+
updated (datetime): The timestamp when the record was last updated.
|
504
460
|
"""
|
505
461
|
|
506
462
|
__tablename__ = "locations"
|
507
463
|
|
464
|
+
id: Mapped[intpk]
|
508
465
|
org_id: Mapped[int] = mapped_column(ForeignKey("orgs.id"))
|
509
466
|
name: Mapped[str]
|
510
467
|
description: Mapped[Optional[text]]
|
@@ -517,8 +474,8 @@ class Location(Base):
|
|
517
474
|
address_zip: Mapped[Optional[str]]
|
518
475
|
address_country: Mapped[Optional[str]]
|
519
476
|
meta: Mapped[Optional[Dict[str, Any]]]
|
520
|
-
|
521
|
-
|
477
|
+
created: Mapped[dt_create]
|
478
|
+
updated: Mapped[dt_update]
|
522
479
|
|
523
480
|
|
524
481
|
class Event(Base):
|
@@ -526,6 +483,7 @@ class Event(Base):
|
|
526
483
|
Model representing an event or series; the same model is used for both with a self-referential relationship for series.
|
527
484
|
|
528
485
|
Attributes:
|
486
|
+
id (int): Primary Key of the model.
|
529
487
|
org_id (int): The ID of the associated organization.
|
530
488
|
location_id (Optional[int]): The ID of the associated location.
|
531
489
|
series_id (Optional[int]): The ID of the associated event series.
|
@@ -551,20 +509,13 @@ class Event(Base):
|
|
551
509
|
preblast_ts (Optional[float]): The Slack post timestamp of the pre-event announcement.
|
552
510
|
backblast_ts (Optional[float]): The Slack post timestamp of the post-event report.
|
553
511
|
meta (Optional[Dict[str, Any]]): Additional metadata for the event.
|
554
|
-
|
555
|
-
|
556
|
-
event_type (EventType): The event type associated with this event.
|
557
|
-
event_tag (EventTag): Any event tags associated with this event.
|
558
|
-
series (Event): The event series associated with this event.
|
559
|
-
attendance (List[Attendance]): The attendance records for this event.
|
560
|
-
event_tags_x_event (List[EventTag_x_Event]): The event tags associated with this event.
|
561
|
-
event_types_x_event (List[EventType_x_Event]): The event types associated with this event.
|
562
|
-
event_tags (List[EventTag]): The event tags associated with this event.
|
563
|
-
event_types (List[EventType]): The event types associated with this event.
|
512
|
+
created (datetime): The timestamp when the record was created.
|
513
|
+
updated (datetime): The timestamp when the record was last updated.
|
564
514
|
"""
|
565
515
|
|
566
516
|
__tablename__ = "events"
|
567
517
|
|
518
|
+
id: Mapped[intpk]
|
568
519
|
org_id: Mapped[int] = mapped_column(ForeignKey("orgs.id"))
|
569
520
|
location_id: Mapped[Optional[int]] = mapped_column(ForeignKey("locations.id"))
|
570
521
|
series_id: Mapped[Optional[int]] = mapped_column(ForeignKey("events.id"))
|
@@ -590,30 +541,8 @@ class Event(Base):
|
|
590
541
|
preblast_ts: Mapped[Optional[float]]
|
591
542
|
backblast_ts: Mapped[Optional[float]]
|
592
543
|
meta: Mapped[Optional[Dict[str, Any]]]
|
593
|
-
|
594
|
-
|
595
|
-
location: Mapped["Location"] = relationship(back_populates="events", lazy="joined")
|
596
|
-
series: Mapped["Event"] = relationship(
|
597
|
-
back_populates="events", remote_side="Event.id", lazy="joined"
|
598
|
-
)
|
599
|
-
occurences: Mapped[List["Event"]] = relationship(
|
600
|
-
back_populates="series", lazy="joined"
|
601
|
-
)
|
602
|
-
attendance: Mapped[List["Attendance"]] = relationship(
|
603
|
-
back_populates="events", lazy="joined"
|
604
|
-
)
|
605
|
-
event_tags_x_event: Mapped[List["EventTag_x_Event"]] = relationship(
|
606
|
-
back_populates="events"
|
607
|
-
)
|
608
|
-
event_types_x_event: Mapped[List["EventType_x_Event"]] = relationship(
|
609
|
-
back_populates="events"
|
610
|
-
)
|
611
|
-
event_tags: Mapped[List["EventTag"]] = relationship(
|
612
|
-
back_populates="event", secondary="event_tags_x_event", lazy="joined"
|
613
|
-
)
|
614
|
-
event_types: Mapped[List["EventType"]] = relationship(
|
615
|
-
back_populates="event", secondary="event_types_x_event", lazy="joined"
|
616
|
-
)
|
544
|
+
created: Mapped[dt_create]
|
545
|
+
updated: Mapped[dt_update]
|
617
546
|
|
618
547
|
|
619
548
|
class AttendanceType(Base):
|
@@ -627,8 +556,11 @@ class AttendanceType(Base):
|
|
627
556
|
|
628
557
|
__tablename__ = "attendance_types"
|
629
558
|
|
559
|
+
id: Mapped[intpk]
|
630
560
|
type: Mapped[str]
|
631
561
|
description: Mapped[Optional[str]]
|
562
|
+
created: Mapped[dt_create]
|
563
|
+
updated: Mapped[dt_update]
|
632
564
|
|
633
565
|
|
634
566
|
class Attendance(Base):
|
@@ -641,29 +573,21 @@ class Attendance(Base):
|
|
641
573
|
attendance_type_id (int): The ID of the associated attendance type.
|
642
574
|
is_planned (bool): Whether this is planned attendance (True) vs actual attendance (False).
|
643
575
|
meta (Optional[Dict[str, Any]]): Additional metadata for the attendance.
|
644
|
-
|
645
|
-
|
646
|
-
attendance_type (AttendanceType): The attendance type associated with this attendance.
|
576
|
+
created (datetime): The timestamp when the record was created.
|
577
|
+
updated (datetime): The timestamp when the record was last updated.
|
647
578
|
"""
|
648
579
|
|
649
580
|
__tablename__ = "attendance"
|
650
|
-
__table_args__ = (
|
651
|
-
UniqueConstraint(
|
652
|
-
"event_id", "user_id", "is_planned", name="_event_user_planned_uc"
|
653
|
-
),
|
654
|
-
)
|
655
581
|
|
656
|
-
event_id: Mapped[int] = mapped_column(ForeignKey("events.id"))
|
657
|
-
user_id: Mapped[Optional[int]] = mapped_column(
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
event: Mapped["Event"] = relationship(back_populates="attendance", lazy="joined")
|
663
|
-
user: Mapped["User"] = relationship(back_populates="attendance", lazy="joined")
|
664
|
-
attendance_type: Mapped["AttendanceType"] = relationship(
|
665
|
-
back_populates="attendance", lazy="joined"
|
582
|
+
event_id: Mapped[int] = mapped_column(ForeignKey("events.id"), primary_key=True)
|
583
|
+
user_id: Mapped[Optional[int]] = mapped_column(
|
584
|
+
ForeignKey("users.id"), primary_key=True
|
585
|
+
) # NOTE: Should this be optional?
|
586
|
+
attendance_type_id: Mapped[int] = mapped_column(
|
587
|
+
ForeignKey("attendance_types.id"), primary_key=True
|
666
588
|
)
|
589
|
+
is_planned: Mapped[bool] = mapped_column(Boolean, primary_key=True)
|
590
|
+
meta: Mapped[Optional[Dict[str, Any]]]
|
667
591
|
|
668
592
|
|
669
593
|
class User(Base):
|
@@ -671,6 +595,7 @@ class User(Base):
|
|
671
595
|
Model representing a user.
|
672
596
|
|
673
597
|
Attributes:
|
598
|
+
id (int): Primary Key of the model.
|
674
599
|
f3_name (Optional[str]): The F3 name of the user.
|
675
600
|
first_name (Optional[str]): The first name of the user.
|
676
601
|
last_name (Optional[str]): The last name of the user.
|
@@ -679,18 +604,13 @@ class User(Base):
|
|
679
604
|
home_region_id (Optional[int]): The ID of the home region.
|
680
605
|
avatar_url (Optional[str]): The URL of the user's avatar.
|
681
606
|
meta (Optional[Dict[str, Any]]): Additional metadata for the user.
|
682
|
-
|
683
|
-
|
684
|
-
slack_users (List[SlackUser]): The Slack users associated with this user.
|
685
|
-
achievements_x_user (List[Achievement_x_User]): The achievements associated with this user.
|
686
|
-
positions_x_orgs_x_users (List[Position_x_Org_x_User]): The positions associated with this user.
|
687
|
-
roles_x_users_x_org (List[Role_x_User_x_Org]): The roles associated with this user.
|
688
|
-
positions (List[Position]): The positions associated with this user.
|
689
|
-
roles (List[Role]): The roles associated with this user.
|
607
|
+
created (datetime): The timestamp when the record was created.
|
608
|
+
updated (datetime): The timestamp when the record was last updated.
|
690
609
|
"""
|
691
610
|
|
692
611
|
__tablename__ = "users"
|
693
612
|
|
613
|
+
id: Mapped[intpk]
|
694
614
|
f3_name: Mapped[Optional[str]]
|
695
615
|
first_name: Mapped[Optional[str]]
|
696
616
|
last_name: Mapped[Optional[str]]
|
@@ -699,32 +619,8 @@ class User(Base):
|
|
699
619
|
home_region_id: Mapped[Optional[int]] = mapped_column(ForeignKey("orgs.id"))
|
700
620
|
avatar_url: Mapped[Optional[str]]
|
701
621
|
meta: Mapped[Optional[Dict[str, Any]]]
|
702
|
-
|
703
|
-
|
704
|
-
attendance: Mapped[List["Attendance"]] = relationship(
|
705
|
-
back_populates="users", lazy="joined"
|
706
|
-
)
|
707
|
-
slack_users: Mapped[List["SlackUser"]] = relationship(
|
708
|
-
back_populates="users", lazy="joined"
|
709
|
-
)
|
710
|
-
achievements_x_user: Mapped[List["Achievement_x_User"]] = relationship(
|
711
|
-
back_populates="user"
|
712
|
-
)
|
713
|
-
positions_x_orgs_x_users: Mapped[List["Position_x_Org_x_User"]] = relationship(
|
714
|
-
back_populates="user"
|
715
|
-
)
|
716
|
-
roles_x_users_x_org: Mapped[List["Role_x_User_x_Org"]] = relationship(
|
717
|
-
back_populates="user"
|
718
|
-
)
|
719
|
-
achievements: Mapped[List["Achievement"]] = relationship(
|
720
|
-
back_populates="user", secondary="achievements_x_users", lazy="joined"
|
721
|
-
)
|
722
|
-
positions: Mapped[List["Position"]] = relationship(
|
723
|
-
back_populates="user", secondary="positions_x_orgs_x_users", lazy="joined"
|
724
|
-
)
|
725
|
-
roles: Mapped[List["Role"]] = relationship(
|
726
|
-
back_populates="user", secondary="roles_x_users_x_org", lazy="joined"
|
727
|
-
)
|
622
|
+
created: Mapped[dt_create]
|
623
|
+
updated: Mapped[dt_update]
|
728
624
|
|
729
625
|
|
730
626
|
class SlackUser(Base):
|
@@ -732,6 +628,7 @@ class SlackUser(Base):
|
|
732
628
|
Model representing a Slack user.
|
733
629
|
|
734
630
|
Attributes:
|
631
|
+
id (int): Primary Key of the model.
|
735
632
|
slack_id (str): The Slack ID of the user.
|
736
633
|
user_name (str): The username of the Slack user.
|
737
634
|
email (str): The email of the Slack user.
|
@@ -747,12 +644,13 @@ class SlackUser(Base):
|
|
747
644
|
strava_athlete_id (Optional[int]): The Strava athlete ID of the user.
|
748
645
|
meta (Optional[Dict[str, Any]]): Additional metadata for the Slack user.
|
749
646
|
slack_updated (Optional[datetime]): The last update time of the Slack user.
|
750
|
-
|
751
|
-
|
647
|
+
created (datetime): The timestamp when the record was created.
|
648
|
+
updated (datetime): The timestamp when the record was last updated.
|
752
649
|
"""
|
753
650
|
|
754
651
|
__tablename__ = "slack_users"
|
755
652
|
|
653
|
+
id: Mapped[intpk]
|
756
654
|
slack_id: Mapped[str]
|
757
655
|
user_name: Mapped[str]
|
758
656
|
email: Mapped[str]
|
@@ -768,11 +666,8 @@ class SlackUser(Base):
|
|
768
666
|
strava_athlete_id: Mapped[Optional[int]]
|
769
667
|
meta: Mapped[Optional[Dict[str, Any]]]
|
770
668
|
slack_updated: Mapped[Optional[datetime]]
|
771
|
-
|
772
|
-
|
773
|
-
back_populates="slack_users", lazy="joined"
|
774
|
-
)
|
775
|
-
user: Mapped["User"] = relationship(back_populates="slack_users", lazy="joined")
|
669
|
+
created: Mapped[dt_create]
|
670
|
+
updated: Mapped[dt_update]
|
776
671
|
|
777
672
|
|
778
673
|
class Achievement(Base):
|
@@ -780,18 +675,24 @@ class Achievement(Base):
|
|
780
675
|
Model representing an achievement.
|
781
676
|
|
782
677
|
Attributes:
|
678
|
+
id (int): Primary Key of the model.
|
783
679
|
name (str): The name of the achievement.
|
784
680
|
description (Optional[str]): A description of the achievement.
|
785
681
|
verb (str): The verb associated with the achievement.
|
786
682
|
image_url (Optional[str]): The URL of the achievement's image.
|
683
|
+
created (datetime): The timestamp when the record was created.
|
684
|
+
updated (datetime): The timestamp when the record was last updated.
|
787
685
|
"""
|
788
686
|
|
789
687
|
__tablename__ = "achievements"
|
790
688
|
|
689
|
+
id: Mapped[intpk]
|
791
690
|
name: Mapped[str]
|
792
691
|
description: Mapped[Optional[str]]
|
793
692
|
verb: Mapped[str]
|
794
693
|
image_url: Mapped[Optional[str]]
|
694
|
+
created: Mapped[dt_create]
|
695
|
+
updated: Mapped[dt_update]
|
795
696
|
|
796
697
|
|
797
698
|
class Achievement_x_User(Base):
|
@@ -801,25 +702,17 @@ class Achievement_x_User(Base):
|
|
801
702
|
Attributes:
|
802
703
|
achievement_id (int): The ID of the associated achievement.
|
803
704
|
user_id (int): The ID of the associated user.
|
804
|
-
date_awarded (date): The date the achievement was awarded.
|
805
|
-
achievement (Achievement): The achievement associated with this relationship.
|
806
|
-
user (User): The user associated with this relationship.
|
705
|
+
date_awarded (date): The date the achievement was awarded. Default is the current date.
|
807
706
|
"""
|
808
707
|
|
809
708
|
__tablename__ = "achievements_x_users"
|
810
|
-
__table_args__ = (
|
811
|
-
UniqueConstraint("achievement_id", "user_id", name="_achievement_user_uc"),
|
812
|
-
)
|
813
|
-
|
814
|
-
achievement_id: Mapped[int] = mapped_column(ForeignKey("achievements.id"))
|
815
|
-
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"))
|
816
|
-
date_awarded: Mapped[date]
|
817
709
|
|
818
|
-
|
819
|
-
|
710
|
+
achievement_id: Mapped[int] = mapped_column(
|
711
|
+
ForeignKey("achievements.id"), primary_key=True
|
820
712
|
)
|
821
|
-
|
822
|
-
|
713
|
+
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"), primary_key=True)
|
714
|
+
date_awarded: Mapped[date] = mapped_column(
|
715
|
+
DateTime, server_default=func.timezone("utc", func.now())
|
823
716
|
)
|
824
717
|
|
825
718
|
|
@@ -830,22 +723,14 @@ class Achievement_x_Org(Base):
|
|
830
723
|
Attributes:
|
831
724
|
achievement_id (int): The ID of the associated achievement.
|
832
725
|
org_id (int): The ID of the associated organization.
|
833
|
-
achievement (Achievement): The achievement associated with this relationship.
|
834
|
-
org (Org): The organization associated with this relationship.
|
835
726
|
"""
|
836
727
|
|
837
728
|
__tablename__ = "achievements_x_org"
|
838
|
-
__table_args__ = (
|
839
|
-
UniqueConstraint("achievement_id", "org_id", name="_achievement_org_uc"),
|
840
|
-
)
|
841
|
-
|
842
|
-
achievement_id: Mapped[int] = mapped_column(ForeignKey("achievements.id"))
|
843
|
-
org_id: Mapped[int] = mapped_column(ForeignKey("orgs.id"))
|
844
729
|
|
845
|
-
|
846
|
-
|
730
|
+
achievement_id: Mapped[int] = mapped_column(
|
731
|
+
ForeignKey("achievements.id"), primary_key=True
|
847
732
|
)
|
848
|
-
|
733
|
+
org_id: Mapped[int] = mapped_column(ForeignKey("orgs.id"), primary_key=True)
|
849
734
|
|
850
735
|
|
851
736
|
class Position(Base):
|
@@ -861,10 +746,13 @@ class Position(Base):
|
|
861
746
|
|
862
747
|
__tablename__ = "positions"
|
863
748
|
|
749
|
+
id: Mapped[intpk]
|
864
750
|
name: Mapped[str]
|
865
751
|
description: Mapped[Optional[str]]
|
866
752
|
org_type_id: Mapped[Optional[int]] = mapped_column(ForeignKey("org_types.id"))
|
867
753
|
org_id: Mapped[Optional[int]] = mapped_column(ForeignKey("orgs.id"))
|
754
|
+
created: Mapped[dt_create]
|
755
|
+
updated: Mapped[dt_update]
|
868
756
|
|
869
757
|
|
870
758
|
class Position_x_Org_x_User(Base):
|
@@ -875,31 +763,15 @@ class Position_x_Org_x_User(Base):
|
|
875
763
|
position_id (int): The ID of the associated position.
|
876
764
|
org_id (int): The ID of the associated organization.
|
877
765
|
user_id (int): The ID of the associated user.
|
878
|
-
position (Position): The position associated with this relationship.
|
879
|
-
org (Org): The organization associated with this relationship.
|
880
|
-
user (User): The user associated with this relationship.
|
881
766
|
"""
|
882
767
|
|
883
768
|
__tablename__ = "positions_x_orgs_x_users"
|
884
|
-
__table_args__ = (
|
885
|
-
UniqueConstraint(
|
886
|
-
"position_id", "user_id", "org_id", name="_position_user_org_uc"
|
887
|
-
),
|
888
|
-
)
|
889
|
-
|
890
|
-
position_id: Mapped[int] = mapped_column(ForeignKey("positions.id"))
|
891
|
-
org_id: Mapped[int] = mapped_column(ForeignKey("orgs.id"))
|
892
|
-
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"))
|
893
769
|
|
894
|
-
|
895
|
-
|
896
|
-
)
|
897
|
-
org: Mapped["Org"] = relationship(
|
898
|
-
back_populates="position_x_org_x_user", lazy="joined"
|
899
|
-
)
|
900
|
-
user: Mapped["User"] = relationship(
|
901
|
-
back_populates="position_x_org_x_user", lazy="joined"
|
770
|
+
position_id: Mapped[int] = mapped_column(
|
771
|
+
ForeignKey("positions.id"), primary_key=True
|
902
772
|
)
|
773
|
+
org_id: Mapped[int] = mapped_column(ForeignKey("orgs.id"), primary_key=True)
|
774
|
+
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"), primary_key=True)
|
903
775
|
|
904
776
|
|
905
777
|
class Expansion(Base):
|
@@ -907,22 +779,28 @@ class Expansion(Base):
|
|
907
779
|
Model representing an expansion.
|
908
780
|
|
909
781
|
Attributes:
|
782
|
+
id (int): Primary Key of the model.
|
910
783
|
area (str): The area of the expansion.
|
911
784
|
pinned_lat (float): The pinned latitude of the expansion.
|
912
785
|
pinned_lon (float): The pinned longitude of the expansion.
|
913
786
|
user_lat (float): The user's latitude.
|
914
787
|
user_lon (float): The user's longitude.
|
915
788
|
interested_in_organizing (bool): Whether the user is interested in organizing.
|
789
|
+
created (datetime): The timestamp when the record was created.
|
790
|
+
updated (datetime): The timestamp when the record was last updated.
|
916
791
|
"""
|
917
792
|
|
918
793
|
__tablename__ = "expansions"
|
919
794
|
|
795
|
+
id: Mapped[intpk]
|
920
796
|
area: Mapped[str]
|
921
797
|
pinned_lat: Mapped[float]
|
922
798
|
pinned_lon: Mapped[float]
|
923
799
|
user_lat: Mapped[float]
|
924
800
|
user_lon: Mapped[float]
|
925
801
|
interested_in_organizing: Mapped[bool]
|
802
|
+
created: Mapped[dt_create]
|
803
|
+
updated: Mapped[dt_update]
|
926
804
|
|
927
805
|
|
928
806
|
class Expansion_x_User(Base):
|
@@ -932,25 +810,124 @@ class Expansion_x_User(Base):
|
|
932
810
|
Attributes:
|
933
811
|
expansion_id (int): The ID of the associated expansion.
|
934
812
|
user_id (int): The ID of the associated user.
|
935
|
-
|
813
|
+
requst_date (date): The date of the request. Default is the current date.
|
936
814
|
notes (Optional[text]): Additional notes for the association.
|
937
|
-
expansion (Expansion): The expansion associated with this relationship.
|
938
|
-
user (User): The user associated with this relationship.
|
939
815
|
"""
|
940
816
|
|
941
817
|
__tablename__ = "expansions_x_users"
|
942
|
-
__table_args__ = (
|
943
|
-
UniqueConstraint("expansion_id", "user_id", name="_expansion_user_uc"),
|
944
|
-
)
|
945
818
|
|
946
|
-
expansion_id: Mapped[int] = mapped_column(
|
947
|
-
|
948
|
-
date: Mapped[date]
|
949
|
-
notes: Mapped[Optional[text]]
|
950
|
-
|
951
|
-
expansion: Mapped["Expansion"] = relationship(
|
952
|
-
back_populates="expansion_x_user", lazy="joined"
|
819
|
+
expansion_id: Mapped[int] = mapped_column(
|
820
|
+
ForeignKey("expansions.id"), primary_key=True
|
953
821
|
)
|
954
|
-
|
955
|
-
|
822
|
+
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"), primary_key=True)
|
823
|
+
request_date: Mapped[date] = mapped_column(
|
824
|
+
DateTime, server_default=func.timezone("utc", func.now())
|
956
825
|
)
|
826
|
+
notes: Mapped[Optional[text]]
|
827
|
+
|
828
|
+
|
829
|
+
# def upgrade() -> None:
|
830
|
+
# # ### commands auto generated by Alembic - please adjust! ###
|
831
|
+
# op.create_table(
|
832
|
+
# "magiclinkauthrecord",
|
833
|
+
# sa.Column("id", sa.Integer(), nullable=False),
|
834
|
+
# sa.Column("email", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
835
|
+
# sa.Column("otp_hash", sa.LargeBinary(), nullable=False),
|
836
|
+
# sa.Column(
|
837
|
+
# "created",
|
838
|
+
# sa.DateTime(timezone=True),
|
839
|
+
# server_default=sa.text("(CURRENT_TIMESTAMP)"),
|
840
|
+
# nullable=False,
|
841
|
+
# ),
|
842
|
+
# sa.Column(
|
843
|
+
# "expiration",
|
844
|
+
# sa.DateTime(timezone=True),
|
845
|
+
# server_default=sa.text("(CURRENT_TIMESTAMP)"),
|
846
|
+
# nullable=False,
|
847
|
+
# ),
|
848
|
+
# sa.Column("client_ip", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
849
|
+
# sa.Column("recent_attempts", sa.Integer(), nullable=False),
|
850
|
+
# sa.PrimaryKeyConstraint("id"),
|
851
|
+
# )
|
852
|
+
# op.create_table(
|
853
|
+
# "magiclinkauthsession",
|
854
|
+
# sa.Column("id", sa.Integer(), nullable=False),
|
855
|
+
# sa.Column("email", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
856
|
+
# sa.Column("persistent_id", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
857
|
+
# sa.Column("session_token", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
858
|
+
# sa.Column(
|
859
|
+
# "created",
|
860
|
+
# sa.DateTime(timezone=True),
|
861
|
+
# server_default=sa.text("(CURRENT_TIMESTAMP)"),
|
862
|
+
# nullable=False,
|
863
|
+
# ),
|
864
|
+
# sa.Column(
|
865
|
+
# "expiration",
|
866
|
+
# sa.DateTime(timezone=True),
|
867
|
+
# server_default=sa.text("(CURRENT_TIMESTAMP)"),
|
868
|
+
# nullable=False,
|
869
|
+
# ),
|
870
|
+
# sa.PrimaryKeyConstraint("id"),
|
871
|
+
# )
|
872
|
+
# with op.batch_alter_table("magiclinkauthsession", schema=None) as batch_op:
|
873
|
+
# batch_op.create_index(
|
874
|
+
# batch_op.f("ix_magiclinkauthsession_email"), ["email"], unique=False
|
875
|
+
# )
|
876
|
+
# batch_op.create_index(
|
877
|
+
# batch_op.f("ix_magiclinkauthsession_persistent_id"),
|
878
|
+
# ["persistent_id"],
|
879
|
+
# unique=False,
|
880
|
+
# )
|
881
|
+
# batch_op.create_index(
|
882
|
+
# batch_op.f("ix_magiclinkauthsession_session_token"),
|
883
|
+
# ["session_token"],
|
884
|
+
# unique=True,
|
885
|
+
# )
|
886
|
+
|
887
|
+
|
888
|
+
class MagicLinkAuthRecord(Base):
|
889
|
+
"""
|
890
|
+
Model representing a Magic Link Auth Record.
|
891
|
+
|
892
|
+
Attributes:
|
893
|
+
id (int): Primary Key of the model.
|
894
|
+
email (str): The email of the user.
|
895
|
+
otp_hash (bytes): The hash of the OTP.
|
896
|
+
created (datetime): The timestamp when the record was created.
|
897
|
+
expiration (datetime): The timestamp when the record expires.
|
898
|
+
client_ip (str): The client IP address.
|
899
|
+
recent_attempts (int): The number of recent attempts.
|
900
|
+
"""
|
901
|
+
|
902
|
+
__tablename__ = "magiclinkauthrecord"
|
903
|
+
|
904
|
+
id: Mapped[intpk]
|
905
|
+
email: Mapped[str]
|
906
|
+
otp_hash: Mapped[bytes]
|
907
|
+
created: Mapped[dt_create]
|
908
|
+
expiration: Mapped[dt_create]
|
909
|
+
client_ip: Mapped[str]
|
910
|
+
recent_attempts: Mapped[int]
|
911
|
+
|
912
|
+
|
913
|
+
class MagicLinkAuthSession(Base):
|
914
|
+
"""
|
915
|
+
Model representing a Magic Link Auth Session.
|
916
|
+
|
917
|
+
Attributes:
|
918
|
+
id (int): Primary Key of the model.
|
919
|
+
email (str): The email of the user.
|
920
|
+
persistent_id (str): The persistent ID.
|
921
|
+
session_token (str): The session token.
|
922
|
+
created (datetime): The timestamp when the record was created.
|
923
|
+
expiration (datetime): The timestamp when the record expires.
|
924
|
+
"""
|
925
|
+
|
926
|
+
__tablename__ = "magiclinkauthsession"
|
927
|
+
|
928
|
+
id: Mapped[intpk]
|
929
|
+
email: Mapped[str]
|
930
|
+
persistent_id: Mapped[str]
|
931
|
+
session_token: Mapped[str]
|
932
|
+
created: Mapped[dt_create]
|
933
|
+
expiration: Mapped[dt_create]
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[tool.poetry]
|
2
2
|
name = "f3-data-models"
|
3
|
-
version = "0.1.
|
3
|
+
version = "0.1.5"
|
4
4
|
description = "The data schema and models for F3 Nation applications."
|
5
5
|
authors = ["Evan Petzoldt <evan.petzoldt@protonmail.com>"]
|
6
6
|
readme = "README.md"
|
@@ -23,6 +23,7 @@ sphinx-autodoc-typehints = "^2.5.0"
|
|
23
23
|
sphinx-rtd-theme = "^3.0.2"
|
24
24
|
sphinx-multiversion = "^0.2.4"
|
25
25
|
psycopg2-binary = "^2.9.10"
|
26
|
+
sqlmodel = "^0.0.22"
|
26
27
|
|
27
28
|
|
28
29
|
[build-system]
|
File without changes
|
File without changes
|
File without changes
|