images working again, featured is broken
This commit is contained in:
@ -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):
|
||||
|
Reference in New Issue
Block a user