diff --git a/openslides/assignments/models.py b/openslides/assignments/models.py index a6f6d1489..3a3063379 100644 --- a/openslides/assignments/models.py +++ b/openslides/assignments/models.py @@ -277,7 +277,8 @@ class Assignment(RESTModelMixin, models.Model): options.append({ 'candidate': related_user.user, 'weight': related_user.weight}) - poll.set_options(options) + poll.set_options(options, skip_autoupdate=True) + inform_changed_data(self) # Add all candidates to list of speakers of related agenda item # TODO: Try to do this in a bulk create diff --git a/openslides/poll/models.py b/openslides/poll/models.py index ccdeec2b8..2cbcbc96a 100644 --- a/openslides/poll/models.py +++ b/openslides/poll/models.py @@ -4,7 +4,6 @@ from django.core.exceptions import ObjectDoesNotExist from django.db import models from django.utils.translation import ugettext as _ -from openslides.utils.autoupdate import inform_changed_data from openslides.utils.models import MinMaxIntegerField @@ -123,7 +122,7 @@ class BasePoll(models.Model): return True return False - def set_options(self, options_data=[]): + def set_options(self, options_data=[], skip_autoupdate=False): """ Adds new option objects to the poll. @@ -132,8 +131,7 @@ class BasePoll(models.Model): for option_data in options_data: option = self.get_option_class()(**option_data) option.poll = self - option.save(skip_autoupdate=True) - inform_changed_data(self.get_assignment()) + option.save(skip_autoupdate=skip_autoupdate) def get_options(self): """ diff --git a/tests/unit/agenda/test_views.py b/tests/unit/agenda/test_views.py index 76d6a4d6c..11efb7638 100644 --- a/tests/unit/agenda/test_views.py +++ b/tests/unit/agenda/test_views.py @@ -52,9 +52,10 @@ class ItemViewSetManageSpeaker(TestCase): mock_queryset = mock_speaker.objects.filter.return_value.exclude.return_value mock_queryset.get.return_value.delete.assert_called_with() + @patch('openslides.agenda.views.inform_changed_data') @patch('openslides.agenda.views.has_perm') @patch('openslides.agenda.views.Speaker') - def test_remove_someone_else(self, mock_speaker, mock_has_perm): + def test_remove_someone_else(self, mock_speaker, mock_has_perm, mock_inform_changed_data): self.request.method = 'DELETE' self.request.user = 1 self.request.data = {'speaker': '1'} @@ -63,7 +64,8 @@ class ItemViewSetManageSpeaker(TestCase): self.view_instance.manage_speaker(self.request) mock_speaker.objects.get.assert_called_with(pk=1) - mock_speaker.objects.get.return_value.delete.assert_called_with() + mock_speaker.objects.get.return_value.delete.assert_called_with(skip_autoupdate=True) + mock_inform_changed_data.assert_called_with(self.mock_item) class ItemViewSetSpeak(TestCase):