artemis-model 0.1.81__py3-none-any.whl → 0.1.83__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.
- artemis_model/__init__.py +1 -0
- artemis_model/device.py +69 -0
- artemis_model/playlist.py +0 -29
- artemis_model/user.py +8 -0
- artemis_model/zone.py +4 -0
- {artemis_model-0.1.81.dist-info → artemis_model-0.1.83.dist-info}/METADATA +1 -1
- {artemis_model-0.1.81.dist-info → artemis_model-0.1.83.dist-info}/RECORD +8 -7
- {artemis_model-0.1.81.dist-info → artemis_model-0.1.83.dist-info}/WHEEL +1 -1
artemis_model/__init__.py
CHANGED
artemis_model/device.py
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
import enum
|
2
|
+
import uuid
|
3
|
+
from datetime import datetime
|
4
|
+
|
5
|
+
from sqlalchemy import JSON, UUID, ForeignKey
|
6
|
+
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
7
|
+
from sqlalchemy.ext.declarative import declared_attr
|
8
|
+
from sqlalchemy.ext.associationproxy import association_proxy
|
9
|
+
|
10
|
+
from artemis_model.base import CustomSyncBase, CustomBase, TimeStampMixin
|
11
|
+
|
12
|
+
|
13
|
+
class DeviceMixin(TimeStampMixin):
|
14
|
+
"""
|
15
|
+
Represents a Jukebox device associated with zone that can be controlled by multiple users.
|
16
|
+
"""
|
17
|
+
id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
18
|
+
zone_id: Mapped[int] = mapped_column(ForeignKey("zone.id"), nullable=False, index=True)
|
19
|
+
|
20
|
+
device_id: Mapped[str] = mapped_column(nullable=False, unique=True, index=True)
|
21
|
+
name: Mapped[str] = mapped_column(nullable=False) # e.g., "Living Room Jukebox"
|
22
|
+
fcm_token: Mapped[str | None] = mapped_column(nullable=True)
|
23
|
+
device_specs: Mapped[dict] = mapped_column(JSON, nullable=True) # control_mode can be stored here
|
24
|
+
|
25
|
+
@declared_attr
|
26
|
+
def zone(cls) -> Mapped["Zone"]:
|
27
|
+
return relationship(back_populates="devices")
|
28
|
+
|
29
|
+
@declared_attr
|
30
|
+
def device_user_assoc(cls) -> Mapped[list["DeviceUserAssoc"]]:
|
31
|
+
return relationship(cascade="all, delete-orphan")
|
32
|
+
|
33
|
+
@declared_attr
|
34
|
+
def users(cls) -> Mapped[list["User"]]:
|
35
|
+
return relationship(
|
36
|
+
secondary="device_user_assoc",
|
37
|
+
viewonly=True
|
38
|
+
)
|
39
|
+
|
40
|
+
|
41
|
+
class DeviceSync(CustomSyncBase, DeviceMixin):
|
42
|
+
pass
|
43
|
+
|
44
|
+
|
45
|
+
class Device(CustomBase, DeviceMixin):
|
46
|
+
pass
|
47
|
+
|
48
|
+
|
49
|
+
class DeviceUserAssocMixin(TimeStampMixin):
|
50
|
+
"""
|
51
|
+
Association table for many-to-many relationship between UserAccount and Device.
|
52
|
+
"""
|
53
|
+
|
54
|
+
device_id: Mapped[uuid.UUID] = mapped_column(
|
55
|
+
ForeignKey("device.id"), primary_key=True, nullable=False
|
56
|
+
)
|
57
|
+
user_id: Mapped[uuid.UUID] = mapped_column(
|
58
|
+
ForeignKey("user.id"), primary_key=True, nullable=False
|
59
|
+
)
|
60
|
+
|
61
|
+
last_seen: Mapped[datetime] = mapped_column(nullable=False, default=datetime.now)
|
62
|
+
|
63
|
+
|
64
|
+
class DeviceUserAssocSync(CustomSyncBase, DeviceUserAssocMixin):
|
65
|
+
pass
|
66
|
+
|
67
|
+
|
68
|
+
class DeviceUserAssoc(CustomBase, DeviceUserAssocMixin):
|
69
|
+
pass
|
artemis_model/playlist.py
CHANGED
@@ -30,21 +30,6 @@ class FavoritePlaylist(CustomBase, FavoritePlaylistMixin):
|
|
30
30
|
pass
|
31
31
|
|
32
32
|
|
33
|
-
class OrganizationApprovedPlaylistMixin(TimeStampMixin):
|
34
|
-
playlist_id: Mapped[int] = mapped_column(
|
35
|
-
ForeignKey("playlist.id"), primary_key=True
|
36
|
-
)
|
37
|
-
organization_id: Mapped[uuid.UUID] = mapped_column(ForeignKey("organization.id"), primary_key=True)
|
38
|
-
|
39
|
-
|
40
|
-
class OrganizationApprovedPlaylistSync(CustomSyncBase, OrganizationApprovedPlaylistMixin):
|
41
|
-
pass
|
42
|
-
|
43
|
-
|
44
|
-
class OrganizationApprovedPlaylist(CustomBase, OrganizationApprovedPlaylistMixin):
|
45
|
-
pass
|
46
|
-
|
47
|
-
|
48
33
|
class PlaylistMixin(TimeStampMixin):
|
49
34
|
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
50
35
|
name: Mapped[str] = mapped_column(nullable=False, unique=True)
|
@@ -77,24 +62,10 @@ class PlaylistMixin(TimeStampMixin):
|
|
77
62
|
lazy="select"
|
78
63
|
)
|
79
64
|
|
80
|
-
@declared_attr
|
81
|
-
def org_approved_playlist_associations(cls):
|
82
|
-
return relationship(
|
83
|
-
"OrganizationApprovedPlaylist",
|
84
|
-
primaryjoin="and_(OrganizationApprovedPlaylist.playlist_id == Playlist.id)",
|
85
|
-
viewonly=True,
|
86
|
-
lazy="select"
|
87
|
-
)
|
88
|
-
|
89
65
|
@hybrid_property
|
90
66
|
def is_favorite(self):
|
91
67
|
return bool(self.favorite_playlist_associations)
|
92
68
|
|
93
|
-
@hybrid_property
|
94
|
-
def is_org_approved(self):
|
95
|
-
return bool(self.org_approved_playlist_associations)
|
96
|
-
|
97
|
-
|
98
69
|
@declared_attr
|
99
70
|
def category_playlist_associations(cls) -> Mapped[
|
100
71
|
list["PlaylistCategoryAssoc"]
|
artemis_model/user.py
CHANGED
@@ -28,6 +28,14 @@ class UserMixin(TimeStampMixin):
|
|
28
28
|
cascade="all, delete-orphan",
|
29
29
|
)
|
30
30
|
|
31
|
+
@declared_attr
|
32
|
+
def devices(cls) -> Mapped[list["Device"]]:
|
33
|
+
return relationship(
|
34
|
+
"Device",
|
35
|
+
secondary="device_user_assoc", # Directly reference the association table
|
36
|
+
back_populates="users",
|
37
|
+
)
|
38
|
+
|
31
39
|
@declared_attr
|
32
40
|
def user_permission_associations(cls) -> Mapped[List["UserPermissionAssoc"]]:
|
33
41
|
return relationship(
|
artemis_model/zone.py
CHANGED
@@ -39,6 +39,10 @@ class ZoneMixin(TimeStampMixin):
|
|
39
39
|
@declared_attr
|
40
40
|
def setting(cls) -> Mapped["Setting"]:
|
41
41
|
return relationship(back_populates="zone", uselist=False)
|
42
|
+
|
43
|
+
@declared_attr
|
44
|
+
def devices(cls) -> Mapped[list["Device"]]:
|
45
|
+
return relationship(back_populates="zone")
|
42
46
|
|
43
47
|
|
44
48
|
class ZoneSync(CustomSyncBase, ZoneMixin):
|
@@ -1,9 +1,10 @@
|
|
1
|
-
artemis_model/__init__.py,sha256=
|
1
|
+
artemis_model/__init__.py,sha256=ppr3Y8tA0RIhszLWNEIL2eIXzj8ho833nbrejsXPuMk,735
|
2
2
|
artemis_model/album.py,sha256=cnjrE0catTK24uWTrAoRcZUQB3CPt5l8s9PeM2sxLrc,2103
|
3
3
|
artemis_model/artist.py,sha256=Mx2bnl7bxqm2ELjDIePGFfIkQU_DbnfOTc507dzh14g,1577
|
4
4
|
artemis_model/auth.py,sha256=WVonoYbCE0uvRuPR2Fz1hZJ-xmbyTuBVt6H51X6OfEs,4087
|
5
5
|
artemis_model/base.py,sha256=21Isonytb_iWfmde4u8LiU6a27h7mkgnwncTAKi9ezY,6768
|
6
6
|
artemis_model/category.py,sha256=jhCZrK-LxPmc0pXmVifAZWdCENssBTzdTmC3nqqZc6s,1761
|
7
|
+
artemis_model/device.py,sha256=VWIQ9kMBp2QiRlz6BOiP1je1bEalHsXy3ic70VsfN3w,2190
|
7
8
|
artemis_model/dj_set.py,sha256=-0rU2xOAJ4vecite8yKFmp9yFLPZurFrdFmYAjPHtso,3848
|
8
9
|
artemis_model/genre.py,sha256=oMs1ZZfr0SZWmWzW9PEPuaNcatfeIx53nk5M3DPodrQ,1615
|
9
10
|
artemis_model/location.py,sha256=T6TlUCXxGyicYtb39dw7XjbCSNECZnMPYahxtOtyEiE,4687
|
@@ -11,12 +12,12 @@ artemis_model/message.py,sha256=gua3X_1hS7akmS42wQGtL0I-FCJUHdTBM4n2DW4hTxQ,3280
|
|
11
12
|
artemis_model/organization.py,sha256=hu9jKB2qu57BwN0sUUK13p3tC-Hqw9EghFMqjFP9Pr4,2387
|
12
13
|
artemis_model/otp.py,sha256=TjZ_EHeIedjsLIqyZTtzd0s6Uc-1dleMEV8DhzsW44o,1046
|
13
14
|
artemis_model/permission.py,sha256=sEBRN-bQJl2TNtRJ5LRuySoEbW1lY4DCoyRk0nOM-kY,1503
|
14
|
-
artemis_model/playlist.py,sha256=
|
15
|
+
artemis_model/playlist.py,sha256=1mR1FbjeG5ZKzILLd7Mo_fuMplEwN3gPCO-jHvkE1WM,6550
|
15
16
|
artemis_model/schedule.py,sha256=pnoKDMlUh28o61I7kZddNYn6z-uqOt_ml1nbWxKVeRM,1722
|
16
17
|
artemis_model/setting.py,sha256=McWbeDZP45km3VSSwP1BgAmmjO4qCL0pTnOmJVAz0WI,1265
|
17
18
|
artemis_model/track.py,sha256=x8BHKDZl9uQmQH6DWpzH-SEsfecLghOBdBT7qXgN3d0,3865
|
18
|
-
artemis_model/user.py,sha256=
|
19
|
-
artemis_model/zone.py,sha256=
|
20
|
-
artemis_model-0.1.
|
21
|
-
artemis_model-0.1.
|
22
|
-
artemis_model-0.1.
|
19
|
+
artemis_model/user.py,sha256=jGG3FpO6ddehXVl9XWqv4poQH6QQZut48saob3Cy8vU,2467
|
20
|
+
artemis_model/zone.py,sha256=p0fWoWbTTX4-Qrjs6QWIpUMktpx3toQPLnKKcz53aYw,2405
|
21
|
+
artemis_model-0.1.83.dist-info/METADATA,sha256=XxOFn6yW6HwGM-aTVnpmlmmzXXgGan0dwBJ17E2Nb6I,3402
|
22
|
+
artemis_model-0.1.83.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
|
23
|
+
artemis_model-0.1.83.dist-info/RECORD,,
|