Merge pull request #2256 from ostcar/fix_2248
Only do an autoupdate after an ongoing transaction.
This commit is contained in:
commit
aea602acb9
@ -5,6 +5,7 @@ from asgiref.inmemory import ChannelLayer
|
|||||||
from channels import Channel, Group
|
from channels import Channel, Group
|
||||||
from channels.auth import channel_session_user, channel_session_user_from_http
|
from channels.auth import channel_session_user, channel_session_user_from_http
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
|
from django.db import transaction
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
from ..users.auth import AnonymousUser
|
from ..users.auth import AnonymousUser
|
||||||
@ -108,6 +109,10 @@ def inform_changed_data(instance, is_deleted=False):
|
|||||||
# Instance has no method get_root_rest_element. Just ignore it.
|
# Instance has no method get_root_rest_element. Just ignore it.
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
# If currently there is an open database transaction, then the following
|
||||||
|
# function is only called, when the transaction is commited. If there
|
||||||
|
# is currently no transaction, then the function is called immediately.
|
||||||
|
def send_autoupdate():
|
||||||
try:
|
try:
|
||||||
Channel('autoupdate.send_data').send({
|
Channel('autoupdate.send_data').send({
|
||||||
'collection_string': root_instance.get_collection_string(),
|
'collection_string': root_instance.get_collection_string(),
|
||||||
@ -116,6 +121,7 @@ def inform_changed_data(instance, is_deleted=False):
|
|||||||
'dispatch_uid': root_instance.get_access_permissions().get_dispatch_uid()})
|
'dispatch_uid': root_instance.get_access_permissions().get_dispatch_uid()})
|
||||||
except ChannelLayer.ChannelFull:
|
except ChannelLayer.ChannelFull:
|
||||||
pass
|
pass
|
||||||
|
transaction.on_commit(send_autoupdate)
|
||||||
|
|
||||||
|
|
||||||
def inform_changed_data_receiver(sender, instance, **kwargs):
|
def inform_changed_data_receiver(sender, instance, **kwargs):
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# Requirements for OpenSlides in production in alphabetical order
|
# Requirements for OpenSlides in production in alphabetical order
|
||||||
Django>=1.8,<1.11,!=1.10.0
|
Django>=1.9,<1.11,!=1.10.0
|
||||||
beautifulsoup4>=4.5,<4.6
|
beautifulsoup4>=4.5,<4.6
|
||||||
channels>=0.15,<1.0
|
channels>=0.15,<1.0
|
||||||
djangorestframework>=3.2.0,<3.5
|
djangorestframework>=3.2.0,<3.5
|
||||||
|
Loading…
Reference in New Issue
Block a user