cineclub-site/server/myapi/models.py

39 lines
1.2 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"
DVD = "DVD"
BLU_RAY = "Blu ray"
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
projection_date = models.DateTimeField()
title = models.CharField(max_length=60)
2022-04-03 01:20:54 +02:00
actors = models.JSONField(default=list)
2022-04-03 01:20:53 +02:00
director = models.CharField(max_length=60)
duration = models.DurationField()
synopsis = models.TextField()
origin_country = models.CharField(max_length=60)
release_year = models.SmallIntegerField()
trailer_link = models.URLField()
is_in_color = models.BooleanField()
movie_format = models.CharField(max_length=20, choices=MovieFormat.choices)
2022-04-03 01:20:54 +02:00
language_subtitles = models.CharField(
max_length=20, choices=LanguageSubtitles.choices
)
2022-04-03 01:20:53 +02:00
poster_link = models.URLField()
banner_link = models.URLField()
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")})'