Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
c3794a4c9f | |||
ef4cca21c8 | |||
476a986c1a |
@ -1,3 +1,4 @@
|
|||||||
asgiref==3.6.0
|
asgiref==3.6.0
|
||||||
Django==4.2.1
|
Django==4.2.1
|
||||||
|
Pillow==9.5.0
|
||||||
sqlparse==0.4.4
|
sqlparse==0.4.4
|
||||||
|
15
ventilator/fan/admin.py
Normal file
15
ventilator/fan/admin.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
from .models import Podcast, PodcastEpisode
|
||||||
|
|
||||||
|
|
||||||
|
class PodcastAdminModel(admin.ModelAdmin):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class PodcastEpisodeAdminModel(admin.ModelAdmin):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
admin.site.register(Podcast, PodcastAdminModel)
|
||||||
|
admin.site.register(PodcastEpisode, PodcastEpisodeAdminModel)
|
@ -1,6 +1,6 @@
|
|||||||
from django.apps import AppConfig
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
class VentilatorConfig(AppConfig):
|
class FanConfig(AppConfig):
|
||||||
default_auto_field = 'django.db.models.BigAutoField'
|
default_auto_field = 'django.db.models.BigAutoField'
|
||||||
name = 'ventilator'
|
name = 'fan'
|
47
ventilator/fan/migrations/0001_initial.py
Normal file
47
ventilator/fan/migrations/0001_initial.py
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
# Generated by Django 4.2.1 on 2023-05-18 17:00
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Podcast',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('uuid', models.UUIDField(default=uuid.uuid4, unique=True)),
|
||||||
|
('slug', models.CharField(max_length=10)),
|
||||||
|
('title', models.CharField(max_length=50)),
|
||||||
|
('author', models.CharField(max_length=200)),
|
||||||
|
('description', models.TextField(max_length=4000)),
|
||||||
|
('image', models.ImageField(upload_to='')),
|
||||||
|
('language', models.CharField(max_length=10)),
|
||||||
|
('published', models.BooleanField(default=False)),
|
||||||
|
('homepage', models.URLField()),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='PodcastEpisode',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('uuid', models.UUIDField(default=uuid.uuid4)),
|
||||||
|
('title', models.CharField(max_length=200)),
|
||||||
|
('audio_file', models.FileField(upload_to='episodes/')),
|
||||||
|
('pub_date', models.DateTimeField()),
|
||||||
|
('description', models.TextField()),
|
||||||
|
('duration', models.DurationField()),
|
||||||
|
('episode_number', models.IntegerField()),
|
||||||
|
('season_number', models.IntegerField()),
|
||||||
|
('published', models.BooleanField(default=False)),
|
||||||
|
('podcast', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='fan.podcast')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
32
ventilator/fan/models.py
Normal file
32
ventilator/fan/models.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
from django.db import models
|
||||||
|
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
|
||||||
|
class Podcast(models.Model):
|
||||||
|
uuid = models.UUIDField(default=uuid.uuid4, unique=True)
|
||||||
|
slug = models.CharField(max_length=10)
|
||||||
|
title = models.CharField(max_length=50)
|
||||||
|
author = models.CharField(max_length=200)
|
||||||
|
description = models.TextField(max_length=4000)
|
||||||
|
image = models.ImageField()
|
||||||
|
language = models.CharField(max_length=10) #TODO: Add Text Choices, ISO 639
|
||||||
|
# iTunes-category (Optional), String
|
||||||
|
published = models.BooleanField(default=False)
|
||||||
|
homepage = models.URLField()
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.title
|
||||||
|
|
||||||
|
|
||||||
|
class PodcastEpisode(models.Model):
|
||||||
|
uuid = models.UUIDField(default=uuid.uuid4)
|
||||||
|
title = models.CharField(max_length=200)
|
||||||
|
audio_file = models.FileField(upload_to="episodes/")
|
||||||
|
pub_date = models.DateTimeField()
|
||||||
|
description = models.TextField()
|
||||||
|
duration = models.DurationField()
|
||||||
|
podcast = models.ForeignKey("Podcast", on_delete=models.CASCADE)
|
||||||
|
episode_number = models.IntegerField()
|
||||||
|
season_number = models.IntegerField()
|
||||||
|
published = models.BooleanField(default=False)
|
24
ventilator/fan/views.py
Normal file
24
ventilator/fan/views.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import mimetypes
|
||||||
|
import os
|
||||||
|
|
||||||
|
from django.http import HttpResponse, FileResponse
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
# Create your views here.
|
||||||
|
def media(request, media_name):
|
||||||
|
#TODO: Check if user is valid
|
||||||
|
if settings.DEBUG:
|
||||||
|
# deliver file from Django
|
||||||
|
file_path = os.path.join(settings.MEDIA_ROOT, media_name)
|
||||||
|
mimetype = mimetypes.guess_type(media_name)
|
||||||
|
|
||||||
|
response = FileResponse(open(file_path, "rb"))
|
||||||
|
response["Content-Type"] = mimetype
|
||||||
|
|
||||||
|
return response
|
||||||
|
else:
|
||||||
|
mimetype = mimetypes.guess_type(image_name)
|
||||||
|
response = HttpResponse()
|
||||||
|
response["Content-Type"] = mimetype
|
||||||
|
response["X-Sendfile"] = os.path.join(settings.MEDIA_ROOT, media_name)
|
||||||
|
return response
|
@ -1,3 +0,0 @@
|
|||||||
from django.contrib import admin
|
|
||||||
|
|
||||||
# Register your models here.
|
|
@ -1,3 +0,0 @@
|
|||||||
from django.db import models
|
|
||||||
|
|
||||||
# Create your models here.
|
|
@ -20,7 +20,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent
|
|||||||
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
|
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
|
||||||
|
|
||||||
# SECURITY WARNING: keep the secret key used in production secret!
|
# SECURITY WARNING: keep the secret key used in production secret!
|
||||||
SECRET_KEY = 'django-insecure-k!rlb6%o#27kbzu*(%8)7(akcvz86-og+ep^p2e(e*6ffd21cj'
|
SECRET_KEY = 'django-insecure-&ysb7-2iiu9s$s!6x175z3-8eo*)3ct1trif#zn!$cr1se+yup'
|
||||||
|
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
@ -37,6 +37,7 @@ INSTALLED_APPS = [
|
|||||||
'django.contrib.sessions',
|
'django.contrib.sessions',
|
||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
|
"fan",
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
@ -110,7 +111,8 @@ TIME_ZONE = 'UTC'
|
|||||||
USE_I18N = True
|
USE_I18N = True
|
||||||
|
|
||||||
USE_TZ = True
|
USE_TZ = True
|
||||||
|
MEDIA_ROOT = ""
|
||||||
|
MEDIA_URL = "media/"
|
||||||
|
|
||||||
# Static files (CSS, JavaScript, Images)
|
# Static files (CSS, JavaScript, Images)
|
||||||
# https://docs.djangoproject.com/en/4.2/howto/static-files/
|
# https://docs.djangoproject.com/en/4.2/howto/static-files/
|
@ -16,7 +16,10 @@ Including another URLconf
|
|||||||
"""
|
"""
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
from fan.views import media
|
||||||
|
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
path("media/<path:media_name>", media, name="media"),
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
]
|
]
|
@ -1,3 +0,0 @@
|
|||||||
from django.shortcuts import render
|
|
||||||
|
|
||||||
# Create your views here.
|
|
Loading…
Reference in New Issue
Block a user