fixted #330. Error if the related slide for an Agenda Item does not exists

This commit is contained in:
Oskar Hahn 2012-08-05 11:28:56 +02:00
parent bcd98301a9
commit 4873cd7163
2 changed files with 14 additions and 3 deletions

View File

@ -52,7 +52,14 @@ class Item(MPTTModel, SlideMixin):
""" """
return the object, of which the item points. return the object, of which the item points.
""" """
return get_slide_from_sid(self.related_sid, True) object = get_slide_from_sid(self.related_sid, element=True)
if object is None:
self.title = 'Item for deleted slide: %s' % self.related_sid
self.related_sid = None
self.save()
return self
else:
return object
def get_related_type(self): def get_related_type(self):
""" """

View File

@ -15,9 +15,9 @@ from django.test.client import Client
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.db.models.query import EmptyQuerySet from django.db.models.query import EmptyQuerySet
from projector.api import get_active_slide from openslides.projector.api import get_active_slide
from agenda.models import Item from openslides.agenda.models import Item
class ItemTest(TestCase): class ItemTest(TestCase):
def setUp(self): def setUp(self):
@ -60,6 +60,10 @@ class ItemTest(TestCase):
self.assertEqual(initial['parent'], 0) self.assertEqual(initial['parent'], 0)
self.assertEqual(initial['weight'], item.weight) self.assertEqual(initial['weight'], item.weight)
def testRelated_sid(self):
self.item1.related_sid = 'foobar'
self.assertFalse(self.item1.get_related_slide() is None)
class ViewTest(TestCase): class ViewTest(TestCase):
def setUp(self): def setUp(self):