OpenSlides/openslides/agenda/signals.py
Oskar Hahn fe64941aab Big Mode for OpenSlides
Uses django channels instead of tornado for the autoupdate. Therefore
tornado is nolonger a dependency of OpenSlides (but channels).

This uses websockets instead of SockJS.

Use the flag insecure in the start command to provide static files serving.

Use a new session backend that has a ForeignKey to User.
2016-06-09 11:14:39 +02:00

30 lines
1.1 KiB
Python

from django.contrib.contenttypes.models import ContentType
from openslides.utils.autoupdate import inform_changed_data
from .models import Item
def listen_to_related_object_post_save(sender, instance, created, **kwargs):
"""
Receiver function to create agenda items. It is connected to the signal
django.db.models.signals.post_save during app loading.
"""
if created and hasattr(instance, 'get_agenda_title'):
Item.objects.create(content_object=instance)
inform_changed_data(instance)
def listen_to_related_object_post_delete(sender, instance, **kwargs):
"""
Receiver function to delete agenda items. It is connected to the signal
django.db.models.signals.post_delete during app loading.
"""
if hasattr(instance, 'get_agenda_title'):
content_type = ContentType.objects.get_for_model(instance)
try:
Item.objects.get(object_id=instance.pk, content_type=content_type).delete()
except Item.DoesNotExist:
# Item does not exist so we do not have to delete it.
pass