rohitjain-rj / django-tagging

Automatically exported from code.google.com/p/django-tagging
Other
0 stars 0 forks source link

edit_string_for_tags handles a single multiword tag incorrectly #184

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
edit_string_for_tags, if given a single tag with the name "spa ces", will
produce the edit string "spa ces". this is a problem because the parsing
function will interpret this as two tags, "spa" and "ces".

There is a unittest attached illustrating the bug.

I think I've fixed it, here's the diff:

=== modified file 'tagging/utils.py'
--- tagging/utils.py    2008-10-23 19:52:44 +0000
+++ tagging/utils.py    2009-02-02 20:17:11 +0000
@@ -124,6 +124,8 @@
         glue = u', '
     else:
         glue = u' '
+    if len(names) == 1:
+        return '"%s"' % names[0]
     return glue.join(names)

 def get_queryset_and_model(queryset_or_model):

Original issue reported on code.google.com by Christia...@gmail.com on 2 Feb 2009 at 8:49

Attachments:

GoogleCodeExporter commented 9 years ago
I'm running into the issue also.

Here is another possible way to work around it.

--- utils-orig.py       2009-09-01 22:43:54.000000000 -0500
+++ utils.py    2009-09-11 18:33:06.376931795 -0500
@@ -122,6 +122,8 @@
         names.append(name)
     if use_commas:
         glue = u', '
+        if len(names) == 1:
+            names.append('')
     else:
         glue = u' '
     return glue.join(names)

Original comment by ribla...@gmail.com on 11 Sep 2009 at 11:37

GoogleCodeExporter commented 9 years ago
Fix applied to my branch on github. Needs testing/review
http://github.com/winhamwr/django-tagging

Original comment by winhamwr on 23 Nov 2009 at 10:06

GoogleCodeExporter commented 9 years ago
I'm surprised this still hasn't addressed. What better bug report could you get 
than 
test cases, a patch, and a working example on github?

Original comment by Christia...@gmail.com on 19 Jan 2010 at 2:32