f3-data-models 0.2.5__tar.gz → 0.3.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: f3-data-models
3
- Version: 0.2.5
3
+ Version: 0.3.1
4
4
  Summary: The data schema and models for F3 Nation applications.
5
5
  License: MIT
6
6
  Author: Evan Petzoldt
@@ -11,6 +11,7 @@ Classifier: Programming Language :: Python :: 3
11
11
  Classifier: Programming Language :: Python :: 3.12
12
12
  Classifier: Programming Language :: Python :: 3.13
13
13
  Requires-Dist: alembic (>=1.14.0,<2.0.0)
14
+ Requires-Dist: alembic-postgresql-enum (>=1.6.1,<2.0.0)
14
15
  Requires-Dist: cloud-sql-python-connector (>=1.13.0,<2.0.0)
15
16
  Requires-Dist: graphviz (>=0.20.3,<0.21.0)
16
17
  Requires-Dist: pg8000 (>=1.31.2,<2.0.0)
@@ -68,7 +69,8 @@ poetry version patch[minor][major]
68
69
  git tag <new_version> -a -m "Your message here"
69
70
  git push origin --tags
70
71
  ```
71
- > [!NOTE] The github pages documentation will be updated when you push to `main`, but if you would like to preview locally, run:
72
+ > [!NOTE]
73
+ > The github pages documentation will be updated when you push to `main`, but if you would like to preview locally, run:
72
74
 
73
75
  ```sh
74
76
  poetry run sphinx-build -b html docs docs/_build/html
@@ -40,7 +40,8 @@ poetry version patch[minor][major]
40
40
  git tag <new_version> -a -m "Your message here"
41
41
  git push origin --tags
42
42
  ```
43
- > [!NOTE] The github pages documentation will be updated when you push to `main`, but if you would like to preview locally, run:
43
+ > [!NOTE]
44
+ > The github pages documentation will be updated when you push to `main`, but if you would like to preview locally, run:
44
45
 
45
46
  ```sh
46
47
  poetry run sphinx-build -b html docs docs/_build/html
@@ -1,16 +1,22 @@
1
1
  from datetime import datetime, date, time
2
2
  from typing import Any, Dict, List, Optional
3
+ import uuid
3
4
  from sqlalchemy import (
5
+ ARRAY,
4
6
  JSON,
5
7
  TEXT,
6
8
  TIME,
9
+ UUID,
7
10
  VARCHAR,
8
11
  Boolean,
9
12
  DateTime,
13
+ Float,
10
14
  ForeignKey,
11
15
  Integer,
12
16
  func,
13
17
  UniqueConstraint,
18
+ Enum,
19
+ Uuid,
14
20
  )
15
21
  from typing_extensions import Annotated
