f3-data-models 0.1.0__py3-none-any.whl → 0.1.2__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 +4 -4
- f3_data_models/utils.py +28 -9
- {f3_data_models-0.1.0.dist-info → f3_data_models-0.1.2.dist-info}/METADATA +2 -1
- f3_data_models-0.1.2.dist-info/RECORD +6 -0
- {f3_data_models-0.1.0.dist-info → f3_data_models-0.1.2.dist-info}/WHEEL +1 -1
- f3_data_models-0.1.0.dist-info/RECORD +0 -6
f3_data_models/models.py
CHANGED
@@ -798,16 +798,16 @@ class Position(Base):
|
|
798
798
|
Attributes:
|
799
799
|
name (str): The name of the position.
|
800
800
|
description (Optional[str]): A description of the position.
|
801
|
-
org_type_id (int): The ID of the associated organization type.
|
802
|
-
org_id (int): The ID of the associated organization.
|
801
|
+
org_type_id (Optional[int]): The ID of the associated organization type. This is used to limit the positions available to certain types of organizations. If null, the position is available to all organization types.
|
802
|
+
org_id (Optional[int]): The ID of the associated organization. This is used to limit the positions available to certain organizations. If null, the position is available to all organizations.
|
803
803
|
"""
|
804
804
|
|
805
805
|
__tablename__ = "positions"
|
806
806
|
|
807
807
|
name: Mapped[str]
|
808
808
|
description: Mapped[Optional[str]]
|
809
|
-
org_type_id: Mapped[int] = mapped_column(ForeignKey("org_types.id"))
|
810
|
-
org_id: Mapped[int] = mapped_column(ForeignKey("orgs.id"))
|
809
|
+
org_type_id: Mapped[Optional[int]] = mapped_column(ForeignKey("org_types.id"))
|
810
|
+
org_id: Mapped[Optional[int]] = mapped_column(ForeignKey("orgs.id"))
|
811
811
|
|
812
812
|
|
813
813
|
class Position_x_Org_x_User(Base):
|
f3_data_models/utils.py
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
import os
|
2
2
|
from dataclasses import dataclass
|
3
|
-
from typing import List, Tuple, TypeVar
|
3
|
+
from typing import List, Optional, Tuple, TypeVar
|
4
4
|
|
5
5
|
import sqlalchemy
|
6
|
-
from sqlalchemy import and_
|
6
|
+
from sqlalchemy import and_, select
|
7
7
|
|
8
8
|
from sqlalchemy.dialects.postgresql import insert
|
9
9
|
from sqlalchemy.engine import Engine
|
10
10
|
from sqlalchemy.orm import sessionmaker
|
11
11
|
|
12
|
-
from .models import Base
|
12
|
+
from f3_data_models.models import Base
|
13
13
|
|
14
14
|
from pydot import Dot
|
15
15
|
from sqlalchemy_schemadisplay import create_schema_graph
|
@@ -88,10 +88,18 @@ class DbManager:
|
|
88
88
|
session.rollback()
|
89
89
|
close_session(session)
|
90
90
|
|
91
|
-
def
|
91
|
+
def get(cls: T, id: int) -> T:
|
92
92
|
session = get_session()
|
93
93
|
try:
|
94
|
-
|
94
|
+
return session.scalars(select(cls).filter(cls.id == id)).one()
|
95
|
+
finally:
|
96
|
+
session.rollback()
|
97
|
+
close_session(session)
|
98
|
+
|
99
|
+
def find_records(cls: T, filters: Optional[List]) -> List[T]:
|
100
|
+
session = get_session()
|
101
|
+
try:
|
102
|
+
records = session.scalars(select(cls).filter(*filters)).all()
|
95
103
|
for r in records:
|
96
104
|
session.expunge(r)
|
97
105
|
return records
|
@@ -99,6 +107,17 @@ class DbManager:
|
|
99
107
|
session.rollback()
|
100
108
|
close_session(session)
|
101
109
|
|
110
|
+
def find_first_record(cls: T, filters: Optional[List]) -> T:
|
111
|
+
session = get_session()
|
112
|
+
try:
|
113
|
+
record = session.scalars(select(cls).filter(*filters)).first()
|
114
|
+
if record:
|
115
|
+
session.expunge(record)
|
116
|
+
return record
|
117
|
+
finally:
|
118
|
+
session.rollback()
|
119
|
+
close_session(session)
|
120
|
+
|
102
121
|
def find_join_records2(left_cls: T, right_cls: T, filters) -> List[Tuple[T]]:
|
103
122
|
session = get_session()
|
104
123
|
try:
|
@@ -247,12 +266,12 @@ def create_diagram():
|
|
247
266
|
graph: Dot = create_schema_graph(
|
248
267
|
engine=get_engine(),
|
249
268
|
metadata=Base.metadata,
|
250
|
-
show_datatypes=
|
251
|
-
show_indexes=
|
269
|
+
show_datatypes=True,
|
270
|
+
show_indexes=True,
|
252
271
|
rankdir="LR",
|
253
|
-
|
272
|
+
show_column_keys=True,
|
254
273
|
)
|
255
|
-
graph.write_png("schema_diagram.png")
|
274
|
+
graph.write_png("docs/_static/schema_diagram.png")
|
256
275
|
|
257
276
|
|
258
277
|
if __name__ == "__main__":
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: f3-data-models
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.2
|
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
|
@@ -10,6 +10,7 @@ Requires-Python: >=3.12,<4.0
|
|
10
10
|
Classifier: License :: OSI Approved :: MIT License
|
11
11
|
Classifier: Programming Language :: Python :: 3
|
12
12
|
Classifier: Programming Language :: Python :: 3.12
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
13
14
|
Requires-Dist: alembic (>=1.14.0,<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)
|
@@ -0,0 +1,6 @@
|
|
1
|
+
f3_data_models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
+
f3_data_models/models.py,sha256=3NDD05kmj06Z-qEXXDB1exQon8xZbydqMbZsLfvdh7A,34327
|
3
|
+
f3_data_models/utils.py,sha256=oCxwNORr0-5l0ZugxMYLmKIbmcec-4HEdTSC1pRMoew,8002
|
4
|
+
f3_data_models-0.1.2.dist-info/METADATA,sha256=mpfJ0xDJjix1qfarr2QKEsvU8HoXqU7SOhNTYSsuv8U,2318
|
5
|
+
f3_data_models-0.1.2.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
6
|
+
f3_data_models-0.1.2.dist-info/RECORD,,
|
@@ -1,6 +0,0 @@
|
|
1
|
-
f3_data_models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
f3_data_models/models.py,sha256=TwNym-sXPrbq_2js-liom6Sof60oeJlqa4n09qqoC-E,34015
|
3
|
-
f3_data_models/utils.py,sha256=9XcjAzt21l3IBoeC5E57QglXHxkIAAFbmgh1VJdQFY8,7338
|
4
|
-
f3_data_models-0.1.0.dist-info/METADATA,sha256=51ozDOUHlGtubysMbMqOEuW7YkpGz9ibF8iZSvj5Zyg,2267
|
5
|
-
f3_data_models-0.1.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
6
|
-
f3_data_models-0.1.0.dist-info/RECORD,,
|