Merge pull request #1395 from normanjaeckel/Fix1394

Fixed bug. Projector was not updated when an object was deleted.
This commit is contained in:
Oskar Hahn 2015-01-15 21:14:22 +01:00
commit dac781d8aa
7 changed files with 506 additions and 420 deletions

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-10-16 23:27+0200\n"
"POT-Creation-Date: 2015-01-11 19:03+0100\n"
"Language: en\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"

View File

@ -77,7 +77,7 @@ def setup_motion_config(sender, **kwargs):
motion_amendments_prefix = ConfigVariable(
name='motion_amendments_prefix',
default_value=pgettext('Prefix for amendment', 'A'),
default_value=pgettext('Prefix for the identifier for amendments', 'A'),
form_field=forms.CharField(
required=False,
label=ugettext_lazy('Prefix for the identifier for amendments')))

View File

@ -61,11 +61,16 @@ class SlideMixin(object):
def delete(self, *args, **kwargs):
"""
Updates the projector, if the object is on the projector and is deleted.
Updates the projector if the object is on the projector and is deleted.
"""
from openslides.projector.api import update_projector
# Checking active slide has to be done before calling super().delete()
# because super().delete() deletes the object and than we have no
# access to the former existing primary key any more. But updating
# projector has to be done after deleting the object of course.
update_required = self.is_active_slide()
value = super(SlideMixin, self).delete(*args, **kwargs)
if self.is_active_slide():
if update_required:
update_projector()
return value

11
tests/projector/models.py Normal file
View File

@ -0,0 +1,11 @@
from django.db import models
from openslides.projector.models import SlideMixin
class DummySlideMixinModel(SlideMixin, models.Model):
"""
Dummy model to test the SlideMixin.
"""
slide_callback_name = 'dummy_slides_mixin_model_geu3AiceeG9eo6ohChoD'
title = models.CharField(max_length=255)

View File

@ -0,0 +1,17 @@
from mock import patch
from openslides.config.api import config
from openslides.utils.test import TestCase
from .models import DummySlideMixinModel
class TestSlideMixin(TestCase):
@patch('openslides.projector.api.update_projector')
def test_delete(self, mock_update_projector):
obj = DummySlideMixinModel.objects.create(title='title_cah4AhZai3einoh9koo3')
config['projector_active_slide'] = {
'callback': 'dummy_slides_mixin_model_geu3AiceeG9eo6ohChoD',
'pk': '1'}
obj.delete()
mock_update_projector.assert_called_with()

View File

@ -29,6 +29,7 @@ DATABASES = {
# Add OpenSlides plugins to this list
INSTALLED_PLUGINS = (
'tests.person_api',
'tests.projector',
'tests.utils',
)