![FinnStutzenstein](/assets/img/avatar_default.png)
- moved all server related things into the folder `server`, so this configuration is parallel to the client. - All main "services" are now folders in the root directory - Added Dockerfiles to each service (currently server and client) - Added a docker compose configuration to start everything together. Currently there are heavy dependencies into https://github.com/OpenSlides/openslides-docker-compose - Resturctured the .gitignore. If someone needs something excluded, please add it to the right section. - Added initial build setup with Docker and docker-compose. - removed setup.py. We won't deliver OpenSlides via pip anymore.
45 lines
1.1 KiB
Python
45 lines
1.1 KiB
Python
from typing import Any, Dict
|
|
|
|
from django.apps import apps
|
|
|
|
|
|
def get_constants_from_apps() -> Dict[str, Any]:
|
|
out: Dict[str, Any] = {}
|
|
for app in apps.get_app_configs():
|
|
try:
|
|
# Each app can deliver values to angular when implementing this method.
|
|
# It should return a list with dicts containing the 'name' and 'value'.
|
|
get_angular_constants = app.get_angular_constants
|
|
except AttributeError:
|
|
# The app doesn't have this method. Continue to next app.
|
|
continue
|
|
out.update(get_angular_constants())
|
|
return out
|
|
|
|
|
|
constants = None
|
|
|
|
|
|
def get_constants() -> Dict[str, Any]:
|
|
"""
|
|
Returns the constants.
|
|
|
|
This method only returns a static dict, so it is fast and can be used in a
|
|
async context.
|
|
"""
|
|
if constants is None:
|
|
raise RuntimeError("Constants are not set.")
|
|
return constants
|
|
|
|
|
|
def set_constants(value: Dict[str, Any]) -> None:
|
|
"""
|
|
Sets the constants variable.
|
|
"""
|
|
global constants
|
|
constants = value
|
|
|
|
|
|
def set_constants_from_apps() -> None:
|
|
set_constants(get_constants_from_apps())
|