f3-data-models 0.1.4__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.4 → f3_data_models-0.1.5}/PKG-INFO +1 -1
- {f3_data_models-0.1.4 → f3_data_models-0.1.5}/f3_data_models/models.py +277 -310
- {f3_data_models-0.1.4 → f3_data_models-0.1.5}/pyproject.toml +1 -1
- {f3_data_models-0.1.4 → f3_data_models-0.1.5}/README.md +0 -0
- {f3_data_models-0.1.4 → f3_data_models-0.1.5}/f3_data_models/__init__.py +0 -0
- {f3_data_models-0.1.4 → f3_data_models-0.1.5}/f3_data_models/utils.py +0 -0
@@ -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,16 +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.
|
282
|
-
event_tags (List[EventTag]): The event tags associated with the organization.
|
283
|
-
event_types (List[EventType]): The event types associated with the organization.
|
284
|
-
events (List[Event]): The events 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.
|
285
280
|
"""
|
286
281
|
|
287
282
|
__tablename__ = "orgs"
|
288
283
|
|
284
|
+
id: Mapped[intpk]
|
289
285
|
parent_id: Mapped[Optional[int]] = mapped_column(ForeignKey("orgs.id"))
|
290
286
|
org_type_id: Mapped[int] = mapped_column(ForeignKey("org_types.id"))
|
291
287
|
default_location_id: Mapped[Optional[int]]
|
@@ -300,23 +296,8 @@ class Org(Base):
|
|
300
296
|
instagram: Mapped[Optional[str]]
|
301
297
|
last_annual_review: Mapped[Optional[date]]
|
302
298
|
meta: Mapped[Optional[Dict[str, Any]]]
|
303
|
-
|
304
|
-
|
305
|
-
"Org", remote_side="Org.id", back_populates="child_orgs"
|
306
|
-
)
|
307
|
-
child_orgs: Mapped[List["Org"]] = relationship(
|
308
|
-
"Org", back_populates="parent_org", join_depth=3
|
309
|
-
)
|
310
|
-
locations: Mapped[List["Location"]] = relationship(
|
311
|
-
back_populates="org", lazy="joined"
|
312
|
-
)
|
313
|
-
event_tags: Mapped[List["EventTag"]] = relationship(
|
314
|
-
back_populates="org", secondary="event_tags_x_org", lazy="joined"
|
315
|
-
)
|
316
|
-
event_types: Mapped[List["EventType"]] = relationship(
|
317
|
-
back_populates="org", secondary="event_types_x_org", lazy="joined"
|
318
|
-
)
|
319
|
-
events: Mapped[List["Event"]] = relationship(back_populates="org", lazy="joined")
|
299
|
+
created: Mapped[dt_create]
|
300
|
+
updated: Mapped[dt_update]
|
320
301
|
|
321
302
|
|
322
303
|
class EventType(Base):
|
@@ -324,23 +305,24 @@ class EventType(Base):
|
|
324
305
|
Model representing an event type. Event types can be shared by regions or not, and should roll up into event categories.
|
325
306
|
|
326
307
|
Attributes:
|
308
|
+
id (int): Primary Key of the model.
|
327
309
|
name (str): The name of the event type.
|
328
310
|
description (Optional[text]): A description of the event type.
|
329
311
|
acronyms (Optional[str]): Acronyms associated with the event type.
|
330
312
|
category_id (int): The ID of the associated event category.
|
331
|
-
|
313
|
+
created (datetime): The timestamp when the record was created.
|
314
|
+
updated (datetime): The timestamp when the record was last updated.
|
332
315
|
"""
|
333
316
|
|
334
317
|
__tablename__ = "event_types"
|
335
318
|
|
319
|
+
id: Mapped[intpk]
|
336
320
|
name: Mapped[str]
|
337
321
|
description: Mapped[Optional[text]]
|
338
322
|
acronyms: Mapped[Optional[str]]
|
339
323
|
category_id: Mapped[int] = mapped_column(ForeignKey("event_categories.id"))
|
340
|
-
|
341
|
-
|
342
|
-
back_populates="event_types", lazy="joined"
|
343
|
-
)
|
324
|
+
created: Mapped[dt_create]
|
325
|
+
updated: Mapped[dt_update]
|
344
326
|
|
345
327
|
|
346
328
|
class EventType_x_Event(Base):
|
@@ -350,23 +332,13 @@ class EventType_x_Event(Base):
|
|
350
332
|
Attributes:
|
351
333
|
event_id (int): The ID of the associated event.
|
352
334
|
event_type_id (int): The ID of the associated event type.
|
353
|
-
event (Event): The event associated with this relationship.
|
354
|
-
event_type (EventType): The event type associated with this relationship.
|
355
335
|
"""
|
356
336
|
|
357
337
|
__tablename__ = "events_x_event_types"
|
358
|
-
__table_args__ = (
|
359
|
-
UniqueConstraint("event_id", "event_type_id", name="_event_event_type_uc"),
|
360
|
-
)
|
361
|
-
|
362
|
-
event_id: Mapped[int] = mapped_column(ForeignKey("events.id"))
|
363
|
-
event_type_id: Mapped[int] = mapped_column(ForeignKey("event_types.id"))
|
364
338
|
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
event_type: Mapped["EventType"] = relationship(
|
369
|
-
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
|
370
342
|
)
|
371
343
|
|
372
344
|
|
@@ -377,24 +349,16 @@ class EventType_x_Org(Base):
|
|
377
349
|
Attributes:
|
378
350
|
event_type_id (int): The ID of the associated event type.
|
379
351
|
org_id (int): The ID of the associated organization.
|
380
|
-
is_default (bool): Whether this is the default event type for the organization.
|
381
|
-
event_type (EventType): The event type associated with this relationship.
|
382
|
-
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.
|
383
353
|
"""
|
384
354
|
|
385
355
|
__tablename__ = "event_types_x_org"
|
386
|
-
__table_args__ = (
|
387
|
-
UniqueConstraint("event_type_id", "org_id", name="_event_type_org_uc"),
|
388
|
-
)
|
389
|
-
|
390
|
-
event_type_id: Mapped[int] = mapped_column(ForeignKey("event_types.id"))
|
391
|
-
org_id: Mapped[int] = mapped_column(ForeignKey("orgs.id"))
|
392
|
-
is_default: Mapped[bool]
|
393
356
|
|
394
|
-
|
395
|
-
|
357
|
+
event_type_id: Mapped[int] = mapped_column(
|
358
|
+
ForeignKey("event_types.id"), primary_key=True
|
396
359
|
)
|
397
|
-
|
360
|
+
org_id: Mapped[int] = mapped_column(ForeignKey("orgs.id"), primary_key=True)
|
361
|
+
is_default: Mapped[bool] = mapped_column(Boolean, default=False)
|
398
362
|
|
399
363
|
|
400
364
|
class EventTag(Base):
|
@@ -402,16 +366,22 @@ class EventTag(Base):
|
|
402
366
|
Model representing an event tag. These are used to mark special events, such as anniversaries or special workouts.
|
403
367
|
|
404
368
|
Attributes:
|
369
|
+
id (int): Primary Key of the model.
|
405
370
|
name (str): The name of the event tag.
|
406
371
|
description (Optional[text]): A description of the event tag.
|
407
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.
|
408
375
|
"""
|
409
376
|
|
410
377
|
__tablename__ = "event_tags"
|
411
378
|
|
379
|
+
id: Mapped[intpk]
|
412
380
|
name: Mapped[str]
|
413
381
|
description: Mapped[Optional[text]]
|
414
382
|
color: Mapped[Optional[str]]
|
383
|
+
created: Mapped[dt_create]
|
384
|
+
updated: Mapped[dt_update]
|
415
385
|
|
416
386
|
|
417
387
|
class EventTag_x_Event(Base):
|
@@ -421,23 +391,13 @@ class EventTag_x_Event(Base):
|
|
421
391
|
Attributes:
|
422
392
|
event_id (int): The ID of the associated event.
|
423
393
|
event_tag_id (int): The ID of the associated event tag.
|
424
|
-
event (Event): The event associated with this relationship.
|
425
|
-
event_tag (EventTag): The event tag associated with this relationship.
|
426
394
|
"""
|
427
395
|
|
428
396
|
__tablename__ = "event_tags_x_events"
|
429
|
-
__table_args__ = (
|
430
|
-
UniqueConstraint("event_id", "event_tag_id", name="_event_event_tag_uc"),
|
431
|
-
)
|
432
397
|
|
433
|
-
event_id: Mapped[int] = mapped_column(ForeignKey("events.id"))
|
434
|
-
event_tag_id: Mapped[int] = mapped_column(
|
435
|
-
|
436
|
-
event: Mapped["Event"] = relationship(
|
437
|
-
back_populates="event_tag_x_event", lazy="joined"
|
438
|
-
)
|
439
|
-
event_tag: Mapped["EventTag"] = relationship(
|
440
|
-
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
|
441
401
|
)
|
442
402
|
|
443
403
|
|
@@ -448,24 +408,16 @@ class EventTag_x_Org(Base):
|
|
448
408
|
Attributes:
|
449
409
|
event_tag_id (int): The ID of the associated event tag.
|
450
410
|
org_id (int): The ID of the associated organization.
|
451
|
-
color_override (Optional[str]): The color override for the event tag (if the region wants to use something other than the default).
|
452
|
-
event_tag (EventTag): The event tag associated with this relationship.
|
453
|
-
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).
|
454
412
|
"""
|
455
413
|
|
456
414
|
__tablename__ = "event_tags_x_org"
|
457
|
-
__table_args__ = (
|
458
|
-
UniqueConstraint("event_tag_id", "org_id", name="_event_tag_org_uc"),
|
459
|
-
)
|
460
415
|
|
461
|
-
event_tag_id: Mapped[int] = mapped_column(
|
462
|
-
|
463
|
-
color_override: Mapped[Optional[str]]
|
464
|
-
|
465
|
-
event_tag: Mapped["EventTag"] = relationship(
|
466
|
-
back_populates="event_tag_x_org", lazy="joined"
|
416
|
+
event_tag_id: Mapped[int] = mapped_column(
|
417
|
+
ForeignKey("event_tags.id"), primary_key=True
|
467
418
|
)
|
468
|
-
|
419
|
+
org_id: Mapped[int] = mapped_column(ForeignKey("orgs.id"), primary_key=True)
|
420
|
+
color_override: Mapped[Optional[str]]
|
469
421
|
|
470
422
|
|
471
423
|
class Org_x_Slack(Base):
|
@@ -475,22 +427,14 @@ class Org_x_Slack(Base):
|
|
475
427
|
Attributes:
|
476
428
|
org_id (int): The ID of the associated organization.
|
477
429
|
slack_space_id (str): The ID of the associated Slack workspace.
|
478
|
-
slack_space (SlackSpace): The Slack workspace associated with this relationship.
|
479
|
-
org (Org): The organization associated with this relationship.
|
480
430
|
"""
|
481
431
|
|
482
432
|
__tablename__ = "org_x_slack"
|
483
|
-
__table_args__ = (
|
484
|
-
UniqueConstraint("org_id", "slack_space_id", name="_org_slack_uc"),
|
485
|
-
)
|
486
|
-
|
487
|
-
org_id: Mapped[int] = mapped_column(ForeignKey("orgs.id"))
|
488
|
-
slack_space_id: Mapped[str] = mapped_column(ForeignKey("slack_spaces.id"))
|
489
433
|
|
490
|
-
|
491
|
-
|
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
|
492
437
|
)
|
493
|
-
org: Mapped["Org"] = relationship(back_populates="org_x_slack", lazy="joined")
|
494
438
|
|
495
439
|
|
496
440
|
class Location(Base):
|
@@ -498,6 +442,7 @@ class Location(Base):
|
|
498
442
|
Model representing a location. Locations are expected to belong to a single organization (region).
|
499
443
|
|
500
444
|
Attributes:
|
445
|
+
id (int): Primary Key of the model.
|
501
446
|
org_id (int): The ID of the associated organization.
|
502
447
|
name (str): The name of the location.
|
503
448
|
description (Optional[text]): A description of the location.
|
@@ -510,11 +455,13 @@ class Location(Base):
|
|
510
455
|
address_zip (Optional[str]): The ZIP code of the location.
|
511
456
|
address_country (Optional[str]): The country of the location.
|
512
457
|
meta (Optional[Dict[str, Any]]): Additional metadata for the location.
|
513
|
-
|
458
|
+
created (datetime): The timestamp when the record was created.
|
459
|
+
updated (datetime): The timestamp when the record was last updated.
|
514
460
|
"""
|
515
461
|
|
516
462
|
__tablename__ = "locations"
|
517
463
|
|
464
|
+
id: Mapped[intpk]
|
518
465
|
org_id: Mapped[int] = mapped_column(ForeignKey("orgs.id"))
|
519
466
|
name: Mapped[str]
|
520
467
|
description: Mapped[Optional[text]]
|
@@ -527,8 +474,8 @@ class Location(Base):
|
|
527
474
|
address_zip: Mapped[Optional[str]]
|
528
475
|
address_country: Mapped[Optional[str]]
|
529
476
|
meta: Mapped[Optional[Dict[str, Any]]]
|
530
|
-
|
531
|
-
|
477
|
+
created: Mapped[dt_create]
|
478
|
+
updated: Mapped[dt_update]
|
532
479
|
|
533
480
|
|
534
481
|
class Event(Base):
|
@@ -536,6 +483,7 @@ class Event(Base):
|
|
536
483
|
Model representing an event or series; the same model is used for both with a self-referential relationship for series.
|
537
484
|
|
538
485
|
Attributes:
|
486
|
+
id (int): Primary Key of the model.
|
539
487
|
org_id (int): The ID of the associated organization.
|
540
488
|
location_id (Optional[int]): The ID of the associated location.
|
541
489
|
series_id (Optional[int]): The ID of the associated event series.
|
@@ -561,20 +509,13 @@ class Event(Base):
|
|
561
509
|
preblast_ts (Optional[float]): The Slack post timestamp of the pre-event announcement.
|
562
510
|
backblast_ts (Optional[float]): The Slack post timestamp of the post-event report.
|
563
511
|
meta (Optional[Dict[str, Any]]): Additional metadata for the event.
|
564
|
-
|
565
|
-
|
566
|
-
event_type (EventType): The event type associated with this event.
|
567
|
-
event_tag (EventTag): Any event tags associated with this event.
|
568
|
-
series (Event): The event series associated with this event.
|
569
|
-
attendance (List[Attendance]): The attendance records for this event.
|
570
|
-
event_tags_x_event (List[EventTag_x_Event]): The event tags associated with this event.
|
571
|
-
event_types_x_event (List[EventType_x_Event]): The event types associated with this event.
|
572
|
-
event_tags (List[EventTag]): The event tags associated with this event.
|
573
|
-
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.
|
574
514
|
"""
|
575
515
|
|
576
516
|
__tablename__ = "events"
|
577
517
|
|
518
|
+
id: Mapped[intpk]
|
578
519
|
org_id: Mapped[int] = mapped_column(ForeignKey("orgs.id"))
|
579
520
|
location_id: Mapped[Optional[int]] = mapped_column(ForeignKey("locations.id"))
|
580
521
|
series_id: Mapped[Optional[int]] = mapped_column(ForeignKey("events.id"))
|
@@ -600,30 +541,8 @@ class Event(Base):
|
|
600
541
|
preblast_ts: Mapped[Optional[float]]
|
601
542
|
backblast_ts: Mapped[Optional[float]]
|
602
543
|
meta: Mapped[Optional[Dict[str, Any]]]
|
603
|
-
|
604
|
-
|
605
|
-
location: Mapped["Location"] = relationship(back_populates="events", lazy="joined")
|
606
|
-
series: Mapped["Event"] = relationship(
|
607
|
-
back_populates="events", remote_side="Event.id", lazy="joined"
|
608
|
-
)
|
609
|
-
occurences: Mapped[List["Event"]] = relationship(
|
610
|
-
back_populates="series", lazy="joined"
|
611
|
-
)
|
612
|
-
attendance: Mapped[List["Attendance"]] = relationship(
|
613
|
-
back_populates="events", lazy="joined"
|
614
|
-
)
|
615
|
-
event_tags_x_event: Mapped[List["EventTag_x_Event"]] = relationship(
|
616
|
-
back_populates="events"
|
617
|
-
)
|
618
|
-
event_types_x_event: Mapped[List["EventType_x_Event"]] = relationship(
|
619
|
-
back_populates="events"
|
620
|
-
)
|
621
|
-
event_tags: Mapped[List["EventTag"]] = relationship(
|
622
|
-
back_populates="event", secondary="event_tags_x_event", lazy="joined"
|
623
|
-
)
|
624
|
-
event_types: Mapped[List["EventType"]] = relationship(
|
625
|
-
back_populates="event", secondary="event_types_x_event", lazy="joined"
|
626
|
-
)
|
544
|
+
created: Mapped[dt_create]
|
545
|
+
updated: Mapped[dt_update]
|
627
546
|
|
628
547
|
|
629
548
|
class AttendanceType(Base):
|
@@ -637,8 +556,11 @@ class AttendanceType(Base):
|
|
637
556
|
|
638
557
|
__tablename__ = "attendance_types"
|
639
558
|
|
559
|
+
id: Mapped[intpk]
|
640
560
|
type: Mapped[str]
|
641
561
|
description: Mapped[Optional[str]]
|
562
|
+
created: Mapped[dt_create]
|
563
|
+
updated: Mapped[dt_update]
|
642
564
|
|
643
565
|
|
644
566
|
class Attendance(Base):
|
@@ -651,29 +573,21 @@ class Attendance(Base):
|
|
651
573
|
attendance_type_id (int): The ID of the associated attendance type.
|
652
574
|
is_planned (bool): Whether this is planned attendance (True) vs actual attendance (False).
|
653
575
|
meta (Optional[Dict[str, Any]]): Additional metadata for the attendance.
|
654
|
-
|
655
|
-
|
656
|
-
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.
|
657
578
|
"""
|
658
579
|
|
659
580
|
__tablename__ = "attendance"
|
660
|
-
__table_args__ = (
|
661
|
-
UniqueConstraint(
|
662
|
-
"event_id", "user_id", "is_planned", name="_event_user_planned_uc"
|
663
|
-
),
|
664
|
-
)
|
665
|
-
|
666
|
-
event_id: Mapped[int] = mapped_column(ForeignKey("events.id"))
|
667
|
-
user_id: Mapped[Optional[int]] = mapped_column(ForeignKey("users.id"))
|
668
|
-
attendance_type_id: Mapped[int] = mapped_column(ForeignKey("attendance_types.id"))
|
669
|
-
is_planned: Mapped[bool]
|
670
|
-
meta: Mapped[Optional[Dict[str, Any]]]
|
671
581
|
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
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
|
676
588
|
)
|
589
|
+
is_planned: Mapped[bool] = mapped_column(Boolean, primary_key=True)
|
590
|
+
meta: Mapped[Optional[Dict[str, Any]]]
|
677
591
|
|
678
592
|
|
679
593
|
class User(Base):
|
@@ -681,6 +595,7 @@ class User(Base):
|
|
681
595
|
Model representing a user.
|
682
596
|
|
683
597
|
Attributes:
|
598
|
+
id (int): Primary Key of the model.
|
684
599
|
f3_name (Optional[str]): The F3 name of the user.
|
685
600
|
first_name (Optional[str]): The first name of the user.
|
686
601
|
last_name (Optional[str]): The last name of the user.
|
@@ -689,18 +604,13 @@ class User(Base):
|
|
689
604
|
home_region_id (Optional[int]): The ID of the home region.
|
690
605
|
avatar_url (Optional[str]): The URL of the user's avatar.
|
691
606
|
meta (Optional[Dict[str, Any]]): Additional metadata for the user.
|
692
|
-
|
693
|
-
|
694
|
-
slack_users (List[SlackUser]): The Slack users associated with this user.
|
695
|
-
achievements_x_user (List[Achievement_x_User]): The achievements associated with this user.
|
696
|
-
positions_x_orgs_x_users (List[Position_x_Org_x_User]): The positions associated with this user.
|
697
|
-
roles_x_users_x_org (List[Role_x_User_x_Org]): The roles associated with this user.
|
698
|
-
positions (List[Position]): The positions associated with this user.
|
699
|
-
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.
|
700
609
|
"""
|
701
610
|
|
702
611
|
__tablename__ = "users"
|
703
612
|
|
613
|
+
id: Mapped[intpk]
|
704
614
|
f3_name: Mapped[Optional[str]]
|
705
615
|
first_name: Mapped[Optional[str]]
|
706
616
|
last_name: Mapped[Optional[str]]
|
@@ -709,32 +619,8 @@ class User(Base):
|
|
709
619
|
home_region_id: Mapped[Optional[int]] = mapped_column(ForeignKey("orgs.id"))
|
710
620
|
avatar_url: Mapped[Optional[str]]
|
711
621
|
meta: Mapped[Optional[Dict[str, Any]]]
|
712
|
-
|
713
|
-
|
714
|
-
attendance: Mapped[List["Attendance"]] = relationship(
|
715
|
-
back_populates="users", lazy="joined"
|
716
|
-
)
|
717
|
-
slack_users: Mapped[List["SlackUser"]] = relationship(
|
718
|
-
back_populates="users", lazy="joined"
|
719
|
-
)
|
720
|
-
achievements_x_user: Mapped[List["Achievement_x_User"]] = relationship(
|
721
|
-
back_populates="user"
|
722
|
-
)
|
723
|
-
positions_x_orgs_x_users: Mapped[List["Position_x_Org_x_User"]] = relationship(
|
724
|
-
back_populates="user"
|
725
|
-
)
|
726
|
-
roles_x_users_x_org: Mapped[List["Role_x_User_x_Org"]] = relationship(
|
727
|
-
back_populates="user"
|
728
|
-
)
|
729
|
-
achievements: Mapped[List["Achievement"]] = relationship(
|
730
|
-
back_populates="user", secondary="achievements_x_users", lazy="joined"
|
731
|
-
)
|
732
|
-
positions: Mapped[List["Position"]] = relationship(
|
733
|
-
back_populates="user", secondary="positions_x_orgs_x_users", lazy="joined"
|
734
|
-
)
|
735
|
-
roles: Mapped[List["Role"]] = relationship(
|
736
|
-
back_populates="user", secondary="roles_x_users_x_org", lazy="joined"
|
737
|
-
)
|
622
|
+
created: Mapped[dt_create]
|
623
|
+
updated: Mapped[dt_update]
|
738
624
|
|
739
625
|
|
740
626
|
class SlackUser(Base):
|
@@ -742,6 +628,7 @@ class SlackUser(Base):
|
|
742
628
|
Model representing a Slack user.
|
743
629
|
|
744
630
|
Attributes:
|
631
|
+
id (int): Primary Key of the model.
|
745
632
|
slack_id (str): The Slack ID of the user.
|
746
633
|
user_name (str): The username of the Slack user.
|
747
634
|
email (str): The email of the Slack user.
|
@@ -757,12 +644,13 @@ class SlackUser(Base):
|
|
757
644
|
strava_athlete_id (Optional[int]): The Strava athlete ID of the user.
|
758
645
|
meta (Optional[Dict[str, Any]]): Additional metadata for the Slack user.
|
759
646
|
slack_updated (Optional[datetime]): The last update time of the Slack user.
|
760
|
-
|
761
|
-
|
647
|
+
created (datetime): The timestamp when the record was created.
|
648
|
+
updated (datetime): The timestamp when the record was last updated.
|
762
649
|
"""
|
763
650
|
|
764
651
|
__tablename__ = "slack_users"
|
765
652
|
|
653
|
+
id: Mapped[intpk]
|
766
654
|
slack_id: Mapped[str]
|
767
655
|
user_name: Mapped[str]
|
768
656
|
email: Mapped[str]
|
@@ -778,11 +666,8 @@ class SlackUser(Base):
|
|
778
666
|
strava_athlete_id: Mapped[Optional[int]]
|
779
667
|
meta: Mapped[Optional[Dict[str, Any]]]
|
780
668
|
slack_updated: Mapped[Optional[datetime]]
|
781
|
-
|
782
|
-
|
783
|
-
back_populates="slack_users", lazy="joined"
|
784
|
-
)
|
785
|
-
user: Mapped["User"] = relationship(back_populates="slack_users", lazy="joined")
|
669
|
+
created: Mapped[dt_create]
|
670
|
+
updated: Mapped[dt_update]
|
786
671
|
|
787
672
|
|
788
673
|
class Achievement(Base):
|
@@ -790,18 +675,24 @@ class Achievement(Base):
|
|
790
675
|
Model representing an achievement.
|
791
676
|
|
792
677
|
Attributes:
|
678
|
+
id (int): Primary Key of the model.
|
793
679
|
name (str): The name of the achievement.
|
794
680
|
description (Optional[str]): A description of the achievement.
|
795
681
|
verb (str): The verb associated with the achievement.
|
796
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.
|
797
685
|
"""
|
798
686
|
|
799
687
|
__tablename__ = "achievements"
|
800
688
|
|
689
|
+
id: Mapped[intpk]
|
801
690
|
name: Mapped[str]
|
802
691
|
description: Mapped[Optional[str]]
|
803
692
|
verb: Mapped[str]
|
804
693
|
image_url: Mapped[Optional[str]]
|
694
|
+
created: Mapped[dt_create]
|
695
|
+
updated: Mapped[dt_update]
|
805
696
|
|
806
697
|
|
807
698
|
class Achievement_x_User(Base):
|
@@ -811,25 +702,17 @@ class Achievement_x_User(Base):
|
|
811
702
|
Attributes:
|
812
703
|
achievement_id (int): The ID of the associated achievement.
|
813
704
|
user_id (int): The ID of the associated user.
|
814
|
-
date_awarded (date): The date the achievement was awarded.
|
815
|
-
achievement (Achievement): The achievement associated with this relationship.
|
816
|
-
user (User): The user associated with this relationship.
|
705
|
+
date_awarded (date): The date the achievement was awarded. Default is the current date.
|
817
706
|
"""
|
818
707
|
|
819
708
|
__tablename__ = "achievements_x_users"
|
820
|
-
__table_args__ = (
|
821
|
-
UniqueConstraint("achievement_id", "user_id", name="_achievement_user_uc"),
|
822
|
-
)
|
823
|
-
|
824
|
-
achievement_id: Mapped[int] = mapped_column(ForeignKey("achievements.id"))
|
825
|
-
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"))
|
826
|
-
date_awarded: Mapped[date]
|
827
709
|
|
828
|
-
|
829
|
-
|
710
|
+
achievement_id: Mapped[int] = mapped_column(
|
711
|
+
ForeignKey("achievements.id"), primary_key=True
|
830
712
|
)
|
831
|
-
|
832
|
-
|
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())
|
833
716
|
)
|
834
717
|
|
835
718
|
|
@@ -840,22 +723,14 @@ class Achievement_x_Org(Base):
|
|
840
723
|
Attributes:
|
841
724
|
achievement_id (int): The ID of the associated achievement.
|
842
725
|
org_id (int): The ID of the associated organization.
|
843
|
-
achievement (Achievement): The achievement associated with this relationship.
|
844
|
-
org (Org): The organization associated with this relationship.
|
845
726
|
"""
|
846
727
|
|
847
728
|
__tablename__ = "achievements_x_org"
|
848
|
-
__table_args__ = (
|
849
|
-
UniqueConstraint("achievement_id", "org_id", name="_achievement_org_uc"),
|
850
|
-
)
|
851
|
-
|
852
|
-
achievement_id: Mapped[int] = mapped_column(ForeignKey("achievements.id"))
|
853
|
-
org_id: Mapped[int] = mapped_column(ForeignKey("orgs.id"))
|
854
729
|
|
855
|
-
|
856
|
-
|
730
|
+
achievement_id: Mapped[int] = mapped_column(
|
731
|
+
ForeignKey("achievements.id"), primary_key=True
|
857
732
|
)
|
858
|
-
|
733
|
+
org_id: Mapped[int] = mapped_column(ForeignKey("orgs.id"), primary_key=True)
|
859
734
|
|
860
735
|
|
861
736
|
class Position(Base):
|
@@ -871,10 +746,13 @@ class Position(Base):
|
|
871
746
|
|
872
747
|
__tablename__ = "positions"
|
873
748
|
|
749
|
+
id: Mapped[intpk]
|
874
750
|
name: Mapped[str]
|
875
751
|
description: Mapped[Optional[str]]
|
876
752
|
org_type_id: Mapped[Optional[int]] = mapped_column(ForeignKey("org_types.id"))
|
877
753
|
org_id: Mapped[Optional[int]] = mapped_column(ForeignKey("orgs.id"))
|
754
|
+
created: Mapped[dt_create]
|
755
|
+
updated: Mapped[dt_update]
|
878
756
|
|
879
757
|
|
880
758
|
class Position_x_Org_x_User(Base):
|
@@ -885,31 +763,15 @@ class Position_x_Org_x_User(Base):
|
|
885
763
|
position_id (int): The ID of the associated position.
|
886
764
|
org_id (int): The ID of the associated organization.
|
887
765
|
user_id (int): The ID of the associated user.
|
888
|
-
position (Position): The position associated with this relationship.
|
889
|
-
org (Org): The organization associated with this relationship.
|
890
|
-
user (User): The user associated with this relationship.
|
891
766
|
"""
|
892
767
|
|
893
768
|
__tablename__ = "positions_x_orgs_x_users"
|
894
|
-
__table_args__ = (
|
895
|
-
UniqueConstraint(
|
896
|
-
"position_id", "user_id", "org_id", name="_position_user_org_uc"
|
897
|
-
),
|
898
|
-
)
|
899
|
-
|
900
|
-
position_id: Mapped[int] = mapped_column(ForeignKey("positions.id"))
|
901
|
-
org_id: Mapped[int] = mapped_column(ForeignKey("orgs.id"))
|
902
|
-
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"))
|
903
769
|
|
904
|
-
|
905
|
-
|
906
|
-
)
|
907
|
-
org: Mapped["Org"] = relationship(
|
908
|
-
back_populates="position_x_org_x_user", lazy="joined"
|
909
|
-
)
|
910
|
-
user: Mapped["User"] = relationship(
|
911
|
-
back_populates="position_x_org_x_user", lazy="joined"
|
770
|
+
position_id: Mapped[int] = mapped_column(
|
771
|
+
ForeignKey("positions.id"), primary_key=True
|
912
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)
|
913
775
|
|
914
776
|
|
915
777
|
class Expansion(Base):
|
@@ -917,22 +779,28 @@ class Expansion(Base):
|
|
917
779
|
Model representing an expansion.
|
918
780
|
|
919
781
|
Attributes:
|
782
|
+
id (int): Primary Key of the model.
|
920
783
|
area (str): The area of the expansion.
|
921
784
|
pinned_lat (float): The pinned latitude of the expansion.
|
922
785
|
pinned_lon (float): The pinned longitude of the expansion.
|
923
786
|
user_lat (float): The user's latitude.
|
924
787
|
user_lon (float): The user's longitude.
|
925
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.
|
926
791
|
"""
|
927
792
|
|
928
793
|
__tablename__ = "expansions"
|
929
794
|
|
795
|
+
id: Mapped[intpk]
|
930
796
|
area: Mapped[str]
|
931
797
|
pinned_lat: Mapped[float]
|
932
798
|
pinned_lon: Mapped[float]
|
933
799
|
user_lat: Mapped[float]
|
934
800
|
user_lon: Mapped[float]
|
935
801
|
interested_in_organizing: Mapped[bool]
|
802
|
+
created: Mapped[dt_create]
|
803
|
+
updated: Mapped[dt_update]
|
936
804
|
|
937
805
|
|
938
806
|
class Expansion_x_User(Base):
|
@@ -942,25 +810,124 @@ class Expansion_x_User(Base):
|
|
942
810
|
Attributes:
|
943
811
|
expansion_id (int): The ID of the associated expansion.
|
944
812
|
user_id (int): The ID of the associated user.
|
945
|
-
|
813
|
+
requst_date (date): The date of the request. Default is the current date.
|
946
814
|
notes (Optional[text]): Additional notes for the association.
|
947
|
-
expansion (Expansion): The expansion associated with this relationship.
|
948
|
-
user (User): The user associated with this relationship.
|
949
815
|
"""
|
950
816
|
|
951
817
|
__tablename__ = "expansions_x_users"
|
952
|
-
__table_args__ = (
|
953
|
-
UniqueConstraint("expansion_id", "user_id", name="_expansion_user_uc"),
|
954
|
-
)
|
955
818
|
|
956
|
-
expansion_id: Mapped[int] = mapped_column(
|
957
|
-
|
958
|
-
date: Mapped[date]
|
959
|
-
notes: Mapped[Optional[text]]
|
960
|
-
|
961
|
-
expansion: Mapped["Expansion"] = relationship(
|
962
|
-
back_populates="expansion_x_user", lazy="joined"
|
819
|
+
expansion_id: Mapped[int] = mapped_column(
|
820
|
+
ForeignKey("expansions.id"), primary_key=True
|
963
821
|
)
|
964
|
-
|
965
|
-
|
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())
|
966
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]
|
File without changes
|
File without changes
|
File without changes
|