Don't update translations of an unsaved article. [bug 615787]

This commit is contained in:
James Socol 2010-12-01 11:57:29 -05:00
Родитель cc8ed8874f
Коммит 0403ecca30
2 изменённых файлов: 14 добавлений и 1 удалений

Просмотреть файл

@ -235,7 +235,8 @@ class Document(ModelBase, BigVocabTaggableMixin):
raise ValidationError(_('Please choose a category.'))
else: # An article cannot have both a parent and children.
# Make my children the same as me:
self.translations.all().update(category=self.category)
if self.id:
self.translations.all().update(category=self.category)
def _attr_for_redirect(self, attr, template):
"""Return the slug or title for a new redirect.

Просмотреть файл

@ -220,6 +220,18 @@ class DocumentTests(TestCase):
d = document(category=9999)
self.assertRaises(ValidationError, d.save)
def test_new_doc_does_not_update_categories(self):
"""Make sure that creating a new document doesn't change the
category of all the other documents."""
d1 = document(category=20)
d1.save()
assert d1.pk
d2 = document(category=30)
assert not d2.pk
d2._clean_category()
d1prime = Document.objects.get(pk=d1.pk)
eq_(20, d1prime.category)
class DocumentTestsWithFixture(TestCase):
"""Document tests which need the users fixture"""