store files per-tenant
Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
This commit is contained in:
parent
f0b8fefd56
commit
bfc36bc993
|
@ -19,6 +19,8 @@ from authentik.stages.password import BACKEND_APP_PASSWORD, BACKEND_INBUILT, BAC
|
|||
BASE_DIR = Path(__file__).absolute().parent.parent.parent
|
||||
STATICFILES_DIRS = [BASE_DIR / Path("web")]
|
||||
MEDIA_ROOT = BASE_DIR / Path("media")
|
||||
DEFAULT_FILE_STORAGE = "django_tenants.files.storage.TenantFileSystemStorage"
|
||||
MULTITENANT_RELATIVE_MEDIA_ROOT = "tenants"
|
||||
|
||||
DEBUG = CONFIG.get_bool("debug")
|
||||
SECRET_KEY = CONFIG.get("secret_key")
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
# flake8: noqa
|
||||
from pathlib import Path
|
||||
|
||||
from lifecycle.migrate import BaseMigration
|
||||
|
||||
MEDIA_ROOT = Path(__file__).parent.parent.parent / "media"
|
||||
TENANT_MEDIA_ROOT = MEDIA_ROOT / "tenants"
|
||||
|
||||
|
||||
class Migration(BaseMigration):
|
||||
def needs_migration(self) -> bool:
|
||||
return not TENANT_MEDIA_ROOT.exists()
|
||||
|
||||
def run(self):
|
||||
TENANT_MEDIA_ROOT.mkdir()
|
||||
for d in ("application-icons", "source-icons", "flow-backgrounds"):
|
||||
if (MEDIA_ROOT / d).exists():
|
||||
(MEDIA_ROOT / d).rename(TENANT_MEDIA_ROOT / d)
|
Reference in New Issue