2014-11-13 22:23:16 +01:00
|
|
|
from django.apps import AppConfig
|
|
|
|
|
|
|
|
|
|
|
|
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
|
2015-10-22 00:01:51 +02:00
|
|
|
js_files = ['js/core/base.js', 'js/core/site.js', 'js/core/projector.js']
|
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
|
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
|
2016-01-25 14:48:00 +01:00
|
|
|
from openslides.core.signals import config_signal, post_permission_creation
|
2015-01-17 14:01:44 +01:00
|
|
|
from openslides.utils.autoupdate import inform_changed_data_receiver
|
2015-01-06 00:04:36 +01:00
|
|
|
from openslides.utils.rest_api import router
|
2016-01-03 15:33:51 +01:00
|
|
|
from openslides.utils.search import index_add_instance, index_del_instance
|
2016-01-25 14:48:00 +01:00
|
|
|
from .signals import delete_django_app_permissions, setup_general_config
|
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,
|
|
|
|
CustomSlideViewSet,
|
|
|
|
ProjectorViewSet,
|
|
|
|
TagViewSet,
|
|
|
|
)
|
2014-11-13 22:23:16 +01:00
|
|
|
|
|
|
|
# Connect signals.
|
2016-01-25 14:48:00 +01:00
|
|
|
config_signal.connect(
|
|
|
|
setup_general_config,
|
|
|
|
dispatch_uid='setup_general_config')
|
|
|
|
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.
|
2015-02-18 01:45:39 +01:00
|
|
|
router.register('core/projector', ProjectorViewSet)
|
2015-09-07 16:46:04 +02:00
|
|
|
router.register('core/chatmessage', ChatMessageViewSet)
|
2015-01-06 00:04:36 +01:00
|
|
|
router.register('core/customslide', CustomSlideViewSet)
|
2015-01-17 14:25:05 +01:00
|
|
|
router.register('core/tag', TagViewSet)
|
2015-06-29 12:08:15 +02:00
|
|
|
router.register('core/config', ConfigViewSet, 'config')
|
2015-01-17 14:01:44 +01:00
|
|
|
|
2015-01-24 16:35:50 +01:00
|
|
|
# Update data when any model of any installed app is saved or deleted.
|
|
|
|
# TODO: Test if the m2m_changed signal is also needed.
|
|
|
|
signals.post_save.connect(
|
|
|
|
inform_changed_data_receiver,
|
|
|
|
dispatch_uid='inform_changed_data_receiver')
|
|
|
|
signals.post_delete.connect(
|
|
|
|
inform_changed_data_receiver,
|
|
|
|
dispatch_uid='inform_changed_data_receiver')
|
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')
|