Commit f7fad676 by Alex Gaynor

Correct an issue with saving tags when no tags were includded in a form.

parent 32a5bcc8
...@@ -89,6 +89,11 @@ class TaggableFormTestCase(BaseTaggingTest): ...@@ -89,6 +89,11 @@ class TaggableFormTestCase(BaseTaggingTest):
self.assert_tags_equal(apple.tags.all(), ['green', 'red', 'yummy', 'delicious']) self.assert_tags_equal(apple.tags.all(), ['green', 'red', 'yummy', 'delicious'])
self.assertEqual(Food.objects.count(), 1) self.assertEqual(Food.objects.count(), 1)
f = FoodForm({"name": "raspberry"})
raspberry = f.save()
self.assert_tags_equal(raspberry.tags.all(), [])
class SimilarityByTagTestCase(BaseTaggingTest): class SimilarityByTagTestCase(BaseTaggingTest):
def test_similarity_by_tag(self): def test_similarity_by_tag(self):
"""Test that pears are more similar to apples than watermelons""" """Test that pears are more similar to apples than watermelons"""
...@@ -105,6 +110,7 @@ class SimilarityByTagTestCase(BaseTaggingTest): ...@@ -105,6 +110,7 @@ class SimilarityByTagTestCase(BaseTaggingTest):
self.assertEqual(similar_objs, [pear, watermelon]) self.assertEqual(similar_objs, [pear, watermelon])
self.assertEqual(map(lambda x: x.similar_tags, similar_objs), [3, 2]) self.assertEqual(map(lambda x: x.similar_tags, similar_objs), [3, 2])
class TagReuseTestCase(BaseTaggingTest): class TagReuseTestCase(BaseTaggingTest):
def test_tag_reuse(self): def test_tag_reuse(self):
apple = Food.objects.create(name="apple") apple = Food.objects.create(name="apple")
......
from functools import wraps from functools import wraps
def parse_tags(tags): def parse_tags(tags):
if tags is None:
tags = ""
return [o.strip() for o in tags.split(',') if o.strip()] return [o.strip() for o in tags.split(',') if o.strip()]
def require_instance_manager(func): def require_instance_manager(func):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment