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
010c6995
authored
May 20, 2010
by
Carl Meyer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow query traversal from TaggedItem (or TaggedItemBase subclass) to content model; fixes #22
parent
c5cbe2e1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
3 deletions
+14
-3
taggit/managers.py
+1
-1
taggit/tests/tests.py
+13
-2
No files found.
taggit/managers.py
View file @
010c6995
...
@@ -97,7 +97,7 @@ class TaggableManager(object):
...
@@ -97,7 +97,7 @@ class TaggableManager(object):
return
self
.
through
.
objects
.
none
()
return
self
.
through
.
objects
.
none
()
def
related_query_name
(
self
):
def
related_query_name
(
self
):
return
None
return
self
.
model
.
_meta
.
object_name
.
lower
()
def
m2m_reverse_name
(
self
):
def
m2m_reverse_name
(
self
):
if
self
.
use_gfk
:
if
self
.
use_gfk
:
...
...
taggit/tests/tests.py
View file @
010c6995
...
@@ -3,9 +3,9 @@ from contextlib import contextmanager
...
@@ -3,9 +3,9 @@ from contextlib import contextmanager
from
django.test
import
TestCase
from
django.test
import
TestCase
from
taggit.models
import
Tag
from
taggit.models
import
Tag
,
TaggedItem
from
taggit.tests.forms
import
FoodForm
,
DirectFoodForm
from
taggit.tests.forms
import
FoodForm
,
DirectFoodForm
from
taggit.tests.models
import
Food
,
Pet
,
HousePet
,
DirectFood
,
DirectPet
,
DirectHousePet
from
taggit.tests.models
import
Food
,
Pet
,
HousePet
,
DirectFood
,
DirectPet
,
DirectHousePet
,
TaggedPet
class
BaseTaggingTest
(
TestCase
):
class
BaseTaggingTest
(
TestCase
):
...
@@ -31,6 +31,7 @@ class TaggableManagerTestCase(BaseTaggingTest):
...
@@ -31,6 +31,7 @@ class TaggableManagerTestCase(BaseTaggingTest):
food_model
=
Food
food_model
=
Food
pet_model
=
Pet
pet_model
=
Pet
housepet_model
=
HousePet
housepet_model
=
HousePet
taggeditem_model
=
TaggedItem
def
test_add_tag
(
self
):
def
test_add_tag
(
self
):
apple
=
self
.
food_model
.
objects
.
create
(
name
=
"apple"
)
apple
=
self
.
food_model
.
objects
.
create
(
name
=
"apple"
)
...
@@ -149,11 +150,21 @@ class TaggableManagerTestCase(BaseTaggingTest):
...
@@ -149,11 +150,21 @@ class TaggableManagerTestCase(BaseTaggingTest):
apple
.
tags
.
add
(
"juicy"
,
"juicy"
)
apple
.
tags
.
add
(
"juicy"
,
"juicy"
)
self
.
assert_tags_equal
(
apple
.
tags
.
all
(),
[
'juicy'
])
self
.
assert_tags_equal
(
apple
.
tags
.
all
(),
[
'juicy'
])
def
test_query_traverse
(
self
):
spot
=
self
.
pet_model
.
objects
.
create
(
name
=
'Spot'
)
spike
=
self
.
pet_model
.
objects
.
create
(
name
=
'Spike'
)
spot
.
tags
.
add
(
'scary'
)
spike
.
tags
.
add
(
'fluffy'
)
lookup_kwargs
=
{
'
%
s__name'
%
(
self
.
pet_model
.
_meta
.
object_name
.
lower
()):
'Spot'
}
self
.
assertEqual
([
unicode
(
i
.
tag
)
for
i
in
self
.
taggeditem_model
.
objects
.
filter
(
**
lookup_kwargs
)],
[
u'scary'
])
class
TaggableManagerDirectTestCase
(
TaggableManagerTestCase
):
class
TaggableManagerDirectTestCase
(
TaggableManagerTestCase
):
food_model
=
DirectFood
food_model
=
DirectFood
pet_model
=
DirectPet
pet_model
=
DirectPet
housepet_model
=
DirectHousePet
housepet_model
=
DirectHousePet
taggeditem_model
=
TaggedPet
class
TaggableFormTestCase
(
BaseTaggingTest
):
class
TaggableFormTestCase
(
BaseTaggingTest
):
...
...
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