cineclub-site/server/myapi/models.py

49 lines
1.8 KiB
Python

from django.db import models
"""
TODO implement validators
- nullable or sure
"""
class Film(models.Model):
class MovieFormat(models.TextChoices):
ANALOG_35 = "35mm"
DIGITAL = "Numérique"
class LanguageSubtitles(models.TextChoices):
FRENCH = "VOF"
FOREIGN = "VOSTFR"
projection_date = models.DateTimeField(null=True, blank=True)
title = models.CharField(max_length=60)
actors = models.JSONField(default=list)
director = models.CharField(max_length=60, null=True, blank=True)
duration = models.DurationField(null=True, blank=True)
synopsis = models.TextField(null=True, blank=True)
origin_country = models.CharField(max_length=60, null=True, blank=True)
release_year = models.SmallIntegerField(null=True, blank=True)
trailer_link = models.URLField(null=True, blank=True)
is_in_color = models.BooleanField(null=True, blank=True)
movie_format = models.CharField(
max_length=20, choices=MovieFormat.choices, null=True, blank=True
)
language_subtitles = models.CharField(
max_length=20, choices=LanguageSubtitles.choices, null=True, blank=True
)
poster_link = models.URLField(null=True, blank=True)
banner_link = models.URLField(null=True, blank=True)
is_confirmed = models.BooleanField(default=False)
imdb_id = models.CharField(max_length=10, null=True, blank=True)
tmdb_id = models.IntegerField(null=True, blank=True)
facebook_event_link = models.URLField(null=True, blank=True)
def __str__(self):
return f'{self.title} de {self.director} ({self.projection_date.strftime("%d/%m/%Y")})'
def is_publishable(self):
return (
self.title is not None
and self.poster_link is not None
and self.projection_date is not None
)