chore(api): move podcasts in dedicated app (#1899)
This commit is contained in:
parent
4004981429
commit
b9895d19e2
15 changed files with 37 additions and 21 deletions
0
api/libretime_api/podcasts/__init__.py
Normal file
0
api/libretime_api/podcasts/__init__.py
Normal file
7
api/libretime_api/podcasts/apps.py
Normal file
7
api/libretime_api/podcasts/apps.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class PodcastsConfig(AppConfig):
|
||||
default_auto_field = "django.db.models.BigAutoField"
|
||||
name = "libretime_api.podcasts"
|
||||
verbose_name = "LibreTime Podcasts API"
|
1
api/libretime_api/podcasts/models/__init__.py
Normal file
1
api/libretime_api/podcasts/models/__init__.py
Normal file
|
@ -0,0 +1 @@
|
|||
from .podcast import ImportedPodcast, Podcast, PodcastEpisode, StationPodcast
|
83
api/libretime_api/podcasts/models/podcast.py
Normal file
83
api/libretime_api/podcasts/models/podcast.py
Normal file
|
@ -0,0 +1,83 @@
|
|||
from django.db import models
|
||||
|
||||
|
||||
class Podcast(models.Model):
|
||||
url = models.CharField(max_length=4096)
|
||||
title = models.CharField(max_length=4096)
|
||||
creator = models.CharField(max_length=4096, blank=True, null=True)
|
||||
description = models.CharField(max_length=4096, blank=True, null=True)
|
||||
language = models.CharField(max_length=4096, blank=True, null=True)
|
||||
copyright = models.CharField(max_length=4096, blank=True, null=True)
|
||||
link = models.CharField(max_length=4096, blank=True, null=True)
|
||||
itunes_author = models.CharField(max_length=4096, blank=True, null=True)
|
||||
itunes_keywords = models.CharField(max_length=4096, blank=True, null=True)
|
||||
itunes_summary = models.CharField(max_length=4096, blank=True, null=True)
|
||||
itunes_subtitle = models.CharField(max_length=4096, blank=True, null=True)
|
||||
itunes_category = models.CharField(max_length=4096, blank=True, null=True)
|
||||
itunes_explicit = models.CharField(max_length=4096, blank=True, null=True)
|
||||
owner = models.ForeignKey(
|
||||
"core.User", models.DO_NOTHING, db_column="owner", blank=True, null=True
|
||||
)
|
||||
|
||||
def get_owner(self):
|
||||
return self.owner
|
||||
|
||||
class Meta:
|
||||
managed = False
|
||||
db_table = "podcast"
|
||||
permissions = [
|
||||
("change_own_podcast", "Change the podcasts where they are the owner"),
|
||||
("delete_own_podcast", "Delete the podcasts where they are the owner"),
|
||||
]
|
||||
|
||||
|
||||
class PodcastEpisode(models.Model):
|
||||
file = models.ForeignKey("storage.File", models.DO_NOTHING, blank=True, null=True)
|
||||
podcast = models.ForeignKey("Podcast", models.DO_NOTHING)
|
||||
publication_date = models.DateTimeField()
|
||||
download_url = models.CharField(max_length=4096)
|
||||
episode_guid = models.CharField(max_length=4096)
|
||||
episode_title = models.CharField(max_length=4096)
|
||||
episode_description = models.TextField()
|
||||
|
||||
def get_owner(self):
|
||||
return self.podcast.owner
|
||||
|
||||
class Meta:
|
||||
managed = False
|
||||
db_table = "podcast_episodes"
|
||||
permissions = [
|
||||
(
|
||||
"change_own_podcastepisode",
|
||||
"Change the episodes of podcasts where they are the owner",
|
||||
),
|
||||
(
|
||||
"delete_own_podcastepisode",
|
||||
"Delete the episodes of podcasts where they are the owner",
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
class StationPodcast(models.Model):
|
||||
podcast = models.ForeignKey("Podcast", models.DO_NOTHING)
|
||||
|
||||
def get_owner(self):
|
||||
return self.podcast.owner
|
||||
|
||||
class Meta:
|
||||
managed = False
|
||||
db_table = "station_podcast"
|
||||
|
||||
|
||||
class ImportedPodcast(models.Model):
|
||||
auto_ingest = models.BooleanField()
|
||||
auto_ingest_timestamp = models.DateTimeField(blank=True, null=True)
|
||||
album_override = models.BooleanField()
|
||||
podcast = models.ForeignKey("Podcast", models.DO_NOTHING)
|
||||
|
||||
def get_owner(self):
|
||||
return self.podcast.owner
|
||||
|
||||
class Meta:
|
||||
managed = False
|
||||
db_table = "imported_podcast"
|
14
api/libretime_api/podcasts/router.py
Normal file
14
api/libretime_api/podcasts/router.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
from rest_framework import routers
|
||||
|
||||
from .views import (
|
||||
ImportedPodcastViewSet,
|
||||
PodcastEpisodeViewSet,
|
||||
PodcastViewSet,
|
||||
StationPodcastViewSet,
|
||||
)
|
||||
|
||||
router = routers.DefaultRouter()
|
||||
router.register("podcast-episodes", PodcastEpisodeViewSet)
|
||||
router.register("podcasts", PodcastViewSet)
|
||||
router.register("station-podcasts", StationPodcastViewSet)
|
||||
router.register("imported-podcasts", ImportedPodcastViewSet)
|
6
api/libretime_api/podcasts/serializers/__init__.py
Normal file
6
api/libretime_api/podcasts/serializers/__init__.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
from .podcast import (
|
||||
ImportedPodcastSerializer,
|
||||
PodcastEpisodeSerializer,
|
||||
PodcastSerializer,
|
||||
StationPodcastSerializer,
|
||||
)
|
27
api/libretime_api/podcasts/serializers/podcast.py
Normal file
27
api/libretime_api/podcasts/serializers/podcast.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
from rest_framework import serializers
|
||||
|
||||
from ..models import ImportedPodcast, Podcast, PodcastEpisode, StationPodcast
|
||||
|
||||
|
||||
class PodcastSerializer(serializers.HyperlinkedModelSerializer):
|
||||
class Meta:
|
||||
model = Podcast
|
||||
fields = "__all__"
|
||||
|
||||
|
||||
class PodcastEpisodeSerializer(serializers.HyperlinkedModelSerializer):
|
||||
class Meta:
|
||||
model = PodcastEpisode
|
||||
fields = "__all__"
|
||||
|
||||
|
||||
class StationPodcastSerializer(serializers.HyperlinkedModelSerializer):
|
||||
class Meta:
|
||||
model = StationPodcast
|
||||
fields = "__all__"
|
||||
|
||||
|
||||
class ImportedPodcastSerializer(serializers.HyperlinkedModelSerializer):
|
||||
class Meta:
|
||||
model = ImportedPodcast
|
||||
fields = "__all__"
|
6
api/libretime_api/podcasts/views/__init__.py
Normal file
6
api/libretime_api/podcasts/views/__init__.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
from .podcast import (
|
||||
ImportedPodcastViewSet,
|
||||
PodcastEpisodeViewSet,
|
||||
PodcastViewSet,
|
||||
StationPodcastViewSet,
|
||||
)
|
33
api/libretime_api/podcasts/views/podcast.py
Normal file
33
api/libretime_api/podcasts/views/podcast.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
from rest_framework import viewsets
|
||||
|
||||
from ..models import ImportedPodcast, Podcast, PodcastEpisode, StationPodcast
|
||||
from ..serializers import (
|
||||
ImportedPodcastSerializer,
|
||||
PodcastEpisodeSerializer,
|
||||
PodcastSerializer,
|
||||
StationPodcastSerializer,
|
||||
)
|
||||
|
||||
|
||||
class PodcastViewSet(viewsets.ModelViewSet):
|
||||
queryset = Podcast.objects.all()
|
||||
serializer_class = PodcastSerializer
|
||||
model_permission_name = "podcast"
|
||||
|
||||
|
||||
class PodcastEpisodeViewSet(viewsets.ModelViewSet):
|
||||
queryset = PodcastEpisode.objects.all()
|
||||
serializer_class = PodcastEpisodeSerializer
|
||||
model_permission_name = "podcastepisode"
|
||||
|
||||
|
||||
class StationPodcastViewSet(viewsets.ModelViewSet):
|
||||
queryset = StationPodcast.objects.all()
|
||||
serializer_class = StationPodcastSerializer
|
||||
model_permission_name = "station"
|
||||
|
||||
|
||||
class ImportedPodcastViewSet(viewsets.ModelViewSet):
|
||||
queryset = ImportedPodcast.objects.all()
|
||||
serializer_class = ImportedPodcastSerializer
|
||||
model_permission_name = "importedpodcast"
|
Loading…
Add table
Add a link
Reference in a new issue