cineclub-site/server/myapi/models.py

39 lines
1.4 KiB
Python
Raw Normal View History

2022-04-03 01:20:53 +02:00
from django.db import models
2022-04-03 01:20:53 +02:00
"""
TODO implement validators
- nullable or sure
"""
class Film(models.Model):
2022-04-03 01:20:53 +02:00
class MovieFormat(models.TextChoices):
2022-04-03 01:20:54 +02:00
ANALOG_35 = "35mm"
2022-04-09 02:48:03 +02:00
DIGITAL = "Numérique"
2022-04-03 01:20:53 +02:00
class LanguageSubtitles(models.TextChoices):
2022-04-03 01:20:54 +02:00
FRENCH = "VOF"
FOREIGN = "VOSTFR"
2022-04-03 01:20:53 +02:00
2022-04-09 00:34:47 +02:00
projection_date = models.DateTimeField(null=True, blank=True)
2022-04-03 01:20:53 +02:00
title = models.CharField(max_length=60)
2022-04-03 01:20:54 +02:00
actors = models.JSONField(default=list)
2022-04-09 00:34:47 +02:00
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)
2022-04-03 01:20:54 +02:00
language_subtitles = models.CharField(
2022-04-09 00:34:47 +02:00
max_length=20, choices=LanguageSubtitles.choices,
null=True, blank=True
2022-04-03 01:20:54 +02:00
)
2022-04-09 00:34:47 +02:00
poster_link = models.URLField(null=True, blank=True)
banner_link = models.URLField(null=True, blank=True)
2022-04-03 01:20:53 +02:00
is_confirmed = models.BooleanField(default=False)
def __str__(self):
2022-04-03 01:20:54 +02:00
return f'{self.title} de {self.director} ({self.projection_date.strftime("%d/%m/%Y")})'