rename trending apis
This commit is contained in:
parent
281d1f8bf2
commit
1a97e5b7ef
3 changed files with 47 additions and 17 deletions
|
@ -141,7 +141,7 @@ def fetch_item(request, url: str):
|
||||||
response={200: list[Gallery]},
|
response={200: list[Gallery]},
|
||||||
summary="Trending items in catalog",
|
summary="Trending items in catalog",
|
||||||
auth=None,
|
auth=None,
|
||||||
tags=["catalog"],
|
tags=["trending"],
|
||||||
deprecated=True,
|
deprecated=True,
|
||||||
)
|
)
|
||||||
def trending_items(request):
|
def trending_items(request):
|
||||||
|
@ -167,66 +167,66 @@ def _get_trending(name):
|
||||||
|
|
||||||
|
|
||||||
@api.get(
|
@api.get(
|
||||||
"/catalog/trending/book/",
|
"/trending/book/",
|
||||||
response={200: list[ItemSchema]},
|
response={200: list[ItemSchema]},
|
||||||
summary="Trending books in catalog",
|
summary="Trending books in catalog",
|
||||||
auth=None,
|
auth=None,
|
||||||
tags=["catalog"],
|
tags=["trending"],
|
||||||
)
|
)
|
||||||
def trending_book(request):
|
def trending_book(request):
|
||||||
return _get_trending("trending_book")
|
return _get_trending("trending_book")
|
||||||
|
|
||||||
|
|
||||||
@api.get(
|
@api.get(
|
||||||
"/catalog/trending/movie/",
|
"/trending/movie/",
|
||||||
response={200: list[ItemSchema]},
|
response={200: list[ItemSchema]},
|
||||||
summary="Trending movies in catalog",
|
summary="Trending movies in catalog",
|
||||||
auth=None,
|
auth=None,
|
||||||
tags=["catalog"],
|
tags=["trending"],
|
||||||
)
|
)
|
||||||
def trending_movie(request):
|
def trending_movie(request):
|
||||||
return _get_trending("trending_movie")
|
return _get_trending("trending_movie")
|
||||||
|
|
||||||
|
|
||||||
@api.get(
|
@api.get(
|
||||||
"/catalog/trending/tv/",
|
"/trending/tv/",
|
||||||
response={200: list[ItemSchema]},
|
response={200: list[ItemSchema]},
|
||||||
summary="Trending tv in catalog",
|
summary="Trending tv in catalog",
|
||||||
auth=None,
|
auth=None,
|
||||||
tags=["catalog"],
|
tags=["trending"],
|
||||||
)
|
)
|
||||||
def trending_tv(request):
|
def trending_tv(request):
|
||||||
return _get_trending("trending_tv")
|
return _get_trending("trending_tv")
|
||||||
|
|
||||||
|
|
||||||
@api.get(
|
@api.get(
|
||||||
"/catalog/trending/music/",
|
"/trending/music/",
|
||||||
response={200: list[ItemSchema]},
|
response={200: list[ItemSchema]},
|
||||||
summary="Trending music in catalog",
|
summary="Trending music in catalog",
|
||||||
auth=None,
|
auth=None,
|
||||||
tags=["catalog"],
|
tags=["trending"],
|
||||||
)
|
)
|
||||||
def trending_music(request):
|
def trending_music(request):
|
||||||
return _get_trending("trending_music")
|
return _get_trending("trending_music")
|
||||||
|
|
||||||
|
|
||||||
@api.get(
|
@api.get(
|
||||||
"/catalog/trending/game/",
|
"/trending/game/",
|
||||||
response={200: list[ItemSchema]},
|
response={200: list[ItemSchema]},
|
||||||
summary="Trending games in catalog",
|
summary="Trending games in catalog",
|
||||||
auth=None,
|
auth=None,
|
||||||
tags=["catalog"],
|
tags=["trending"],
|
||||||
)
|
)
|
||||||
def trending_game(request):
|
def trending_game(request):
|
||||||
return _get_trending("trending_game")
|
return _get_trending("trending_game")
|
||||||
|
|
||||||
|
|
||||||
@api.get(
|
@api.get(
|
||||||
"/catalog/trending/podcast/",
|
"/trending/podcast/",
|
||||||
response={200: list[ItemSchema]},
|
response={200: list[ItemSchema]},
|
||||||
summary="Trending podcasts in catalog",
|
summary="Trending podcasts in catalog",
|
||||||
auth=None,
|
auth=None,
|
||||||
tags=["catalog"],
|
tags=["trending"],
|
||||||
)
|
)
|
||||||
def trending_podcast(request):
|
def trending_podcast(request):
|
||||||
return _get_trending("trending_podcast")
|
return _get_trending("trending_podcast")
|
||||||
|
|
|
@ -197,11 +197,11 @@ def collection_delete_item(request, collection_uuid: str, item_uuid: str):
|
||||||
|
|
||||||
|
|
||||||
@api.get(
|
@api.get(
|
||||||
"/catalog/trending/collection/",
|
"/trending/collection/",
|
||||||
response={200: list[CollectionSchema]},
|
response={200: list[CollectionSchema]},
|
||||||
summary="Trending collection in catalog",
|
summary="Trending collections",
|
||||||
auth=None,
|
auth=None,
|
||||||
tags=["catalog"],
|
tags=["trending"],
|
||||||
)
|
)
|
||||||
@decorate_view(cache_page(600))
|
@decorate_view(cache_page(600))
|
||||||
def trending_collection(request):
|
def trending_collection(request):
|
||||||
|
|
|
@ -1432,7 +1432,7 @@ class Post(models.Model):
|
||||||
"sensitive": self.sensitive,
|
"sensitive": self.sensitive,
|
||||||
"spoiler_text": self.summary or "",
|
"spoiler_text": self.summary or "",
|
||||||
"media_attachments": [
|
"media_attachments": [
|
||||||
# attachment.to_mastodon_json() for attachment in self.attachments.all()
|
attachment.to_mastodon_json() for attachment in self.attachments.all()
|
||||||
],
|
],
|
||||||
"mentions": [
|
"mentions": [
|
||||||
mention.to_mastodon_mention_json() for mention in self.mentions.all()
|
mention.to_mastodon_mention_json() for mention in self.mentions.all()
|
||||||
|
@ -1647,6 +1647,36 @@ class PostAttachment(models.Model):
|
||||||
return self.file.name.rsplit("/", 1)[-1]
|
return self.file.name.rsplit("/", 1)[-1]
|
||||||
return f"attachment ({self.mimetype})"
|
return f"attachment ({self.mimetype})"
|
||||||
|
|
||||||
|
def to_mastodon_json(self):
|
||||||
|
type_ = "unknown"
|
||||||
|
if self.is_image():
|
||||||
|
type_ = "image"
|
||||||
|
elif self.is_video():
|
||||||
|
type_ = "video"
|
||||||
|
value = {
|
||||||
|
"id": str(self.pk),
|
||||||
|
"type": type_,
|
||||||
|
"url": self.full_url().absolute,
|
||||||
|
"preview_url": self.thumbnail_url().absolute,
|
||||||
|
"remote_url": None,
|
||||||
|
"meta": {
|
||||||
|
"focus": {
|
||||||
|
"x": self.focal_x or 0,
|
||||||
|
"y": self.focal_y or 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"description": self.name,
|
||||||
|
"blurhash": self.blurhash,
|
||||||
|
}
|
||||||
|
if self.width and self.height:
|
||||||
|
value["meta"]["original"] = {
|
||||||
|
"width": self.width,
|
||||||
|
"height": self.height,
|
||||||
|
"size": f"{self.width}x{self.height}",
|
||||||
|
"aspect": self.width / self.height,
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
class EmojiQuerySet(models.QuerySet):
|
class EmojiQuerySet(models.QuerySet):
|
||||||
def usable(self, domain: Domain | None = None):
|
def usable(self, domain: Domain | None = None):
|
||||||
|
|
Loading…
Add table
Reference in a new issue