foldbank-mock/backend/foldbank/utils.py
Ameya Shenoy 6bb49337c3
feat: backend with models
Signed-off-by: Ameya Shenoy <shenoy.ameya@gmail.com>
2023-03-19 19:12:47 +05:30

19 lines
427 B
Python

import pathlib
import datetime
def get_file_extension(file):
return pathlib.Path(file.name).suffix
def generate_filename_for_storage(file):
ext = get_file_extension(file)
filename = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
return f"{filename}{ext}"
def get_bank_logo_file_path(self, _):
filename = generate_filename_for_storage(self.logo)
return f"images/bank/{self.pk}/logo/{filename}"