From b016a4c649c68e4860e3b80da8a36fce08f9df49 Mon Sep 17 00:00:00 2001 From: Daniel Martinez Date: Mon, 8 Jun 2020 20:25:22 -0400 Subject: [PATCH] further model building --- managemedia/models/books.py | 16 ++++++++++++++++ managemedia/models/common.py | 20 +++++++++++--------- managemedia/models/movies.py | 16 ++++++++-------- managemedia/models/tv.py | 16 ++++++++++++++++ managemedia/models/vgames.py | 27 ++++++++++++++++++++++----- 5 files changed, 73 insertions(+), 22 deletions(-) diff --git a/managemedia/models/books.py b/managemedia/models/books.py index e69de29..1a49a15 100644 --- a/managemedia/models/books.py +++ b/managemedia/models/books.py @@ -0,0 +1,16 @@ +from django.db import models + +class Book(CommonMediaFields) + author = models.ForeignKey('Author') + series = models.ForeignKey('Series', blank=True) + series_entry = models.BooleanField('Series Entry', blank=True) + is_comic = models.BooleanField('Comic') + is_manga = models.BooleanField('Manga') + +class Author(models.Model) + name = models.CharFields('Author', unique=True) + sort_name = models.CharFields('Author sort name', blank=True) + +class Series(models.Model) + name = models.CharFields('Series', unique=True) + total_entries = models.PositiveIntegerField('Total Entries', blank=True) diff --git a/managemedia/models/common.py b/managemedia/models/common.py index f1083f0..9d88a6b 100644 --- a/managemedia/models/common.py +++ b/managemedia/models/common.py @@ -10,25 +10,27 @@ class MediaTypes(models.Model): media_type = models.CharField( max_length=2, choices=MEDIA_TYPES, - default='mo', ) class CommonMediaFields(models.Model): name = models.CharField('Title', maxlength=256) media_type = models.ForeignKey('MediaType') - summary = models.TextField('Summary') - release_date = models.DateField('Release Date') + summary = models.TextField('Summary', blank=True) + cover = models.ImageField('Cover Image', blank=True) + backdrop = models.ImageField('Backdrop Image', blank=True) + release_date = models.DateField('Release Date', blank=True) creation_date = models.DateTimeField('Added Date', auto_now_add=True) updated_date = models.DateTimeField('Updated Date', auto_now=True) - original_language = models.CharField('Original Language') + original_language = models.CharField('Original Language', blank=True) class Meta: abstract = True - + +### VideoFields is for movies and tv shows class VideoFields(CommonFields): - tmdb_id = models.PositiveIntegerField('TheMovieDB ID') - imdb_id = models.PositiveIntegerField('IMDB ID') - tmdb_rating = models.PositiveIntegerField('TheMovieDB rating', max_value=100) - mc_rating = models.PositiveIntegerFrield('MetaCritic Rating', max_value=100) + tmdb_id = models.PositiveIntegerField('TheMovieDB ID', blank=True) + imdb_id = models.PositiveIntegerField('IMDB ID', blank=True) + tmdb_rating = models.PositiveIntegerField('TheMovieDB rating', max_value=100, blank=True) + mc_rating = models.PositiveIntegerFrield('MetaCritic Rating', max_value=100, blank=True) class Meta: abstract = True diff --git a/managemedia/models/movies.py b/managemedia/models/movies.py index b445869..64306ae 100644 --- a/managemedia/models/movies.py +++ b/managemedia/models/movies.py @@ -1,17 +1,17 @@ +from django.db import models + class Film(VideoFields): - original_title = models.CharField('Original Title', maxlength=256) - tagline = modelx.CharField('Tagline') - runtime = models.PositiveIntegerField('Total Runtime') - cover = models.ImageField('Cover Image') - backdrop = models.ImageField('Backdrop Image') - rt_rating = models.PositiveIntegerField('Rotten Tomatoes Rating', max_value=100) - am_rating = models.DecimalField('AllMovie Rating', max_digits=3, decimal_places=1) + original_title = models.CharField('Original Title', maxlength=256, blank=True) + tagline = models.CharField('Tagline', blank=True) + runtime = models.PositiveIntegerField('Total Runtime', blank=True) + rt_rating = models.PositiveIntegerField('Rotten Tomatoes Rating', max_value=100, blank=True) + am_rating = models.DecimalField('AllMovie Rating', max_digits=3, decimal_places=1, blank=True) class FilmAltTitles(models.Model): film = models.ForeignKey('Film', on_delete=models.CASCADE) title = models.CharField('Title') country = models.CharField('Country') - type = models.CharField('Type') + title_type = models.CharField('Type', blank=True) class FilmGenres(models.Model): film = models.ForeignKey('Film', on_delete=models.CASCADE) diff --git a/managemedia/models/tv.py b/managemedia/models/tv.py index e69de29..77f629a 100644 --- a/managemedia/models/tv.py +++ b/managemedia/models/tv.py @@ -0,0 +1,16 @@ +from django.db import models + +class Television(VideoFields) + episodes = models.PositiveIntegerField('Number of Episodes', min_value=1, blank=True) + seasons = models.PositiveIntegerField('Number of Seasons', min_value=1, blank=True) + first_aired = models.DateField('First Aired Date', blank=True) + last_aired = models.DateField('Last Aired Date', blank=True) + networks = models.ForeignKey('Networks', blank=True) + status = models.CharField('Status', blank=True) + +class Networks(models.Model) + name = models.CharField('Network') + +class ShowtoNetworks(models.Model) + show = models.ForeignKey('Television') + network = models.ForeignKey('Networks') diff --git a/managemedia/models/vgames.py b/managemedia/models/vgames.py index 92ed872..0bd757f 100644 --- a/managemedia/models/vgames.py +++ b/managemedia/models/vgames.py @@ -1,9 +1,26 @@ +from django.db import models + class VGames(CommonMediaFields) tgdb_id = models.PositiveIntegerField('TheGamesDB ID') platform = models.ForeignKey('Platform') - developer = models.CharField('Developers') - publisher = models.CharField('Publishers') - cover = models.ImageField('Cover Image') - players = models.PositiveIntegerField('Players') - coop = models.BooleanField('Co-Op') + cover = models.ImageField('Cover Image', blank=True) + players = models.PositiveIntegerField('Players', blank=True) + coop = models.BooleanField('Co-Op', blank=True) + mc_rating = models.PositiveIntegerFrield('MetaCritic Rating', max_value=100, blank=True) +class Publishers(models.Model) + name = models.CharField('Publisher Name') + +class Developers(models.Model) + name = models.CharField('Developer Name') + +class Platforms(models.Model) + name = models.CharField('Game System') + +class PublisherMap(models.Model) + publisher = models.ForeignKey('Publishers') + game = models.ForeignKey('VGames') + +class DeveloperMap(models.Model) + developer = models.ForeignKey('Developers') + game = models.ForeignKey('VGames')