added media init

This commit is contained in:
Daniel Tsvetkov 2021-02-22 10:07:05 +01:00
parent 0d02b47df5
commit 3362e6131c

View File

@ -3,6 +3,7 @@ import datetime
import json import json
import os import os
import re import re
from distutils import dir_util
from importlib import import_module from importlib import import_module
from json import JSONEncoder from json import JSONEncoder
from uuid import uuid4 from uuid import uuid4
@ -10,7 +11,7 @@ from uuid import uuid4
from flask import request from flask import request
from flask_security import current_user from flask_security import current_user
from config import SQLALCHEMY_DATABASE_URI, MAKEDIRS, DATABASE_FILE, SEARCH_INDEX_PATH, STATIC_DATA_DIR, basepath from config import SQLALCHEMY_DATABASE_URI, MAKEDIRS, DATABASE_FILE, SEARCH_INDEX_PATH, STATIC_DATA_DIR, MEDIA_DIR, basepath
from flask_migrate import Migrate from flask_migrate import Migrate
from flask_migrate import upgrade as migrate_upgrade from flask_migrate import upgrade as migrate_upgrade
from flask_migrate import init as migrate_init from flask_migrate import init as migrate_init
@ -304,6 +305,9 @@ SENSITIVE_PREFIX = "__SENSITIVE__."
def populate_static(app): def populate_static(app):
static_media_dir = os.path.join(STATIC_DATA_DIR, "media")
if os.path.exists(static_media_dir):
dir_util.copy_tree(static_media_dir, MEDIA_DIR)
with app.app_context(): with app.app_context():
models = import_module("webapp.models") models = import_module("webapp.models")
sensitive = import_module("sensitive") sensitive = import_module("sensitive")