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
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
Commit
f3657783
authored
Aug 27, 2010
by
Carl Meyer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
quote multiword tags so they round-trip
parent
4b0d0dc4
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
5 deletions
+9
-5
docs/forms.txt
+1
-1
taggit/tests/tests.py
+7
-3
taggit/utils.py
+1
-1
No files found.
docs/forms.txt
View file @
f3657783
...
@@ -42,7 +42,7 @@ If, when saving a form, you use the ``commit=False`` option you'll need to call
...
@@ -42,7 +42,7 @@ If, when saving a form, you use the ``commit=False`` option you'll need to call
form with normal many to many fields on it::
form with normal many to many fields on it::
if request.method == "POST":
if request.method == "POST":
form = MyFormClass(reque
ts
.POST)
form = MyFormClass(reque
st
.POST)
if form.is_valid():
if form.is_valid():
obj = form.save(commit=False)
obj = form.save(commit=False)
obj.user = request.user
obj.user = request.user
...
...
taggit/tests/tests.py
View file @
f3657783
...
@@ -241,6 +241,10 @@ class TaggableFormTestCase(BaseTaggingTestCase):
...
@@ -241,6 +241,10 @@ class TaggableFormTestCase(BaseTaggingTestCase):
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>"""
)
apple
.
tags
.
add
(
'has space'
)
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 space", "has,comma", delicious, green, red, yummy" id="id_tags" /><br />A comma-separated list of tags.</td></tr>"""
)
class
TaggableFormDirectTestCase
(
TaggableFormTestCase
):
class
TaggableFormDirectTestCase
(
TaggableFormTestCase
):
form_class
=
DirectFoodForm
form_class
=
DirectFoodForm
...
@@ -330,7 +334,7 @@ class TagStringParseTestCase(UnitTestCase):
...
@@ -330,7 +334,7 @@ class TagStringParseTestCase(UnitTestCase):
spaces
=
Tag
.
objects
.
create
(
name
=
'spa ces'
)
spaces
=
Tag
.
objects
.
create
(
name
=
'spa ces'
)
comma
=
Tag
.
objects
.
create
(
name
=
'com,ma'
)
comma
=
Tag
.
objects
.
create
(
name
=
'com,ma'
)
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'
"spa ces", plain
'
)
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",
"spa ces", plain
'
)
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 @
f3657783
...
@@ -110,7 +110,7 @@ def edit_string_for_tags(tags):
...
@@ -110,7 +110,7 @@ def edit_string_for_tags(tags):
names
=
[]
names
=
[]
for
tag
in
tags
:
for
tag
in
tags
:
name
=
tag
.
name
name
=
tag
.
name
if
u','
in
name
:
if
u','
in
name
or
u' '
in
name
:
names
.
append
(
'"
%
s"'
%
name
)
names
.
append
(
'"
%
s"'
%
name
)
else
:
else
:
names
.
append
(
name
)
names
.
append
(
name
)
...
...
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