16
22
  from sqlalchemy.orm import (
@@ -19,9 +25,11 @@ from sqlalchemy.orm import (
19
25
  Mapped,
20
26
  relationship,
21
27
  )
28
+ import enum
22
29
 
23
30
  # Custom Annotations
24
- time_notz = Annotated[time, TIME]
31
+ time_notz = Annotated[time, TIME(timezone=False)]
32
+ time_with_tz = Annotated[time, TIME(timezone=True)]
25
33
  text = Annotated[str, TEXT]
26
34
  intpk = Annotated[int, mapped_column(Integer, primary_key=True, autoincrement=True)]
27
35
  dt_create = Annotated[
@@ -37,6 +45,40 @@ dt_update = Annotated[
37
45
  ]
38
46
 
39
47
 
48
+ class User_Status(enum.Enum):
49
+ active = 1
50
+ inactive = 2
51
+ deleted = 3
52
+
53
+
54
+ class Region_Role(enum.Enum):
55
+ user = 1
56
+ editor = 2
57
+ admin = 3
58
+
59
+
60
+ class User_Role(enum.Enum):
61
+ user = 1
62
+ editor = 2
63
+ admin = 3
64
+
65
+
66
+ class Update_Request_Status(enum.Enum):
67
+ pending = 1
68
+ approved = 2
69
+ rejected = 3
70
+
71
+
72
+ class Day_Of_Week(enum.Enum):
73
+ monday = 0
74
+ tuesday = 1
75
+ wednesday = 2
76
+ thursday = 3
77
+ friday = 4
78
+ saturday = 5
79
+ sunday = 6
80
+
81
+
40
82
  class Base(DeclarativeBase):
41
83
  """
42
84
  Base class for all models, providing common methods.
@@ -187,7 +229,7 @@ class Role(Base):
187
229
 
188
230
  Attributes:
189
231
  id (int): Primary Key of the model.
190
- name (str): The name of the role.
232
+ name (Region_Role): The name of the role.
191
233
  description (Optional[text]): A description of the role.
192
234
  created (datetime): The timestamp when the record was created.
193
235
  updated (datetime): The timestamp when the record was last updated.
@@ -196,7 +238,7 @@ class Role(Base):
196
238
  __tablename__ = "roles"
197
239
 
198
240
  id: Mapped[intpk]
199
- name: Mapped[str]
241
+ name: Mapped[Region_Role]
200
242
  description: Mapped[Optional[text]]
201
243
  created: Mapped[dt_create]
202
244
  updated: Mapped[dt_update]
@@ -514,8 +556,12 @@ class Location(Base):
514
556
  description: Mapped[Optional[text]]
515
557
  is_active: Mapped[bool]
516
558
  email: Mapped[Optional[str]]
517
- latitude: Mapped[Optional[float]]
518
- longitude: Mapped[Optional[float]]
559
+ latitude: Mapped[Optional[float]] = mapped_column(
560
+ Float(precision=8, decimal_return_scale=5)
561
+ )
562
+ longitude: Mapped[Optional[float]] = mapped_column(
563
+ Float(precision=8, decimal_return_scale=5)
564
+ )
519
565
  address_street: Mapped[Optional[str]]
520
566
  address_street2: Mapped[Optional[str]]
521
567
  address_city: Mapped[Optional[str]]
@@ -541,9 +587,9 @@ class Event(Base):
541
587
  highlight (bool): Whether the event is highlighted. Default is False.
542
588
  start_date (date): The start date of the event.
543
589
  end_date (Optional[date]): The end date of the event.
544
- start_time (Optional[time_notz]): The start time of the event.
545
- end_time (Optional[time_notz]): The end time of the event.
546
- day_of_week (Optional[int]): The day of the week of the event. (0=Monday, 6=Sunday)
590
+ start_time (Optional[time_with_tz]): The start time of the event.
591
+ end_time (Optional[time_with_tz]): The end time of the event.
592
+ day_of_week (Optional[Day_Of_Week]): The day of the week of the event.
547
593
  name (str): The name of the event.
548
594
  description (Optional[text]): A description of the event.
549
595
  email (Optional[str]): A contact email address associated with the event.
@@ -583,7 +629,7 @@ class Event(Base):
583
629
  end_date: Mapped[Optional[date]]
584
630
  start_time: Mapped[Optional[time_notz]]
585
631
  end_time: Mapped[Optional[time_notz]]
586
- day_of_week: Mapped[Optional[int]]
632
+ day_of_week: Mapped[Optional[Day_Of_Week]]
587
633
  name: Mapped[str]
588
634
  description: Mapped[Optional[text]]
589
635
  email: Mapped[Optional[str]]
@@ -680,7 +726,8 @@ class User(Base):
680
726
  home_region_id (Optional[int]): The ID of the home region.
681
727
  avatar_url (Optional[str]): The URL of the user's avatar.
682
728
  meta (Optional[Dict[str, Any]]): Additional metadata for the user.
683
- email_verified_ts (Optional[datetime]): The timestamp when the user's email was verified.
729
+ email_verified (Optional[datetime]): The timestamp when the user's email was verified.
730
+ status (UserStatus): The status of the user. Default is 'active'.
684
731
  created (datetime): The timestamp when the record was created.
685
732
  updated (datetime): The timestamp when the record was last updated.
686
733
  """
@@ -699,7 +746,10 @@ class User(Base):
699
746
  home_region_id: Mapped[Optional[int]] = mapped_column(ForeignKey("orgs.id"))
700
747
  avatar_url: Mapped[Optional[str]]
701
748
  meta: Mapped[Optional[Dict[str, Any]]]
702
- email_verified_ts: Mapped[Optional[datetime]]
749
+ email_verified: Mapped[Optional[datetime]]
750
+ status: Mapped[User_Status] = mapped_column(
751
+ Enum(User_Status), default=User_Status.active
752
+ )
703
753
  created: Mapped[dt_create]
704
754
  updated: Mapped[dt_update]
705
755
 
@@ -956,38 +1006,187 @@ class Expansion_x_User(Base):
956
1006
  notes: Mapped[Optional[text]]
957
1007
 
958
1008
 
959
- # class Org_x_SlackChannel(Base):
960
- # """
961
- # Model representing the association between organizations (specifically AOs) and Slack channels.
1009
+ class NextAuthAccount(Base):
1010
+ """
1011
+ Model representing an authentication account.
962
1012
 
963
- # Attributes:
964
- # org_id (int): The ID of the associated organization.
965
- # slack_channel_id (str): The Slack-internal ID of the associated Slack channel.
966
- # """
1013
+ Attributes:
1014
+ user_id (int): The ID of the associated user.
1015
+ type (text): The type of the account.
1016
+ provider (text): The provider of the account.
1017
+ provider_account_id (text): The provider account ID.
1018
+ refresh_token (Optional[text]): The refresh token.
1019
+ access_token (text): The access token.
1020
+ expires_at (Optional[datetime]): The expiration time of the token.
1021
+ token_type (Optional[text]): The token type.
1022
+ scope (Optional[text]): The scope of the token.
1023
+ id_token (Optional[text]): The ID token.
1024
+ session_state (Optional[text]): The session state.
1025
+ created (datetime): The timestamp when the record was created.
1026
+ updated (datetime): The timestamp when the record was last updated.
1027
+ """
967
1028
 
968
- # __tablename__ = "orgs_x_slack_channels"
1029
+ __tablename__ = "auth_accounts"
969
1030
 
970
- # org_id: Mapped[int] = mapped_column(ForeignKey("orgs.id"), primary_key=True)
971
- # slack_channel_id: Mapped[str] = mapped_column(
972
- # primary_key=True
973
- # ) # Do we need a slack channel table?
1031
+ user_id: Mapped[int] = mapped_column(ForeignKey("users.id"))
1032
+ type: Mapped[text] # need adapter account_type?
1033
+ provider: Mapped[text] = mapped_column(VARCHAR, primary_key=True)
1034
+ provider_account_id: Mapped[text] = mapped_column(VARCHAR, primary_key=True)
1035
+ refresh_token: Mapped[Optional[text]]
1036
+ access_token: Mapped[text]
1037
+ expires_at: Mapped[Optional[datetime]]
1038
+ token_type: Mapped[Optional[text]]
1039
+ scope: Mapped[Optional[text]]
1040
+ id_token: Mapped[Optional[text]]
1041
+ session_state: Mapped[Optional[text]]
1042
+ created: Mapped[dt_create]
1043
+ updated: Mapped[dt_update]
974
1044
 
975
- # class SlackSpaceLog(Base):
976
- # """
977
- # Model representing a log of Slack space events.
978
1045
 
979
- # Attributes:
980
- # id (int): Primary Key of the model.
981
- # slack_space_id (int): The ID of the associated Slack space.
982
- # event (str): The event that occurred.
983
- # data (Optional[Dict[str, Any]]): Additional data for the log.
984
- # created (datetime): The timestamp when the record was created.
985
- # """
1046
+ class NextAuthSession(Base):
1047
+ """
1048
+ Model representing an authentication session.
1049
+
1050
+ Attributes:
1051
+ session_token (text): The session token.
1052
+ user_id (int): The ID of the associated user.
1053
+ expires (date): The expiration time of the session.
1054
+ created (datetime): The timestamp when the record was created.
1055
+ updated (datetime): The timestamp when the record was last updated.
1056
+ """
1057
+
1058
+ __tablename__ = "auth_sessions"
1059
+
1060
+ session_token: Mapped[text] = mapped_column(TEXT, primary_key=True)
1061
+ user_id: Mapped[int] = mapped_column(ForeignKey("users.id"))
1062
+ expires: Mapped[date]
1063
+ created: Mapped[dt_create]
1064
+ updated: Mapped[dt_update]
1065
+
1066
+
1067
+ class NextAuthVerificationToken(Base):
1068
+ """
1069
+ Model representing an authentication verification token.
1070
+
1071
+ Attributes:
1072
+ identifier (text): The identifier of the token.
1073
+ token (text): The token.
1074
+ expires (date): The expiration time of the token.
1075
+ created (datetime): The timestamp when the record was created.
1076
+ updated (datetime): The timestamp when the record was last updated.
1077
+ """
1078
+
1079
+ __tablename__ = "auth_verification_tokens"
1080
+
1081
+ identifier: Mapped[text] = mapped_column(VARCHAR, primary_key=True)
1082
+ token: Mapped[text] = mapped_column(VARCHAR, primary_key=True)
1083
+ expires: Mapped[date]
1084
+ created: Mapped[dt_create]
1085
+ updated: Mapped[dt_update]
1086
+
1087
+
1088
+ class UpdateRequest(Base):
1089
+ """
1090
+ Model representing an update request.
1091
+
1092
+ Attributes:
1093
+ id (UUID): The ID of the update request.
1094
+ token (UUID): The token of the update request.
1095
+ region_id (int): The ID of the associated region.
1096
+ event_id (Optional[int]): The ID of the associated event.
1097
+ event_type_ids (Optional[List[int]]): The associated event type IDs.
1098
+ event_tag (Optional[str]): The associated event tag.
1099
+ event_series_id (Optional[int]): The ID of the associated event series.
1100
+ event_is_series (Optional[bool]): Whether the event is a series.
1101
+ event_is_active (Optional[bool]): Whether the event is active.
1102
+ event_highlight (Optional[bool]): Whether the event is highlighted.
1103
+ event_start_date (Optional[date]): The start date of the event.
1104
+ event_end_date (Optional[date]): The end date of the event.
1105
+ event_start_time (Optional[time_notz]): The start time of the event.
1106
+ event_end_time (Optional[time_notz]): The end time of the event.
1107
+ event_day_of_week (Optional[Day_Of_Week]): The day of the week of the event.
1108
+ event_name (str): The name of the event.
1109
+ event_description (Optional[text]): A description of the event.
1110
+ event_recurrence_pattern (Optional[str]): The recurrence pattern of the event.
1111
+ event_recurrence_interval (Optional[int]): The recurrence interval of the event.
1112
+ event_index_within_interval (Optional[int]): The index within the recurrence interval.
1113
+ event_meta (Optional[Dict[str, Any]]): Additional metadata for the event.
1114
+ event_contact_email (Optional[str]): The contact email of the event.
1115
+ location_name (Optional[text]): The name of the location.
1116
+ location_description (Optional[text]): A description of the location.
1117
+ location_address (Optional[text]): The address of the location.
1118
+ location_address2 (Optional[text]): The second address line of the location.
1119
+ location_city (Optional[text]): The city of the location.
1120
+ location_state (Optional[str]): The state of the location.
1121
+ location_zip (Optional[str]): The ZIP code of the location.
1122
+ location_country (Optional[str]): The country of the location.
1123
+ location_lat (Optional[float]): The latitude of the location.
1124
+ location_lng (Optional[float]): The longitude of the location.
1125
+ location_id (Optional[int]): The ID of the location.
1126
+ location_contact_email (Optional[str]): The contact email of the location.
1127
+ ao_logo (Optional[text]): The URL of the AO logo.
1128
+ submitted_by (str): The user who submitted the request.
1129
+ submitter_validated (Optional[bool]): Whether the submitter has validated the request. Default is False.
1130
+ reviewed_by (Optional[str]): The user who reviewed the request.
1131
+ reviewed_at (Optional[datetime]): The timestamp when the request was reviewed.
1132
+ status (Update_Request_Status): The status of the request. Default is 'pending'.
1133
+ meta (Optional[Dict[str, Any]]): Additional metadata for the request.
1134
+ created (datetime): The timestamp when the record was created.
1135
+ updated (datetime): The timestamp when the record was last updated.
1136
+ """
986
1137
 
987
- # __tablename__ = "slack_space_logs"
1138
+ __tablename__ = "update_requests"
1139
+
1140
+ id: Mapped[Uuid] = mapped_column(UUID(as_uuid=True), primary_key=True)
1141
+ token: Mapped[Uuid] = mapped_column(UUID(as_uuid=True), default=uuid.uuid4)
1142
+ region_id: Mapped[int] = mapped_column(ForeignKey("orgs.id"))
1143
+ event_id: Mapped[Optional[int]] = mapped_column(ForeignKey("events.id"))
1144
+ event_type_ids: Mapped[Optional[List[int]]] = mapped_column(ARRAY(Integer))
1145
+ event_tag: Mapped[Optional[str]]
1146
+ event_series_id: Mapped[Optional[int]]
1147
+ event_is_series: Mapped[Optional[bool]]
1148
+ event_is_active: Mapped[Optional[bool]]
1149
+ event_highlight: Mapped[Optional[bool]]
1150
+ event_start_date: Mapped[Optional[date]]
1151
+ event_end_date: Mapped[Optional[date]]
1152
+ event_start_time: Mapped[Optional[time_notz]]
1153
+ event_end_time: Mapped[Optional[time_notz]]
1154
+ event_day_of_week: Mapped[Optional[Day_Of_Week]]
1155
+ event_name: Mapped[str]
1156
+ event_description: Mapped[Optional[text]]
1157
+ event_recurrence_pattern: Mapped[Optional[str]] = mapped_column(VARCHAR(length=30))
1158
+ event_recurrence_interval: Mapped[Optional[int]]
1159
+ event_index_within_interval: Mapped[Optional[int]]
1160
+ event_meta: Mapped[Optional[Dict[str, Any]]]
1161
+ event_contact_email: Mapped[Optional[str]]
1162
+
1163
+ location_name: Mapped[Optional[text]]
1164
+ location_description: Mapped[Optional[text]]
1165
+ location_address: Mapped[Optional[text]]
1166
+ location_address2: Mapped[Optional[text]]
1167
+ location_city: Mapped[Optional[text]]
1168
+ location_state: Mapped[Optional[str]]
1169
+ location_zip: Mapped[Optional[str]]
1170
+ location_country: Mapped[Optional[str]]
1171
+ location_lat: Mapped[Optional[float]] = mapped_column(
1172
+ Float(precision=8, decimal_return_scale=5)
1173
+ )
1174
+ location_lng: Mapped[Optional[float]] = mapped_column(
1175
+ Float(precision=8, decimal_return_scale=5)
1176
+ )
1177
+ location_id: Mapped[Optional[int]] = mapped_column(ForeignKey("locations.id"))
1178
+ location_contact_email: Mapped[Optional[str]]
988
1179
 
989
- # id: Mapped[intpk]
990
- # slack_space_id: Mapped[int] = mapped_column(ForeignKey("slack_spaces.id"))
991
- # event: Mapped[str]
992
- # data: Mapped[Optional[Dict[str, Any]]]
993
- # created: Mapped[dt_create]
1180
+ ao_logo: Mapped[Optional[text]]
1181
+
1182
+ submitted_by: Mapped[text]
1183
+ submitter_validated: Mapped[Optional[bool]] = mapped_column(Boolean, default=False)
1184
+ reviewed_by: Mapped[Optional[text]]
1185
+ reviewed_at: Mapped[Optional[datetime]]
1186
+ status: Mapped[Update_Request_Status] = mapped_column(
1187
+ Enum(Update_Request_Status), default=Update_Request_Status.pending
1188
+ )
1189
+ meta: Mapped[Optional[Dict[str, Any]]]
1190
+
1191
+ created: Mapped[dt_create]
1192
+ updated: Mapped[dt_update]
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "f3-data-models"
3
- version = "0.2.5"
3
+ version = "0.3.1"
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"
@@ -24,6 +24,7 @@ sphinx-rtd-theme = "^3.0.2"
24
24
  sphinx-multiversion = "^0.2.4"
25
25
  psycopg2-binary = "^2.9.10"
26
26
  sqlmodel = "^0.0.22"
27
+ alembic-postgresql-enum = "^1.6.1"
27
28
 
28
29
 
29
30
  [build-system]