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
8b991346
authored
Dec 16, 2010
by
Alex Gaynor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for trunk, and start fixing them.
parent
1563a6b3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
2 deletions
+42
-2
taggit/managers.py
+5
-0
taggit/models.py
+14
-0
tox.ini
+23
-2
No files found.
taggit/managers.py
View file @
8b991346
...
@@ -130,6 +130,11 @@ class TaggableManager(RelatedField):
...
@@ -130,6 +130,11 @@ class TaggableManager(RelatedField):
return
[(
"
%
s__content_type"
%
prefix
,
cts
[
0
])]
return
[(
"
%
s__content_type"
%
prefix
,
cts
[
0
])]
return
[(
"
%
s__content_type__in"
%
prefix
,
cts
)]
return
[(
"
%
s__content_type__in"
%
prefix
,
cts
)]
def
bulk_related_objects
(
self
,
new_objs
,
using
):
return
self
.
through
.
_base_manager
.
db_manager
(
using
)
.
filter
(
**
self
.
through
.
bulk_lookup_kwargs
(
new_objs
)
)
class
_TaggableManager
(
models
.
Manager
):
class
_TaggableManager
(
models
.
Manager
):
def
__init__
(
self
,
through
,
model
,
instance
):
def
__init__
(
self
,
through
,
model
,
instance
):
...
...
taggit/models.py
View file @
8b991346
...
@@ -82,6 +82,12 @@ class ItemBase(models.Model):
...
@@ -82,6 +82,12 @@ class ItemBase(models.Model):
'content_object'
:
instance
'content_object'
:
instance
}
}
@classmethod
def
bulk_lookup_kwargs
(
cls
,
instances
):
return
{
"content_object__in"
:
instances
,
}
class
TaggedItemBase
(
ItemBase
):
class
TaggedItemBase
(
ItemBase
):
if
django
.
VERSION
<
(
1
,
2
):
if
django
.
VERSION
<
(
1
,
2
):
...
@@ -130,6 +136,14 @@ class GenericTaggedItemBase(ItemBase):
...
@@ -130,6 +136,14 @@ class GenericTaggedItemBase(ItemBase):
}
}
@classmethod
@classmethod
def
bulk_lookup_kwargs
(
cls
,
instances
):
# TODO: instances[0], can we assume there are instances.
return
{
"object_id__in"
:
[
instance
.
pk
for
instance
in
instances
],
"content_type"
:
ContentType
.
objects
.
get_for_model
(
instances
[
0
]),
}
@classmethod
def
tags_for
(
cls
,
model
,
instance
=
None
):
def
tags_for
(
cls
,
model
,
instance
=
None
):
ct
=
ContentType
.
objects
.
get_for_model
(
model
)
ct
=
ContentType
.
objects
.
get_for_model
(
model
)
kwargs
=
{
kwargs
=
{
...
...
tox.ini
View file @
8b991346
[tox]
[tox]
envlist
=
py25,
py26,py27,pypy
envlist
=
py25,
py26 , py27, pypy, py25-trunk, py26-trunk, py27-trunk, pypy-trunk
[testenv]
[testenv]
commands
=
python setup.py test
commands
=
python setup.py test
deps
=
deps
=
django
django
=
=1.2.3
[testenv:py25-trunk]
basepython
=
python2.5
deps
=
http://www.djangoproject.com/download/1.3-alpha-1/tarball/
[testenv:py26-trunk]
basepython
=
python2.6
deps
=
http://www.djangoproject.com/download/1.3-alpha-1/tarball/
[testenv:py27-trunk]
basepython
=
python2.7
deps
=
http://www.djangoproject.com/download/1.3-alpha-1/tarball/
[testenv:pypy-trunk]
basepython
=
pypy
deps
=
http://www.djangoproject.com/download/1.3-alpha-1/tarball/
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