Merge pull request #5602 from FinnStutzenstein/addDemoModeToDocker
Add demo mode to all docker setups
This commit is contained in:
commit
21990aa568
@ -101,9 +101,9 @@ export class UserRepositoryService extends BaseRepository<ViewUser, User, UserTi
|
||||
this.sortProperty = conf;
|
||||
this.setConfigSortFn();
|
||||
});
|
||||
this.constantsService.get<any>('Settings').subscribe(settings => {
|
||||
this.constantsService.get<{ DEMO_USERS?: number[] }>('Settings').subscribe(settings => {
|
||||
if (settings) {
|
||||
this.demoModeUserIds = settings.DEMO || null;
|
||||
this.demoModeUserIds = settings.DEMO_USERS || null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -51,6 +51,7 @@ POSTFIX_RELAYHOST=
|
||||
# Features
|
||||
ENABLE_SAML=
|
||||
ENABLE_ELECTRONIC_VOTING=
|
||||
DEMO_USERS=
|
||||
# Connections
|
||||
AUTOUPDATE_DELAY=
|
||||
CONNECTION_POOL_LIMIT=
|
||||
|
@ -45,6 +45,7 @@ x-osserver:
|
||||
x-osserver-env: &default-osserver-env
|
||||
AMOUNT_REPLICAS: ifenvelse(`REDIS_RO_SERVICE_REPLICAS', 1)
|
||||
AUTOUPDATE_DELAY: ifenvelse(`AUTOUPDATE_DELAY', 1)
|
||||
DEMO_USERS: "ifenvelse(`DEMO_USERS',)"
|
||||
CONNECTION_POOL_LIMIT: ifenvelse(`CONNECTION_POOL_LIMIT', 100)
|
||||
DATABASE_HOST: "ifenvelse(`DATABASE_HOST', pgbouncer)"
|
||||
DATABASE_PASSWORD: "ifenvelse(`DATABASE_PASSWORD', openslides)"
|
||||
|
@ -44,6 +44,7 @@ x-osserver:
|
||||
x-osserver-env: &default-osserver-env
|
||||
AMOUNT_REPLICAS: ifenvelse(`REDIS_RO_SERVICE_REPLICAS', 3)
|
||||
AUTOUPDATE_DELAY: ifenvelse(`AUTOUPDATE_DELAY', 1)
|
||||
DEMO_USERS: "ifenvelse(`DEMO_USERS',)"
|
||||
CONNECTION_POOL_LIMIT: ifenvelse(`CONNECTION_POOL_LIMIT', 100)
|
||||
DATABASE_HOST: "ifenvelse(`DATABASE_HOST', pgbouncer)"
|
||||
DATABASE_PASSWORD: "ifenvelse(`DATABASE_PASSWORD', openslides)"
|
||||
|
@ -147,6 +147,6 @@ these requests from "prioritized clients" can be routed to different servers.
|
||||
deactivated by setting it to `None`. It is deactivated per default. The Delay is
|
||||
given in seconds
|
||||
|
||||
`DEMO`: Apply special settings for demo use cases. A list of protected user ids handlers
|
||||
to be given. Updating these users (also password) is not allowed. Some bulk actions like
|
||||
resetting password are completly disabled. Irrelevant for normal use cases.
|
||||
`DEMO_USERS`: Apply special settings for demo use cases. A list of protected user ids
|
||||
handlers to be given. Updating these users (also password) is not allowed. Some bulk
|
||||
actions like resetting password are completly disabled. Irrelevant for normal use cases.
|
@ -6,6 +6,7 @@ https://github.com/OpenSlides/OpenSlides/blob/master/SETTINGS.rst
|
||||
"""
|
||||
|
||||
import os
|
||||
import json
|
||||
from openslides.global_settings import *
|
||||
|
||||
|
||||
@ -19,17 +20,18 @@ undefined = object()
|
||||
def get_env(name, default=undefined, cast=str):
|
||||
env = os.environ.get(name)
|
||||
default_extension = ""
|
||||
if env is None:
|
||||
if not env:
|
||||
env = default
|
||||
default_extension = " (default)"
|
||||
|
||||
if env is undefined:
|
||||
raise MissingEnvironmentVariable(name)
|
||||
|
||||
if cast is bool:
|
||||
env = env in ("1", "true", "True")
|
||||
else:
|
||||
env = cast(env)
|
||||
if env is not None:
|
||||
if cast is bool:
|
||||
env = env in ("1", "true", "True")
|
||||
else:
|
||||
env = cast(env)
|
||||
|
||||
if env is None:
|
||||
print(f"{name}={default_extension}", flush=True)
|
||||
@ -51,7 +53,10 @@ DEBUG = False
|
||||
# messages. An success message will always be shown.
|
||||
RESET_PASSWORD_VERBOSE_ERRORS = get_env("RESET_PASSWORD_VERBOSE_ERRORS", True, bool)
|
||||
|
||||
# OpenSlides specific settings
|
||||
AUTOUPDATE_DELAY = get_env("AUTOUPDATE_DELAY", 1, int)
|
||||
DEMO_USERS = get_env("DEMO_USERS", default=None)
|
||||
DEMO_USERS = json.loads(DEMO_USERS) if DEMO_USERS else None
|
||||
|
||||
# Email settings
|
||||
# For SSL/TLS specific settings see https://docs.djangoproject.com/en/1.11/topics/email/#smtp-backend
|
||||
@ -109,7 +114,7 @@ CHANNEL_LAYERS = {
|
||||
# Collection Cache
|
||||
REDIS_ADDRESS = f"redis://{REDIS_HOST}:{REDIS_PORT}/0"
|
||||
REDIS_READ_ONLY_ADDRESS = f"redis://{REDIS_SLAVE_HOST}:{REDIS_SLAVE_PORT}/0"
|
||||
AMOUNT_REPLICAS = get_env("AMOUNT_REPLICAS", 1)
|
||||
AMOUNT_REPLICAS = get_env("AMOUNT_REPLICAS", 1, int)
|
||||
CONNECTION_POOL_LIMIT = get_env("CONNECTION_POOL_LIMIT", 100, int)
|
||||
|
||||
# Session backend
|
||||
|
@ -133,7 +133,7 @@ class CoreAppConfig(AppConfig):
|
||||
"JITSI_DOMAIN",
|
||||
"JITSI_ROOM_NAME",
|
||||
"JITSI_ROOM_PASSWORD",
|
||||
"DEMO",
|
||||
"DEMO_USERS",
|
||||
]
|
||||
client_settings_dict = {}
|
||||
for key in client_settings_keys:
|
||||
|
@ -56,7 +56,7 @@ from .serializers import GroupSerializer, PermissionRelatedField
|
||||
from .user_backend import user_backend_manager
|
||||
|
||||
|
||||
demo_mode_users = getattr(settings, "DEMO", None)
|
||||
demo_mode_users = getattr(settings, "DEMO_USERS", None)
|
||||
is_demo_mode = isinstance(demo_mode_users, list) and len(demo_mode_users) > 0
|
||||
logger = logging.getLogger(__name__)
|
||||
if is_demo_mode:
|
||||
|
Loading…
Reference in New Issue
Block a user