artemis-model 0.1.81__tar.gz → 0.1.87__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.
Files changed (23) hide show
  1. {artemis_model-0.1.81 → artemis_model-0.1.87}/PKG-INFO +1 -1
  2. {artemis_model-0.1.81 → artemis_model-0.1.87}/artemis_model/__init__.py +1 -0
  3. artemis_model-0.1.87/artemis_model/device.py +69 -0
  4. {artemis_model-0.1.81 → artemis_model-0.1.87}/artemis_model/playlist.py +0 -29
  5. {artemis_model-0.1.81 → artemis_model-0.1.87}/artemis_model/user.py +8 -0
  6. {artemis_model-0.1.81 → artemis_model-0.1.87}/pyproject.toml +1 -1
  7. {artemis_model-0.1.81 → artemis_model-0.1.87}/README.md +0 -0
  8. {artemis_model-0.1.81 → artemis_model-0.1.87}/artemis_model/album.py +0 -0
  9. {artemis_model-0.1.81 → artemis_model-0.1.87}/artemis_model/artist.py +0 -0
  10. {artemis_model-0.1.81 → artemis_model-0.1.87}/artemis_model/auth.py +0 -0
  11. {artemis_model-0.1.81 → artemis_model-0.1.87}/artemis_model/base.py +0 -0
  12. {artemis_model-0.1.81 → artemis_model-0.1.87}/artemis_model/category.py +0 -0
  13. {artemis_model-0.1.81 → artemis_model-0.1.87}/artemis_model/dj_set.py +0 -0
  14. {artemis_model-0.1.81 → artemis_model-0.1.87}/artemis_model/genre.py +0 -0
  15. {artemis_model-0.1.81 → artemis_model-0.1.87}/artemis_model/location.py +0 -0
  16. {artemis_model-0.1.81 → artemis_model-0.1.87}/artemis_model/message.py +0 -0
  17. {artemis_model-0.1.81 → artemis_model-0.1.87}/artemis_model/organization.py +0 -0
  18. {artemis_model-0.1.81 → artemis_model-0.1.87}/artemis_model/otp.py +0 -0
  19. {artemis_model-0.1.81 → artemis_model-0.1.87}/artemis_model/permission.py +0 -0
  20. {artemis_model-0.1.81 → artemis_model-0.1.87}/artemis_model/schedule.py +0 -0
  21. {artemis_model-0.1.81 → artemis_model-0.1.87}/artemis_model/setting.py +0 -0
  22. {artemis_model-0.1.81 → artemis_model-0.1.87}/artemis_model/track.py +0 -0
  23. {artemis_model-0.1.81 → artemis_model-0.1.87}/artemis_model/zone.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: artemis-model
3
- Version: 0.1.81
3
+ Version: 0.1.87
4
4
  Summary:
5
5
  Author: Jukeboxy
6
6
  Requires-Python: >=3.10.6,<4.0.0
@@ -14,3 +14,4 @@ from artemis_model.track import * # noqa
14
14
  from artemis_model.user import * # noqa
15
15
  from artemis_model.zone import * # noqa
16
16
  from artemis_model.otp import * # noqa
17
+ from artemis_model.device import * # noqa
@@ -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 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
+ device_id: Mapped[str] = mapped_column(nullable=False, unique=True, index=True)
19
+ name: Mapped[str] = mapped_column(nullable=False) # e.g., "Living Room Jukebox"
20
+ fcm_token: Mapped[str | None] = mapped_column(nullable=True)
21
+ device_specs: Mapped[dict] = mapped_column(JSON, nullable=True) # control_mode can be stored here
22
+
23
+ @declared_attr
24
+ def device_user_assoc(cls) -> Mapped[list["DeviceUserAssoc"]]:
25
+ return relationship(cascade="all, delete-orphan")
26
+
27
+ @declared_attr
28
+ def user_ids(cls) -> Mapped[list["UserAccount"] | None]:
29
+ return association_proxy(
30
+ "device_user_assoc",
31
+ "user",
32
+ creator=lambda u: DeviceUserAssoc(user_id=u),
33
+ )
34
+
35
+ @declared_attr
36
+ def users(cls) -> Mapped[list["User"]]:
37
+ return relationship(
38
+ secondary="device_user_assoc",
39
+ viewonly=True
40
+ )
41
+
42
+
43
+ class DeviceSync(CustomSyncBase, DeviceMixin):
44
+ pass
45
+
46
+
47
+ class Device(CustomBase, DeviceMixin):
48
+ pass
49
+
50
+
51
+ class DeviceUserAssocMixin(TimeStampMixin):
52
+ """
53
+ Association table for many-to-many relationship between UserAccount and Device.
54
+ """
55
+
56
+ device_id: Mapped[uuid.UUID] = mapped_column(
57
+ ForeignKey("device.id"), primary_key=True, nullable=False
58
+ )
59
+ user_id: Mapped[uuid.UUID] = mapped_column(
60
+ ForeignKey("user.id"), primary_key=True, nullable=False
61
+ )
62
+
63
+
64
+ class DeviceUserAssocSync(CustomSyncBase, DeviceUserAssocMixin):
65
+ pass
66
+
67
+
68
+ class DeviceUserAssoc(CustomBase, DeviceUserAssocMixin):
69
+ pass
@@ -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"]
@@ -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(
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "artemis-model"
3
- version = "0.1.81"
3
+ version = "0.1.87"
4
4
  description = ""
5
5
  authors = ["Jukeboxy"]
6
6
  readme = "README.md"
File without changes