Add demo mode to all docker setups

This commit is contained in:
Finn Stutzenstein 2020-10-02 09:57:28 +02:00 committed by Sean
parent c0fb65316c
commit fd2fd8d73a
8 changed files with 21 additions and 13 deletions

View File

@ -89,9 +89,9 @@ export class UserRepositoryService extends BaseRepository<ViewUser, User, UserTi
this.sortProperty = conf; this.sortProperty = conf;
this.setConfigSortFn(); this.setConfigSortFn();
}); });
this.constantsService.get<any>('Settings').subscribe(settings => { this.constantsService.get<{ DEMO_USERS?: number[] }>('Settings').subscribe(settings => {
if (settings) { if (settings) {
this.demoModeUserIds = settings.DEMO || null; this.demoModeUserIds = settings.DEMO_USERS || null;
} }
}); });
} }

View File

@ -51,6 +51,7 @@ POSTFIX_RELAYHOST=
# Features # Features
ENABLE_SAML= ENABLE_SAML=
ENABLE_ELECTRONIC_VOTING= ENABLE_ELECTRONIC_VOTING=
DEMO_USERS=
# Connections # Connections
AUTOUPDATE_DELAY= AUTOUPDATE_DELAY=
CONNECTION_POOL_LIMIT= CONNECTION_POOL_LIMIT=

View File

@ -45,6 +45,7 @@ x-osserver:
x-osserver-env: &default-osserver-env x-osserver-env: &default-osserver-env
AMOUNT_REPLICAS: ifenvelse(`REDIS_RO_SERVICE_REPLICAS', 1) AMOUNT_REPLICAS: ifenvelse(`REDIS_RO_SERVICE_REPLICAS', 1)
AUTOUPDATE_DELAY: ifenvelse(`AUTOUPDATE_DELAY', 1) AUTOUPDATE_DELAY: ifenvelse(`AUTOUPDATE_DELAY', 1)
DEMO_USERS: "ifenvelse(`DEMO_USERS',)"
CONNECTION_POOL_LIMIT: ifenvelse(`CONNECTION_POOL_LIMIT', 100) CONNECTION_POOL_LIMIT: ifenvelse(`CONNECTION_POOL_LIMIT', 100)
DATABASE_HOST: "ifenvelse(`DATABASE_HOST', pgbouncer)" DATABASE_HOST: "ifenvelse(`DATABASE_HOST', pgbouncer)"
DATABASE_PASSWORD: "ifenvelse(`DATABASE_PASSWORD', openslides)" DATABASE_PASSWORD: "ifenvelse(`DATABASE_PASSWORD', openslides)"

View File

@ -44,6 +44,7 @@ x-osserver:
x-osserver-env: &default-osserver-env x-osserver-env: &default-osserver-env
AMOUNT_REPLICAS: ifenvelse(`REDIS_RO_SERVICE_REPLICAS', 3) AMOUNT_REPLICAS: ifenvelse(`REDIS_RO_SERVICE_REPLICAS', 3)
AUTOUPDATE_DELAY: ifenvelse(`AUTOUPDATE_DELAY', 1) AUTOUPDATE_DELAY: ifenvelse(`AUTOUPDATE_DELAY', 1)
DEMO_USERS: "ifenvelse(`DEMO_USERS',)"
CONNECTION_POOL_LIMIT: ifenvelse(`CONNECTION_POOL_LIMIT', 100) CONNECTION_POOL_LIMIT: ifenvelse(`CONNECTION_POOL_LIMIT', 100)
DATABASE_HOST: "ifenvelse(`DATABASE_HOST', pgbouncer)" DATABASE_HOST: "ifenvelse(`DATABASE_HOST', pgbouncer)"
DATABASE_PASSWORD: "ifenvelse(`DATABASE_PASSWORD', openslides)" DATABASE_PASSWORD: "ifenvelse(`DATABASE_PASSWORD', openslides)"

View File

@ -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 deactivated by setting it to `None`. It is deactivated per default. The Delay is
given in seconds given in seconds
`DEMO`: Apply special settings for demo use cases. A list of protected user ids handlers `DEMO_USERS`: Apply special settings for demo use cases. A list of protected user ids
to be given. Updating these users (also password) is not allowed. Some bulk actions like handlers to be given. Updating these users (also password) is not allowed. Some bulk
resetting password are completly disabled. Irrelevant for normal use cases. actions like resetting password are completly disabled. Irrelevant for normal use cases.

View File

@ -6,6 +6,7 @@ https://github.com/OpenSlides/OpenSlides/blob/master/SETTINGS.rst
""" """
import os import os
import json
from openslides.global_settings import * from openslides.global_settings import *
@ -19,13 +20,14 @@ undefined = object()
def get_env(name, default=undefined, cast=str): def get_env(name, default=undefined, cast=str):
env = os.environ.get(name) env = os.environ.get(name)
default_extension = "" default_extension = ""
if env is None: if not env:
env = default env = default
default_extension = " (default)" default_extension = " (default)"
if env is undefined: if env is undefined:
raise MissingEnvironmentVariable(name) raise MissingEnvironmentVariable(name)
if env is not None:
if cast is bool: if cast is bool:
env = env in ("1", "true", "True") env = env in ("1", "true", "True")
else: else:
@ -51,7 +53,10 @@ DEBUG = False
# messages. An success message will always be shown. # messages. An success message will always be shown.
RESET_PASSWORD_VERBOSE_ERRORS = get_env("RESET_PASSWORD_VERBOSE_ERRORS", True, bool) RESET_PASSWORD_VERBOSE_ERRORS = get_env("RESET_PASSWORD_VERBOSE_ERRORS", True, bool)
# OpenSlides specific settings
AUTOUPDATE_DELAY = get_env("AUTOUPDATE_DELAY", 1, int) 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 # Email settings
# For SSL/TLS specific settings see https://docs.djangoproject.com/en/1.11/topics/email/#smtp-backend # 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 # Collection Cache
REDIS_ADDRESS = f"redis://{REDIS_HOST}:{REDIS_PORT}/0" REDIS_ADDRESS = f"redis://{REDIS_HOST}:{REDIS_PORT}/0"
REDIS_READ_ONLY_ADDRESS = f"redis://{REDIS_SLAVE_HOST}:{REDIS_SLAVE_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) CONNECTION_POOL_LIMIT = get_env("CONNECTION_POOL_LIMIT", 100, int)
# Session backend # Session backend

View File

@ -133,7 +133,7 @@ class CoreAppConfig(AppConfig):
"JITSI_DOMAIN", "JITSI_DOMAIN",
"JITSI_ROOM_NAME", "JITSI_ROOM_NAME",
"JITSI_ROOM_PASSWORD", "JITSI_ROOM_PASSWORD",
"DEMO", "DEMO_USERS",
] ]
client_settings_dict = {} client_settings_dict = {}
for key in client_settings_keys: for key in client_settings_keys:

View File

@ -56,7 +56,7 @@ from .serializers import GroupSerializer, PermissionRelatedField
from .user_backend import user_backend_manager 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 is_demo_mode = isinstance(demo_mode_users, list) and len(demo_mode_users) > 0
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
if is_demo_mode: if is_demo_mode: