Initial commit from ZIP

This commit is contained in:
kusz committed 2024-11-27 13:18:16 +01:00
commit 378d4692a9
454 files changed
+40367

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
from django.db import models
from django.utils.translation import gettext_lazy as _
from rules.contrib.models import RulesModel
from outbo.apps.core.models import TimestampableDeletableMixin
from outbo.apps.final_photobriefing.enums import PhotoType
class Photo(TimestampableDeletableMixin, RulesModel):
brief = models.ForeignKey(
verbose_name=_("photo brief"),
to="Brief",
on_delete=models.CASCADE,
related_name="photos",
related_query_name="photo",
)
type = models.CharField(
max_length=50,
choices=((type, type.value) for type in PhotoType),
default=PhotoType.INVALID,
)
def filename(self, filename):
return f"projects/{self.brief.product.project.slug[1:]}/photos/{filename}"
file = models.ImageField(verbose_name=_("file"), upload_to=filename)