keymedia/managemedia/models/common.py

45 lines
1.8 KiB
Python
Raw Normal View History

2020-06-08 19:21:18 -04:00
from django.db import models
2020-06-12 15:43:36 -04:00
from django.core import validators
2020-06-08 19:21:18 -04:00
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):
2020-06-12 15:43:36 -04:00
name = models.CharField('Title', max_length=256)
2020-06-12 17:49:58 -04:00
media_type = models.ForeignKey('MediaTypes', on_delete=models.CASCADE)
2020-06-08 20:25:22 -04:00
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)
2020-06-08 19:21:18 -04:00
creation_date = models.DateTimeField('Added Date', auto_now_add=True)
updated_date = models.DateTimeField('Updated Date', auto_now=True)
2020-06-12 17:49:58 -04:00
original_language = models.CharField('Original Language', max_length=256, blank=True)
2020-06-08 19:21:18 -04:00
class Meta:
abstract = True
2020-06-09 11:18:39 -04:00
2020-06-08 20:25:22 -04:00
### VideoFields is for movies and tv shows
2020-06-12 11:17:30 -04:00
class VideoFields(CommonMediaFields):
2020-06-12 17:49:58 -04:00
tmdb_id = models.CharField('TheMovieDB ID', blank=True, max_length=256)
imdb_id = models.CharField('IMDB ID', blank=True, max_length=256)
2020-06-12 15:43:36 -04:00
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)
2020-06-08 19:21:18 -04:00
class Meta:
abstract = True
class Genres(models.Model):
2020-06-12 15:43:36 -04:00
media = models.ForeignKey('MediaTypes', on_delete=models.CASCADE)
2020-06-12 17:49:58 -04:00
genre = models.CharField('Genre', max_length=256)
2020-06-08 19:21:18 -04:00
class MediaStatus(models.Model):
2020-06-12 15:43:36 -04:00
media = models.ForeignKey('MediaTypes', on_delete=models.CASCADE)
2020-06-12 17:49:58 -04:00
status = models.CharField('Status', max_length=256)