artemis-model 0.1.75__tar.gz → 0.1.79__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 (22) hide show
  1. {artemis_model-0.1.75 → artemis_model-0.1.79}/PKG-INFO +1 -1
  2. {artemis_model-0.1.75 → artemis_model-0.1.79}/artemis_model/playlist.py +30 -4
  3. {artemis_model-0.1.75 → artemis_model-0.1.79}/pyproject.toml +1 -1
  4. {artemis_model-0.1.75 → artemis_model-0.1.79}/README.md +0 -0
  5. {artemis_model-0.1.75 → artemis_model-0.1.79}/artemis_model/__init__.py +0 -0
  6. {artemis_model-0.1.75 → artemis_model-0.1.79}/artemis_model/album.py +0 -0
  7. {artemis_model-0.1.75 → artemis_model-0.1.79}/artemis_model/artist.py +0 -0
  8. {artemis_model-0.1.75 → artemis_model-0.1.79}/artemis_model/auth.py +0 -0
  9. {artemis_model-0.1.75 → artemis_model-0.1.79}/artemis_model/base.py +0 -0
  10. {artemis_model-0.1.75 → artemis_model-0.1.79}/artemis_model/category.py +0 -0
  11. {artemis_model-0.1.75 → artemis_model-0.1.79}/artemis_model/dj_set.py +0 -0
  12. {artemis_model-0.1.75 → artemis_model-0.1.79}/artemis_model/genre.py +0 -0
  13. {artemis_model-0.1.75 → artemis_model-0.1.79}/artemis_model/location.py +0 -0
  14. {artemis_model-0.1.75 → artemis_model-0.1.79}/artemis_model/message.py +0 -0
  15. {artemis_model-0.1.75 → artemis_model-0.1.79}/artemis_model/organization.py +0 -0
  16. {artemis_model-0.1.75 → artemis_model-0.1.79}/artemis_model/otp.py +0 -0
  17. {artemis_model-0.1.75 → artemis_model-0.1.79}/artemis_model/permission.py +0 -0
  18. {artemis_model-0.1.75 → artemis_model-0.1.79}/artemis_model/schedule.py +0 -0
  19. {artemis_model-0.1.75 → artemis_model-0.1.79}/artemis_model/setting.py +0 -0
  20. {artemis_model-0.1.75 → artemis_model-0.1.79}/artemis_model/track.py +0 -0
  21. {artemis_model-0.1.75 → artemis_model-0.1.79}/artemis_model/user.py +0 -0
  22. {artemis_model-0.1.75 → artemis_model-0.1.79}/artemis_model/zone.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: artemis-model
3
- Version: 0.1.75
3
+ Version: 0.1.79
4
4
  Summary:
5
5
  Author: Jukeboxy
6
6
  Requires-Python: >=3.10.6,<4.0.0
@@ -2,11 +2,11 @@ import uuid
2
2
  from datetime import date, datetime
3
3
 
4
4
  from sqlalchemy import Computed, ForeignKey, func, literal, text
5
+ from sqlalchemy.ext.hybrid import hybrid_property
5
6
  from sqlalchemy.ext.associationproxy import AssociationProxy, association_proxy
6
7
  from sqlalchemy.orm import Mapped, mapped_column, relationship
7
8
 
8
9
  from artemis_model.base import CustomBase, CustomSyncBase, TSVector, TimeStampMixin
9
-
10
10
  from sqlalchemy.ext.declarative import declared_attr
11
11
 
12
12
 
@@ -15,6 +15,21 @@ def to_tsvector_ix(*columns):
15
15
  return func.to_tsvector(literal("english"), text(s))
16
16
 
17
17
 
18
+ class FavoritePlaylistMixin:
19
+ playlist_id: Mapped[int] = mapped_column(
20
+ ForeignKey("playlist.id"), primary_key=True
21
+ )
22
+ user_id: Mapped[uuid.UUID] = mapped_column(ForeignKey("user.id"), primary_key=True)
23
+
24
+
25
+ class FavoritePlaylistSync(CustomSyncBase, FavoritePlaylistMixin):
26
+ pass
27
+
28
+
29
+ class FavoritePlaylist(CustomBase, FavoritePlaylistMixin):
30
+ pass
31
+
32
+
18
33
  class PlaylistMixin(TimeStampMixin):
19
34
  id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
20
35
  name: Mapped[str] = mapped_column(nullable=False, unique=True)
@@ -26,9 +41,7 @@ class PlaylistMixin(TimeStampMixin):
26
41
  is_published: Mapped[bool] = mapped_column(default=False) # legacy isTest
27
42
  description: Mapped[str | None] = mapped_column(nullable=True)
28
43
  cover_image: Mapped[str | None] = mapped_column(nullable=True)
29
- is_ordered: Mapped[bool] = mapped_column(
30
- default=False
31
- ) # CanBeShuffled - Migration'da tersini al
44
+ is_ordered: Mapped[bool] = mapped_column(default=False)
32
45
  legacy_prepared_by: Mapped[str | None] = mapped_column(nullable=True)
33
46
  notes: Mapped[str | None] = mapped_column(nullable=True)
34
47
  published_at: Mapped[date | None] = mapped_column(nullable=True)
@@ -40,6 +53,19 @@ class PlaylistMixin(TimeStampMixin):
40
53
  Computed("to_tsvector('english', name)", persisted=True),
41
54
  )
42
55
 
56
+ @declared_attr
57
+ def favorite_playlist_associations(cls):
58
+ return relationship(
59
+ "FavoritePlaylist",
60
+ primaryjoin="and_(FavoritePlaylist.playlist_id == Playlist.id)",
61
+ viewonly=True,
62
+ lazy="select"
63
+ )
64
+
65
+ @hybrid_property
66
+ def is_favorite(self):
67
+ return bool(self.favorite_playlist_associations)
68
+
43
69
  @declared_attr
44
70
  def category_playlist_associations(cls) -> Mapped[
45
71
  list["PlaylistCategoryAssoc"]
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "artemis-model"
3
- version = "0.1.75"
3
+ version = "0.1.79"
4
4
  description = ""
5
5
  authors = ["Jukeboxy"]
6
6
  readme = "README.md"
File without changes