keymedia/managemedia/models/common.py

45 lines
1.8 KiB
Python

from django.db import models
from django.core import validators
class MediaTypes(models.Model):
MEDIA_TYPES = [
('vg', 'Video Games'),
('mo', 'Movies'),
('tv', 'TV Shows'),
('bo', 'Books'),
]
media_type = models.CharField(
max_length=2,
choices=MEDIA_TYPES,
)
class CommonMediaFields(models.Model):
name = models.CharField('Title', max_length=256)
media_type = models.ForeignKey('MediaTypes', on_delete=models.CASCADE)
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', max_length=256, blank=True)
class Meta:
abstract = True
### VideoFields is for movies and tv shows
class VideoFields(CommonMediaFields):
tmdb_id = models.CharField('TheMovieDB ID', blank=True, max_length=256)
imdb_id = models.CharField('IMDB ID', blank=True, max_length=256)
imdb_rating = models.DecimalField('IMDB rating', max_digits=5, blank=True, decimal_places=3)
tmdb_rating = models.DecimalField('TheMovieDB rating', max_digits=5, blank=True, decimal_places=3)
class Meta:
abstract = True
class Genres(models.Model):
media = models.ForeignKey('MediaTypes', on_delete=models.CASCADE)
genre = models.CharField('Genre', max_length=256)
class MediaStatus(models.Model):
media = models.ForeignKey('MediaTypes', on_delete=models.CASCADE)
status = models.CharField('Status', max_length=256)