f3-data-models 0.5.7__py3-none-any.whl → 0.5.11__py3-none-any.whl
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/models.py +38 -14
- f3_data_models/testing.py +18 -6
- {f3_data_models-0.5.7.dist-info → f3_data_models-0.5.11.dist-info}/METADATA +32 -1
- f3_data_models-0.5.11.dist-info/RECORD +7 -0
- {f3_data_models-0.5.7.dist-info → f3_data_models-0.5.11.dist-info}/WHEEL +1 -1
- f3_data_models-0.5.7.dist-info/RECORD +0 -7
f3_data_models/models.py
CHANGED
@@ -399,6 +399,7 @@ class Org(Base):
|
|
399
399
|
instagram (Optional[str]): The organization's Instagram handle.
|
400
400
|
last_annual_review (Optional[date]): The date of the last annual review.
|
401
401
|
meta (Optional[Dict[str, Any]]): Additional metadata for the organization.
|
402
|
+
ao_count (int): The number of AOs associated with the organization. Defaults to 0, will be updated by triggers.
|
402
403
|
created (datetime): The timestamp when the record was created.
|
403
404
|
updated (datetime): The timestamp when the record was last updated.
|
404
405
|
|
@@ -427,6 +428,7 @@ class Org(Base):
|
|
427
428
|
instagram: Mapped[Optional[str]]
|
428
429
|
last_annual_review: Mapped[Optional[date]]
|
429
430
|
meta: Mapped[Optional[Dict[str, Any]]]
|
431
|
+
ao_count: Mapped[Optional[int]] = mapped_column(Integer, default=0, nullable=True)
|
430
432
|
created: Mapped[dt_create]
|
431
433
|
updated: Mapped[dt_update]
|
432
434
|
|
@@ -471,6 +473,7 @@ class EventType(Base):
|
|
471
473
|
acronym (Optional[str]): Acronyms associated with the event type.
|
472
474
|
event_category (Event_Category): The category of the event type (first_f, second_f, third_f).
|
473
475
|
specific_org_id (Optional[int]): The ID of the specific organization.
|
476
|
+
is_active (bool): Whether the event type is active. Default is True.
|
474
477
|
created (datetime): The timestamp when the record was created.
|
475
478
|
updated (datetime): The timestamp when the record was last updated.
|
476
479
|
""" # noqa: E501
|
@@ -483,6 +486,7 @@ class EventType(Base):
|
|
483
486
|
acronym: Mapped[Optional[str]]
|
484
487
|
event_category: Mapped[Event_Category]
|
485
488
|
specific_org_id: Mapped[Optional[int]] = mapped_column(ForeignKey("orgs.id"))
|
489
|
+
is_active: Mapped[bool] = mapped_column(Boolean, default=True, nullable=False)
|
486
490
|
created: Mapped[dt_create]
|
487
491
|
updated: Mapped[dt_update]
|
488
492
|
|
@@ -500,7 +504,7 @@ class EventType_x_Event(Base):
|
|
500
504
|
|
501
505
|
__tablename__ = "events_x_event_types"
|
502
506
|
|
503
|
-
event_id: Mapped[int] = mapped_column(ForeignKey("events.id"), primary_key=True)
|
507
|
+
event_id: Mapped[int] = mapped_column(ForeignKey("events.id"), primary_key=True, onupdate="CASCADE")
|
504
508
|
event_type_id: Mapped[int] = mapped_column(ForeignKey("event_types.id"), primary_key=True)
|
505
509
|
__table_args__ = (
|
506
510
|
Index("idx_events_x_event_types_event_id", "event_id"),
|
@@ -523,7 +527,9 @@ class EventType_x_EventInstance(Base):
|
|
523
527
|
|
524
528
|
__tablename__ = "event_instances_x_event_types"
|
525
529
|
|
526
|
-
event_instance_id: Mapped[int] = mapped_column(
|
530
|
+
event_instance_id: Mapped[int] = mapped_column(
|
531
|
+
ForeignKey("event_instances.id"), primary_key=True, onupdate="CASCADE"
|
532
|
+
)
|
527
533
|
event_type_id: Mapped[int] = mapped_column(ForeignKey("event_types.id"), primary_key=True)
|
528
534
|
|
529
535
|
event_instance: Mapped["EventInstance"] = relationship(back_populates="event_instances_x_event_types")
|
@@ -567,7 +573,7 @@ class EventTag_x_Event(Base):
|
|
567
573
|
|
568
574
|
__tablename__ = "event_tags_x_events"
|
569
575
|
|
570
|
-
event_id: Mapped[int] = mapped_column(ForeignKey("events.id"), primary_key=True)
|
576
|
+
event_id: Mapped[int] = mapped_column(ForeignKey("events.id"), primary_key=True, onupdate="CASCADE")
|
571
577
|
event_tag_id: Mapped[int] = mapped_column(ForeignKey("event_tags.id"), primary_key=True)
|
572
578
|
|
573
579
|
event: Mapped["Event"] = relationship(back_populates="event_x_event_tags")
|
@@ -586,7 +592,9 @@ class EventTag_x_EventInstance(Base):
|
|
586
592
|
|
587
593
|
__tablename__ = "event_tags_x_event_instances"
|
588
594
|
|
589
|
-
event_instance_id: Mapped[int] = mapped_column(
|
595
|
+
event_instance_id: Mapped[int] = mapped_column(
|
596
|
+
ForeignKey("event_instances.id"), primary_key=True, onupdate="CASCADE"
|
597
|
+
)
|
590
598
|
event_tag_id: Mapped[int] = mapped_column(ForeignKey("event_tags.id"), primary_key=True)
|
591
599
|
|
592
600
|
event_instance: Mapped["EventInstance"] = relationship(back_populates="event_instances_x_event_tags")
|
@@ -735,10 +743,12 @@ class Event(Base):
|
|
735
743
|
secondary="event_tags_x_events", cascade="expunge", viewonly=True
|
736
744
|
)
|
737
745
|
event_x_event_types: Mapped[List[EventType_x_Event]] = relationship(
|
738
|
-
back_populates="event",
|
746
|
+
back_populates="event",
|
747
|
+
passive_deletes=True,
|
739
748
|
)
|
740
749
|
event_x_event_tags: Mapped[Optional[List[EventTag_x_Event]]] = relationship(
|
741
|
-
back_populates="event",
|
750
|
+
back_populates="event",
|
751
|
+
passive_deletes=True,
|
742
752
|
)
|
743
753
|
|
744
754
|
|
@@ -781,11 +791,16 @@ class EventInstance(Base):
|
|
781
791
|
""" # noqa: E501
|
782
792
|
|
783
793
|
__tablename__ = "event_instances"
|
794
|
+
__table_args__ = (
|
795
|
+
Index("idx_event_instances_org_id", "org_id"),
|
796
|
+
Index("idx_event_instances_location_id", "location_id"),
|
797
|
+
Index("idx_event_instances_is_active", "is_active"),
|
798
|
+
)
|
784
799
|
|
785
800
|
id: Mapped[intpk]
|
786
801
|
org_id: Mapped[int] = mapped_column(ForeignKey("orgs.id"))
|
787
802
|
location_id: Mapped[Optional[int]] = mapped_column(ForeignKey("locations.id"))
|
788
|
-
series_id: Mapped[Optional[int]] = mapped_column(ForeignKey("events.id"))
|
803
|
+
series_id: Mapped[Optional[int]] = mapped_column(ForeignKey("events.id"), onupdate="CASCADE")
|
789
804
|
is_active: Mapped[bool] = mapped_column(Boolean, default=True)
|
790
805
|
highlight: Mapped[bool] = mapped_column(Boolean, default=False)
|
791
806
|
start_date: Mapped[date]
|
@@ -825,12 +840,14 @@ class EventInstance(Base):
|
|
825
840
|
secondary="event_tags_x_event_instances", cascade="expunge", viewonly=True
|
826
841
|
)
|
827
842
|
event_instances_x_event_types: Mapped[List[EventType_x_EventInstance]] = relationship(
|
828
|
-
back_populates="event_instance",
|
843
|
+
back_populates="event_instance",
|
844
|
+
passive_deletes=True,
|
829
845
|
)
|
830
846
|
event_instances_x_event_tags: Mapped[Optional[List[EventTag_x_EventInstance]]] = relationship(
|
831
|
-
back_populates="event_instance",
|
847
|
+
back_populates="event_instance",
|
848
|
+
passive_deletes=True,
|
832
849
|
)
|
833
|
-
attendance: Mapped[List["Attendance"]] = relationship(back_populates="event_instance",
|
850
|
+
attendance: Mapped[List["Attendance"]] = relationship(back_populates="event_instance", passive_deletes=True)
|
834
851
|
|
835
852
|
|
836
853
|
class AttendanceType(Base):
|
@@ -864,7 +881,7 @@ class Attendance_x_AttendanceType(Base):
|
|
864
881
|
|
865
882
|
__tablename__ = "attendance_x_attendance_types"
|
866
883
|
|
867
|
-
attendance_id: Mapped[int] = mapped_column(ForeignKey("attendance.id"), primary_key=True)
|
884
|
+
attendance_id: Mapped[int] = mapped_column(ForeignKey("attendance.id"), primary_key=True, onupdate="CASCADE")
|
868
885
|
attendance_type_id: Mapped[int] = mapped_column(ForeignKey("attendance_types.id"), primary_key=True)
|
869
886
|
|
870
887
|
attendance: Mapped["Attendance"] = relationship(back_populates="attendance_x_attendance_types")
|
@@ -980,10 +997,15 @@ class Attendance(Base):
|
|
980
997
|
""" # noqa: E501
|
981
998
|
|
982
999
|
__tablename__ = "attendance"
|
983
|
-
__table_args__ = (
|
1000
|
+
__table_args__ = (
|
1001
|
+
UniqueConstraint("event_instance_id", "user_id", "is_planned"),
|
1002
|
+
Index("idx_attendance_event_instance_id", "event_instance_id"),
|
1003
|
+
Index("idx_attendance_user_id", "user_id"),
|
1004
|
+
Index("idx_attendance_is_planned", "is_planned"),
|
1005
|
+
)
|
984
1006
|
|
985
1007
|
id: Mapped[intpk]
|
986
|
-
event_instance_id: Mapped[int] = mapped_column(ForeignKey("event_instances.id"))
|
1008
|
+
event_instance_id: Mapped[int] = mapped_column(ForeignKey("event_instances.id"), onupdate="CASCADE")
|
987
1009
|
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"))
|
988
1010
|
is_planned: Mapped[bool]
|
989
1011
|
meta: Mapped[Optional[Dict[str, Any]]]
|
@@ -996,7 +1018,7 @@ class Attendance(Base):
|
|
996
1018
|
innerjoin=False, cascade="expunge", secondary="users", viewonly=True
|
997
1019
|
)
|
998
1020
|
attendance_x_attendance_types: Mapped[List[Attendance_x_AttendanceType]] = relationship(
|
999
|
-
back_populates="attendance",
|
1021
|
+
back_populates="attendance", passive_deletes=True
|
1000
1022
|
)
|
1001
1023
|
attendance_types: Mapped[List[AttendanceType]] = relationship(
|
1002
1024
|
secondary="attendance_x_attendance_types",
|
@@ -1258,6 +1280,7 @@ class UpdateRequest(Base):
|
|
1258
1280
|
ao_id (Optional[int]): The ID of the associated AO.
|
1259
1281
|
ao_name (Optional[text]): The name of the AO.
|
1260
1282
|
ao_logo (Optional[text]): The URL of the AO logo.
|
1283
|
+
ao_website (Optional[text]): The website of the AO.
|
1261
1284
|
submitted_by (str): The user who submitted the request.
|
1262
1285
|
submitter_validated (Optional[bool]): Whether the submitter has validated the request. Default is False.
|
1263
1286
|
reviewed_by (Optional[str]): The user who reviewed the request.
|
@@ -1310,6 +1333,7 @@ class UpdateRequest(Base):
|
|
1310
1333
|
ao_id: Mapped[Optional[int]] = mapped_column(ForeignKey("orgs.id"))
|
1311
1334
|
ao_name: Mapped[Optional[text]]
|
1312
1335
|
ao_logo: Mapped[Optional[text]]
|
1336
|
+
ao_website: Mapped[Optional[text]]
|
1313
1337
|
|
1314
1338
|
submitted_by: Mapped[text]
|
1315
1339
|
submitter_validated: Mapped[Optional[bool]] = mapped_column(Boolean, default=False)
|
f3_data_models/testing.py
CHANGED
@@ -1,12 +1,24 @@
|
|
1
|
-
from
|
1
|
+
from datetime import date
|
2
|
+
|
3
|
+
from sqlalchemy import or_
|
4
|
+
|
5
|
+
from f3_data_models.models import Event, Org
|
2
6
|
from f3_data_models.utils import DbManager
|
3
7
|
|
4
8
|
|
5
|
-
def
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
+
def test():
|
10
|
+
org_id = 25272
|
11
|
+
event_records = DbManager.find_records(
|
12
|
+
Event,
|
13
|
+
filters=[
|
14
|
+
Event.is_active,
|
15
|
+
or_(Event.org_id == org_id, Event.org.has(Org.parent_id == org_id)),
|
16
|
+
or_(Event.end_date >= date.today(), Event.end_date.is_(None)),
|
17
|
+
],
|
18
|
+
joinedloads="all",
|
19
|
+
)
|
20
|
+
print(f"Found {len(event_records)} active events for org_id {org_id}.")
|
9
21
|
|
10
22
|
|
11
23
|
if __name__ == "__main__":
|
12
|
-
|
24
|
+
test()
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: f3-data-models
|
3
|
-
Version: 0.5.
|
3
|
+
Version: 0.5.11
|
4
4
|
Summary: The data schema and models for F3 Nation applications.
|
5
5
|
License: MIT
|
6
6
|
Author: Evan Petzoldt
|
@@ -81,3 +81,34 @@ poetry run python -m http.server --directory _build/html
|
|
81
81
|
|
82
82
|
> [!TIP]
|
83
83
|
> Adding new fields as nullable (ie `Optional[]`) has the best chance of reducing breaking changes to the apps.
|
84
|
+
|
85
|
+
# Entity Overview
|
86
|
+
|
87
|
+
```mermaid
|
88
|
+
---
|
89
|
+
config:
|
90
|
+
look: handDrawn
|
91
|
+
theme: dark
|
92
|
+
---
|
93
|
+
|
94
|
+
erDiagram
|
95
|
+
USERS ||--|{ ATTENDANCE : have
|
96
|
+
ATTENDANCE }|--|| EVENT_INSTANCES: at
|
97
|
+
ATTENDANCE }|..|{ ATTENDANCE_TYPES : "are of type(s)"
|
98
|
+
EVENT_INSTANCES }|..|| EVENTS : "part of series"
|
99
|
+
EVENT_INSTANCES }|..|{ EVENT_TYPES : "with type(s)"
|
100
|
+
EVENTS }|..|{ EVENT_TYPES : "with type(s)"
|
101
|
+
EVENT_INSTANCES }|--|| ORGS : "belong to"
|
102
|
+
EVENT_INSTANCES }|..|| LOCATIONS : "at"
|
103
|
+
EVENTS }|--|| ORGS : "belong to"
|
104
|
+
EVENTS }|..|| LOCATIONS : "at"
|
105
|
+
SLACK_SPACES ||..|| ORGS : "are connected to"
|
106
|
+
USERS ||..|{ SLACK_USERS : "have one or more"
|
107
|
+
SLACK_USERS }|--|| SLACK_SPACES : "belong to"
|
108
|
+
USERS }|..|{ ACHIEVEMENTS : "earn"
|
109
|
+
USERS }|..|{ ROLES : "have"
|
110
|
+
ROLES ||..|{ PERMISSIONS : "have"
|
111
|
+
ROLES }|..|{ ORGS : "in"
|
112
|
+
USERS }|..|{ POSITIONS : "hold"
|
113
|
+
POSITIONS }|..|{ ORGS : "in"
|
114
|
+
```
|
@@ -0,0 +1,7 @@
|
|
1
|
+
f3_data_models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
+
f3_data_models/models.py,sha256=V1GZQWMTp6T91r_YIwqtBGb7dIPjhhZxFl6CxKvuDg8,52607
|
3
|
+
f3_data_models/testing.py,sha256=uHHgrfMOpUvu6-yOyuMsGadyeN-zuAFRYuGQNpXX4Lk,598
|
4
|
+
f3_data_models/utils.py,sha256=LBNy7BXwRY0tqNKGUBoYi6-1Ch9dSLjGysLoes1Jfys,12083
|
5
|
+
f3_data_models-0.5.11.dist-info/METADATA,sha256=KBad-92ZziqtZivm7q5WY8PBzP8gcaMybT0fMkqk_nU,3675
|
6
|
+
f3_data_models-0.5.11.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
7
|
+
f3_data_models-0.5.11.dist-info/RECORD,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
f3_data_models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
f3_data_models/models.py,sha256=Nd57_jd5lkVbTfj2CZ_Eg4AfVVa7QjK86Ko7qYlrT1I,51616
|
3
|
-
f3_data_models/testing.py,sha256=xDTZdEo5BXx8zzXCBsadxtN2wNnK9tj0w_HYL3pFl3A,314
|
4
|
-
f3_data_models/utils.py,sha256=LBNy7BXwRY0tqNKGUBoYi6-1Ch9dSLjGysLoes1Jfys,12083
|
5
|
-
f3_data_models-0.5.7.dist-info/METADATA,sha256=9K6BEPYZ0OIEl41sX7IBZcyjOuUNRPyCVVYJo4CjUvM,2766
|
6
|
-
f3_data_models-0.5.7.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
|
7
|
-
f3_data_models-0.5.7.dist-info/RECORD,,
|