2014-11-13 22:23:16 +01:00
|
|
|
from django.apps import AppConfig
|
2017-01-20 10:23:14 +01:00
|
|
|
from django.conf import settings
|
2014-11-13 22:23:16 +01:00
|
|
|
|
|
|
|
|
|
|
|
class CoreAppConfig(AppConfig):
|
|
|
|
name = 'openslides.core'
|
|
|
|
verbose_name = 'OpenSlides Core'
|
2015-07-01 17:48:41 +02:00
|
|
|
angular_site_module = True
|
|
|
|
angular_projector_module = True
|
2014-11-13 22:23:16 +01:00
|
|
|
|
|
|
|
def ready(self):
|
2015-06-16 10:37:23 +02:00
|
|
|
# Load projector elements.
|
2014-11-13 22:23:16 +01:00
|
|
|
# Do this by just importing all from these files.
|
2015-06-16 10:37:23 +02:00
|
|
|
from . import projector # noqa
|
2016-02-11 22:58:32 +01:00
|
|
|
|
2014-11-13 22:23:16 +01:00
|
|
|
# Import all required stuff.
|
2015-01-17 14:01:44 +01:00
|
|
|
from django.db.models import signals
|
2017-01-14 12:29:42 +01:00
|
|
|
from .config import config
|
|
|
|
from .signals import post_permission_creation
|
|
|
|
from ..utils.rest_api import router
|
|
|
|
from ..utils.search import index_add_instance, index_del_instance
|
2016-06-02 12:47:01 +02:00
|
|
|
from .config_variables import get_config_variables
|
2016-10-21 11:05:24 +02:00
|
|
|
from .signals import delete_django_app_permissions
|
2015-06-29 12:08:15 +02:00
|
|
|
from .views import (
|
2015-09-07 16:46:04 +02:00
|
|
|
ChatMessageViewSet,
|
2015-06-29 12:08:15 +02:00
|
|
|
ConfigViewSet,
|
2016-10-21 11:05:24 +02:00
|
|
|
CountdownViewSet,
|
|
|
|
ProjectorMessageViewSet,
|
2015-06-29 12:08:15 +02:00
|
|
|
ProjectorViewSet,
|
|
|
|
TagViewSet,
|
|
|
|
)
|
2014-11-13 22:23:16 +01:00
|
|
|
|
2016-06-02 12:47:01 +02:00
|
|
|
# Define config variables
|
2016-06-08 22:18:35 +02:00
|
|
|
config.update_config_variables(get_config_variables())
|
2016-06-02 12:47:01 +02:00
|
|
|
|
2014-11-13 22:23:16 +01:00
|
|
|
# Connect signals.
|
2016-01-25 14:48:00 +01:00
|
|
|
post_permission_creation.connect(
|
|
|
|
delete_django_app_permissions,
|
|
|
|
dispatch_uid='delete_django_app_permissions')
|
2014-11-13 22:23:16 +01:00
|
|
|
|
2015-01-17 14:25:05 +01:00
|
|
|
# Register viewsets.
|
2016-02-11 22:58:32 +01:00
|
|
|
router.register(self.get_model('Projector').get_collection_string(), ProjectorViewSet)
|
|
|
|
router.register(self.get_model('ChatMessage').get_collection_string(), ChatMessageViewSet)
|
|
|
|
router.register(self.get_model('Tag').get_collection_string(), TagViewSet)
|
|
|
|
router.register(self.get_model('ConfigStore').get_collection_string(), ConfigViewSet, 'config')
|
2016-10-21 11:05:24 +02:00
|
|
|
router.register(self.get_model('ProjectorMessage').get_collection_string(), ProjectorMessageViewSet)
|
|
|
|
router.register(self.get_model('Countdown').get_collection_string(), CountdownViewSet)
|
2015-01-17 14:01:44 +01:00
|
|
|
|
2016-01-03 15:33:51 +01:00
|
|
|
# Update the search when a model is saved or deleted
|
|
|
|
signals.post_save.connect(
|
|
|
|
index_add_instance,
|
|
|
|
dispatch_uid='index_add_instance')
|
|
|
|
signals.post_delete.connect(
|
|
|
|
index_del_instance,
|
|
|
|
dispatch_uid='index_del_instance')
|
|
|
|
signals.m2m_changed.connect(
|
|
|
|
index_add_instance,
|
|
|
|
dispatch_uid='m2m_index_add_instance')
|
2017-01-14 12:29:42 +01:00
|
|
|
|
|
|
|
def get_startup_elements(self):
|
|
|
|
from .config import config
|
|
|
|
from ..utils.collection import Collection
|
|
|
|
for model in ('Projector', 'ChatMessage', 'Tag', 'ProjectorMessage', 'Countdown'):
|
|
|
|
yield Collection(self.get_model(model).get_collection_string())
|
|
|
|
yield Collection(config.get_collection_string())
|
2017-01-20 10:23:14 +01:00
|
|
|
|
|
|
|
def get_angular_constants(self):
|
|
|
|
# Client settings
|
|
|
|
client_settings_keys = [
|
|
|
|
'MOTIONS_ALLOW_AMENDMENTS_OF_AMENDMENTS'
|
|
|
|
]
|
|
|
|
client_settings_dict = {}
|
|
|
|
for key in client_settings_keys:
|
|
|
|
try:
|
|
|
|
client_settings_dict[key] = getattr(settings, key)
|
|
|
|
except AttributeError:
|
|
|
|
# Settings key does not exist. Do nothing. The client will
|
|
|
|
# treat this as undefined.
|
|
|
|
pass
|
|
|
|
client_settings = {
|
|
|
|
'name': 'OpenSlidesSettings',
|
|
|
|
'value': client_settings_dict}
|
|
|
|
return [client_settings]
|