Changeset View
Changeset View
Standalone View
Standalone View
films/models/collections.py
| from django.db import models | from django.db import models | ||||
| from django.urls.base import reverse | from django.urls.base import reverse | ||||
| from django.utils.text import slugify | from django.utils.text import slugify | ||||
| from django.contrib.auth.models import User | from django.contrib.auth.models import User | ||||
| from common import mixins | from common import mixins | ||||
| from common.upload_paths import get_upload_to_hashed_path | from common.upload_paths import get_upload_to_hashed_path, shortuid | ||||
| from films.models import films | from films.models import films | ||||
| import common.help_texts | import common.help_texts | ||||
| class ThumbnailAspectRatioChoices(models.TextChoices): | class ThumbnailAspectRatioChoices(models.TextChoices): | ||||
| original = 'original', 'Original' | original = 'original', 'Original' | ||||
| square = '1:1', 'Square (1:1)' | square = '1:1', 'Square (1:1)' | ||||
| widescreen = '16:9', 'Widescreen (16:9)' | widescreen = '16:9', 'Widescreen (16:9)' | ||||
| Show All 9 Lines | class Collection(mixins.CreatedUpdatedMixin, mixins.StaticThumbnailURLMixin, models.Model): | ||||
| film = models.ForeignKey(films.Film, on_delete=models.CASCADE, related_name='collections') | film = models.ForeignKey(films.Film, on_delete=models.CASCADE, related_name='collections') | ||||
| parent = models.ForeignKey( | parent = models.ForeignKey( | ||||
| 'self', on_delete=models.CASCADE, blank=True, null=True, related_name='child_collections' | 'self', on_delete=models.CASCADE, blank=True, null=True, related_name='child_collections' | ||||
| ) | ) | ||||
| order = models.IntegerField(null=True, blank=True) | order = models.IntegerField(null=True, blank=True) | ||||
| name = models.CharField(max_length=512) | name = models.CharField(max_length=512) | ||||
| slug = models.SlugField(blank=True) | slug = models.SlugField(blank=False, null=False, default=shortuid) | ||||
| text = models.TextField(blank=True, help_text=common.help_texts.markdown) | text = models.TextField(blank=True, help_text=common.help_texts.markdown) | ||||
| # TODO(fsiddi) Add text_html | # TODO(fsiddi) Add text_html | ||||
| user = models.ForeignKey(User, null=True, blank=True, on_delete=models.SET_NULL) | user = models.ForeignKey(User, null=True, blank=True, on_delete=models.SET_NULL) | ||||
| thumbnail = models.FileField(upload_to=get_upload_to_hashed_path, blank=True, null=True) | thumbnail = models.FileField(upload_to=get_upload_to_hashed_path, blank=True, null=True) | ||||
| thumbnail_aspect_ratio = models.CharField( | thumbnail_aspect_ratio = models.CharField( | ||||
| choices=ThumbnailAspectRatioChoices.choices, | choices=ThumbnailAspectRatioChoices.choices, | ||||
| Show All 26 Lines | |||||