lib.itmens/catalog/common/utils.py
2022-12-08 16:59:03 +00:00

14 lines
334 B
Python

import logging
from django.utils import timezone
import uuid
_logger = logging.getLogger(__name__)
DEFAULT_ITEM_COVER = 'item/default.svg'
def item_cover_path(resource, filename):
fn = timezone.now().strftime('%Y/%m/%d/') + str(uuid.uuid4()) + '.' + filename.split('.')[-1]
return 'items/' + resource.id_type + '/' + fn