images working again, featured is broken

This commit is contained in:
2025-06-23 05:16:22 -05:00
parent 23fee50a77
commit 289f2f0ca1
4 changed files with 108 additions and 50 deletions

View File

@ -57,20 +57,17 @@ class Media(db.Model):
# If they passed plant_id or growlog_id in kwargs, pick one:
if self.plant_id:
self.plugin = "plants"
self.plugin = "plant"
self.related_id = self.plant_id
elif self.growlog_id:
self.plugin = "grow_logs"
self.plugin = "growlog"
self.related_id = self.growlog_id
else:
# fallback (you might choose to raise instead)
self.plugin = kwargs.get("plugin", "")
self.related_id = kwargs.get("related_id", 0)
# They must also supply `filename` before commit.
# Build `file_url` in the same format your property used to:
date_path = self.uploaded_at.strftime("%Y/%m/%d")
self.file_url = f"{self.plugin}/{self.related_id}/{date_path}/{self.filename}"
self.file_url = f"{self.plugin}/{self.related_id}/{self.filename}"
@property
def url(self):