Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
django-taggit
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
6768d4c0
authored
Aug 05, 2010
by
Alex Gaynor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DOn't use spaces for joining strings together in the edit_string, the UX isn't very good.
parent
8d20130c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
13 deletions
+5
-13
taggit/tests/tests.py
+3
-3
taggit/utils.py
+2
-10
No files found.
taggit/tests/tests.py
View file @
6768d4c0
...
@@ -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=""has,comma"
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=""has,comma"
, 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'
)
taggit/utils.py
View file @
6768d4c0
...
@@ -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
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment