2022-12-07 19:09:05 -05:00
|
|
|
import uuid
|
|
|
|
|
2023-08-10 11:27:31 -04:00
|
|
|
from django.utils import timezone
|
2022-12-07 19:09:05 -05:00
|
|
|
|
|
|
|
|
2023-01-05 03:06:13 -05:00
|
|
|
def resource_cover_path(resource, filename):
|
2022-12-29 23:57:02 -05:00
|
|
|
fn = (
|
|
|
|
timezone.now().strftime("%Y/%m/%d/")
|
|
|
|
+ str(uuid.uuid4())
|
|
|
|
+ "."
|
|
|
|
+ filename.split(".")[-1]
|
|
|
|
)
|
2023-01-08 22:47:43 -05:00
|
|
|
return "item/" + resource.id_type + "/" + fn
|
2023-01-05 03:06:13 -05:00
|
|
|
|
|
|
|
|
|
|
|
def item_cover_path(item, filename):
|
|
|
|
fn = (
|
|
|
|
timezone.now().strftime("%Y/%m/%d/")
|
|
|
|
+ str(uuid.uuid4())
|
|
|
|
+ "."
|
|
|
|
+ filename.split(".")[-1]
|
|
|
|
)
|
2023-01-08 22:47:43 -05:00
|
|
|
return "item/" + item.category + "/" + fn
|
2023-01-12 11:15:28 -05:00
|
|
|
|
|
|
|
|
|
|
|
def piece_cover_path(item, filename):
|
|
|
|
fn = (
|
|
|
|
timezone.now().strftime("%Y/%m/%d/")
|
|
|
|
+ str(uuid.uuid4())
|
|
|
|
+ "."
|
|
|
|
+ filename.split(".")[-1]
|
|
|
|
)
|
2023-07-20 21:59:49 -04:00
|
|
|
return f"user/{item.owner_id or '_'}/{fn}"
|