Commit 6768d4c0 by Alex Gaynor

DOn't use spaces for joining strings together in the edit_string, the UX isn't very good.

parent 8d20130c
...@@ -235,11 +235,11 @@ class TaggableFormTestCase(BaseTaggingTestCase): ...@@ -235,11 +235,11 @@ class TaggableFormTestCase(BaseTaggingTestCase):
self.assert_tags_equal(raspberry.tags.all(), []) self.assert_tags_equal(raspberry.tags.all(), [])
f = self.form_class(instance=apple) f = self.form_class(instance=apple)
self.assertEqual(str(f), """<tr><th><label for="id_name">Name:</label></th><td><input id="id_name" type="text" name="name" value="apple" maxlength="50" /></td></tr>\n<tr><th><label for="id_tags">Tags:</label></th><td><input type="text" name="tags" value="delicious green red yummy" id="id_tags" /><br />A comma-separated list of tags.</td></tr>""") self.assertEqual(str(f), """<tr><th><label for="id_name">Name:</label></th><td><input id="id_name" type="text" name="name" value="apple" maxlength="50" /></td></tr>\n<tr><th><label for="id_tags">Tags:</label></th><td><input type="text" name="tags" value="delicious, green, red, yummy" id="id_tags" /><br />A comma-separated list of tags.</td></tr>""")
apple.tags.add('has,comma') apple.tags.add('has,comma')
f = self.form_class(instance=apple) f = self.form_class(instance=apple)
self.assertEqual(str(f), """<tr><th><label for="id_name">Name:</label></th><td><input id="id_name" type="text" name="name" value="apple" maxlength="50" /></td></tr>\n<tr><th><label for="id_tags">Tags:</label></th><td><input type="text" name="tags" value="&quot;has,comma&quot; delicious green red yummy" id="id_tags" /><br />A comma-separated list of tags.</td></tr>""") self.assertEqual(str(f), """<tr><th><label for="id_name">Name:</label></th><td><input id="id_name" type="text" name="name" value="apple" maxlength="50" /></td></tr>\n<tr><th><label for="id_tags">Tags:</label></th><td><input type="text" name="tags" value="&quot;has,comma&quot;, delicious, green, red, yummy" id="id_tags" /><br />A comma-separated list of tags.</td></tr>""")
class TaggableFormDirectTestCase(TaggableFormTestCase): class TaggableFormDirectTestCase(TaggableFormTestCase):
...@@ -332,5 +332,5 @@ class TagStringParseTestCase(UnitTestCase): ...@@ -332,5 +332,5 @@ class TagStringParseTestCase(UnitTestCase):
self.assertEqual(edit_string_for_tags([plain]), u'plain') self.assertEqual(edit_string_for_tags([plain]), u'plain')
self.assertEqual(edit_string_for_tags([plain, spaces]), u'plain, spa ces') self.assertEqual(edit_string_for_tags([plain, spaces]), u'plain, spa ces')
self.assertEqual(edit_string_for_tags([plain, spaces, comma]), u'"com,ma", plain, spa ces') self.assertEqual(edit_string_for_tags([plain, spaces, comma]), u'"com,ma", plain, spa ces')
self.assertEqual(edit_string_for_tags([plain, comma]), u'"com,ma" plain') self.assertEqual(edit_string_for_tags([plain, comma]), u'"com,ma", plain')
self.assertEqual(edit_string_for_tags([comma, spaces]), u'"com,ma", spa ces') self.assertEqual(edit_string_for_tags([comma, spaces]), u'"com,ma", spa ces')
...@@ -108,21 +108,13 @@ def edit_string_for_tags(tags): ...@@ -108,21 +108,13 @@ def edit_string_for_tags(tags):
<http://django-tagging.googlecode.com/>`_ <http://django-tagging.googlecode.com/>`_
""" """
names = [] names = []
use_commas = False
for tag in tags: for tag in tags:
name = tag.name name = tag.name
if u',' in name: if u',' in name:
names.append('"%s"' % name) names.append('"%s"' % name)
continue
elif u' ' in name:
if not use_commas:
use_commas = True
names.append(name)
if use_commas:
glue = u', '
else: else:
glue = u' ' names.append(name)
return glue.join(sorted(names)) return u', '.join(sorted(names))
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