lib.itmens/catalog/common/utils.py

34 lines
729 B
Python
Raw Normal View History

import uuid
from django.utils import timezone
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}"