Adding agenda/topics app, fixes user app
This commit is contained in:
parent
14ec6c0f44
commit
cc0049b55b
@ -17,9 +17,11 @@ class AgendaAppConfig(AppConfig):
|
||||
# Import all required stuff.
|
||||
from django.db.models.signals import pre_delete, post_save
|
||||
from openslides.core.config import config
|
||||
from openslides.core.signals import permission_change
|
||||
from openslides.utils.rest_api import router
|
||||
from .config_variables import get_config_variables
|
||||
from .signals import (
|
||||
get_permission_change_data,
|
||||
listen_to_related_object_post_delete,
|
||||
listen_to_related_object_post_save)
|
||||
from .views import ItemViewSet
|
||||
@ -34,6 +36,9 @@ class AgendaAppConfig(AppConfig):
|
||||
pre_delete.connect(
|
||||
listen_to_related_object_post_delete,
|
||||
dispatch_uid='listen_to_related_object_post_delete')
|
||||
permission_change.connect(
|
||||
get_permission_change_data,
|
||||
dispatch_uid='agenda_get_permission_change_data')
|
||||
|
||||
# Register viewsets.
|
||||
router.register(self.get_model('Item').get_collection_string(), ItemViewSet)
|
||||
|
@ -1,3 +1,4 @@
|
||||
from django.apps import apps
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
|
||||
from openslides.utils.autoupdate import inform_changed_data
|
||||
@ -36,3 +37,17 @@ def listen_to_related_object_post_delete(sender, instance, **kwargs):
|
||||
except Item.DoesNotExist:
|
||||
# Item does not exist so we do not have to delete it.
|
||||
pass
|
||||
|
||||
|
||||
def get_permission_change_data(sender, permissions, **kwargs):
|
||||
"""
|
||||
Yields all necessary collections if 'agenda.can_see' or
|
||||
'agenda.can_see_hidden_items' permissions changes.
|
||||
"""
|
||||
agenda_app = apps.get_app_config(app_label='agenda')
|
||||
for permission in permissions:
|
||||
# There could be only one 'agenda.can_see' and then we want to return data.
|
||||
if (permission.content_type.app_label == agenda_app.label
|
||||
and permission.codename in ('can_see', 'can_see_hidden_items')):
|
||||
yield from agenda_app.get_startup_elements()
|
||||
break
|
||||
|
@ -15,9 +15,16 @@ class TopicsAppConfig(AppConfig):
|
||||
from . import projector # noqa
|
||||
|
||||
# Import all required stuff.
|
||||
from openslides.core.signals import permission_change
|
||||
from ..utils.rest_api import router
|
||||
from .signals import get_permission_change_data
|
||||
from .views import TopicViewSet
|
||||
|
||||
# Connect signals.
|
||||
permission_change.connect(
|
||||
get_permission_change_data,
|
||||
dispatch_uid='topics_get_permission_change_data')
|
||||
|
||||
# Register viewsets.
|
||||
router.register(self.get_model('Topic').get_collection_string(), TopicViewSet)
|
||||
|
||||
|
14
openslides/topics/signals.py
Normal file
14
openslides/topics/signals.py
Normal file
@ -0,0 +1,14 @@
|
||||
from django.apps import apps
|
||||
|
||||
|
||||
def get_permission_change_data(sender, permissions, **kwargs):
|
||||
"""
|
||||
Yields all necessary collections from the topics app if
|
||||
'agenda.can_see' permission changes, because topics are strongly
|
||||
connected to the agenda items.
|
||||
"""
|
||||
topics_app = apps.get_app_config(app_label='topics')
|
||||
for permission in permissions:
|
||||
# There could be only one 'agenda.can_see' and then we want to return data.
|
||||
if permission.content_type.app_label == 'agenda' and permission.codename == 'can_see':
|
||||
yield from topics_app.get_startup_elements()
|
@ -8,12 +8,12 @@ from .models import Group, User
|
||||
|
||||
def get_permission_change_data(sender, permissions=None, **kwargs):
|
||||
"""
|
||||
Yields all necessary collections if 'users.can_see' permission changes.
|
||||
Yields all necessary collections if 'users.can_see_name' permission changes.
|
||||
"""
|
||||
users_app = apps.get_app_config(app_label='users')
|
||||
for permission in permissions:
|
||||
# There could be only one 'users.can_see' and then we want to return data.
|
||||
if permission.content_type.app_label == users_app.label and permission.codename == 'can_see':
|
||||
# There could be only one 'users.can_see_name' and then we want to return data.
|
||||
if permission.content_type.app_label == users_app.label and permission.codename == 'can_see_name':
|
||||
yield from users_app.get_startup_elements()
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user