Skip to content

Commit

Permalink
fix: change folder where user-uploaded images are stored
Browse files Browse the repository at this point in the history
  • Loading branch information
raphael0202 committed Aug 22, 2024
1 parent 217233e commit a067e2f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 2 additions & 0 deletions config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent

# Directory where user-uploaded images are stored
IMAGES_DIR = BASE_DIR / "img"

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/
Expand Down
4 changes: 1 addition & 3 deletions open_prices/proofs/utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import os
import random
import string
from mimetypes import guess_extension
from pathlib import Path

from django.conf import settings

Expand Down Expand Up @@ -46,7 +44,7 @@ def store_file(file):
# the directory ID
# This is used to prevent the base image directory from containing too many
# files
images_dir = Path(os.path.join(settings.BASE_DIR, "static/img"))
images_dir = settings.IMAGES_DIR
current_dir_id = max(
(int(p.name) for p in images_dir.iterdir() if p.is_dir() and p.name.isdigit()),
default=1,
Expand Down

0 comments on commit a067e2f

Please sign in to comment.