F(backend): add public media derivatives pipeline
Some checks failed
Backend CI/CD / test (push) Has been cancelled
Backend CI/CD / deploy (push) Has been cancelled

This commit is contained in:
2026-05-20 14:26:51 +03:30
parent 88b793ed9f
commit b4903f7cb1
18 changed files with 710 additions and 53 deletions

View File

@@ -10,6 +10,11 @@ import uuid
import markdown
from location_field.models.plain import PlainLocationField as LocationField
from core.media import (
delete_image_derivatives_by_name,
get_image_previous_name,
safe_process_public_image,
)
from core.models import BaseModel
@@ -68,10 +73,24 @@ class Event(BaseModel):
return self.title
def save(self, *args, **kwargs):
previous_image_name = get_image_previous_name(self, "featured_image")
current_image_name = self.featured_image.name if self.featured_image else None
if not self.slug:
self.slug = slugify(self.title)
super().save(*args, **kwargs)
if previous_image_name != current_image_name and previous_image_name:
delete_image_derivatives_by_name(
self.featured_image.storage if self.featured_image else None,
previous_image_name,
"event_featured",
delete_original=True,
)
if previous_image_name != current_image_name and self.featured_image:
safe_process_public_image(self.featured_image, "event_featured")
@property
def description_html(self):
"""Convert markdown description to HTML"""