mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 21:13:36 +00:00
uploads: Add LOCAL_AVATARS_DIR / LOCAL_FILES_DIR computed settings.
This avoids strewing "avatars" and "files" constants throughout.
This commit is contained in:
committed by
Alex Vandiver
parent
24f95a3788
commit
7ad06473b6
@@ -40,6 +40,7 @@ from .configured_settings import (
|
||||
EXTRA_INSTALLED_APPS,
|
||||
GOOGLE_OAUTH2_CLIENT_ID,
|
||||
IS_DEV_DROPLET,
|
||||
LOCAL_UPLOADS_DIR,
|
||||
MEMCACHED_LOCATION,
|
||||
MEMCACHED_USERNAME,
|
||||
RATE_LIMITING_RULES,
|
||||
@@ -539,6 +540,9 @@ if PRODUCTION or IS_DEV_DROPLET or os.getenv("EXTERNAL_HOST") is not None:
|
||||
else:
|
||||
STATIC_URL = "http://localhost:9991/static/"
|
||||
|
||||
LOCAL_AVATARS_DIR = os.path.join(LOCAL_UPLOADS_DIR, "avatars") if LOCAL_UPLOADS_DIR else None
|
||||
LOCAL_FILES_DIR = os.path.join(LOCAL_UPLOADS_DIR, "files") if LOCAL_UPLOADS_DIR else None
|
||||
|
||||
# ZulipStorage is a modified version of ManifestStaticFilesStorage,
|
||||
# and, like that class, it inserts a file hash into filenames
|
||||
# to prevent the browser from using stale files from cache.
|
||||
|
||||
@@ -141,6 +141,8 @@ S3_REGION: Optional[str] = None
|
||||
S3_ENDPOINT_URL: Optional[str] = None
|
||||
S3_SKIP_PROXY = True
|
||||
LOCAL_UPLOADS_DIR: Optional[str] = None
|
||||
LOCAL_AVATARS_DIR: Optional[str] = None
|
||||
LOCAL_FILES_DIR: Optional[str] = None
|
||||
MAX_FILE_UPLOAD_SIZE = 25
|
||||
|
||||
# Jitsi Meet video call integration; set to None to disable integration.
|
||||
|
||||
@@ -125,10 +125,10 @@ i18n_urls = [
|
||||
urls += i18n_urls
|
||||
|
||||
# On a production instance, these files would be served by nginx.
|
||||
if settings.LOCAL_UPLOADS_DIR is not None:
|
||||
if settings.LOCAL_AVATARS_DIR is not None:
|
||||
avatars_url = path(
|
||||
"user_avatars/<path:path>",
|
||||
serve,
|
||||
{"document_root": os.path.join(settings.LOCAL_UPLOADS_DIR, "avatars")},
|
||||
{"document_root": os.path.join(settings.LOCAL_AVATARS_DIR)},
|
||||
)
|
||||
urls += [avatars_url]
|
||||
|
||||
Reference in New Issue
Block a user