From ef4cca21c89bd6af51ae01a6365e8273a0e627cc Mon Sep 17 00:00:00 2001 From: Nathan Mattes Date: Thu, 18 May 2023 19:01:49 +0200 Subject: [PATCH] Add basic data model (#2) There are podcasts and podcasts have episodes. No magic or other automated stuff here (yet) --- requirements.txt | 1 + ventilator/fan/admin.py | 14 ++++++- ventilator/fan/migrations/0001_initial.py | 47 +++++++++++++++++++++++ ventilator/fan/models.py | 31 ++++++++++++++- 4 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 ventilator/fan/migrations/0001_initial.py diff --git a/requirements.txt b/requirements.txt index f74f171..661b501 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ asgiref==3.6.0 Django==4.2.1 +Pillow==9.5.0 sqlparse==0.4.4 diff --git a/ventilator/fan/admin.py b/ventilator/fan/admin.py index 8c38f3f..d5763e3 100644 --- a/ventilator/fan/admin.py +++ b/ventilator/fan/admin.py @@ -1,3 +1,15 @@ from django.contrib import admin -# Register your models here. +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) diff --git a/ventilator/fan/migrations/0001_initial.py b/ventilator/fan/migrations/0001_initial.py new file mode 100644 index 0000000..f14356c --- /dev/null +++ b/ventilator/fan/migrations/0001_initial.py @@ -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')), + ], + ), + ] diff --git a/ventilator/fan/models.py b/ventilator/fan/models.py index 71a8362..4bb019e 100644 --- a/ventilator/fan/models.py +++ b/ventilator/fan/models.py @@ -1,3 +1,32 @@ from django.db import models -# Create your models here. +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)