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
76c8a84f
authored
Sep 26, 2009
by
Alex Gaynor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more tests, added a remove method to taggable manager
parent
dba4d502
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
0 deletions
+16
-0
taggit/managers.py
+8
-0
taggit/tests/tests.py
+8
-0
No files found.
taggit/managers.py
View file @
76c8a84f
...
@@ -40,6 +40,14 @@ class _TaggableManager(models.Manager):
...
@@ -40,6 +40,14 @@ class _TaggableManager(models.Manager):
self
.
add
(
tags
)
self
.
add
(
tags
)
@require_instance_manager
@require_instance_manager
def
remove
(
self
,
tags
):
if
isinstance
(
tags
,
basestring
):
tags
=
[
tags
]
TaggedItem
.
objects
.
filter
(
object_id
=
self
.
object_id
,
content_type
=
ContentType
.
objects
.
get_for_model
(
self
.
model
))
.
filter
(
tag__name__in
=
tags
)
.
delete
()
@require_instance_manager
def
clear
(
self
):
def
clear
(
self
):
TaggedItem
.
objects
.
filter
(
object_id
=
self
.
object_id
,
TaggedItem
.
objects
.
filter
(
object_id
=
self
.
object_id
,
content_type
=
ContentType
.
objects
.
get_for_model
(
self
.
model
))
.
delete
()
content_type
=
ContentType
.
objects
.
get_for_model
(
self
.
model
))
.
delete
()
taggit/tests/tests.py
View file @
76c8a84f
...
@@ -22,3 +22,11 @@ class AddTagTestCase(BaseTaggingTest):
...
@@ -22,3 +22,11 @@ class AddTagTestCase(BaseTaggingTest):
pair
.
tags
.
add
(
'green'
)
pair
.
tags
.
add
(
'green'
)
self
.
assert_tags_equal
(
pair
.
tags
.
all
(),
[
'green'
])
self
.
assert_tags_equal
(
pair
.
tags
.
all
(),
[
'green'
])
self
.
assert_tags_equal
(
Food
.
tags
.
all
(),
[
'green'
])
self
.
assert_tags_equal
(
Food
.
tags
.
all
(),
[
'green'
])
apple
.
tags
.
add
(
'red'
)
self
.
assert_tags_equal
(
apple
.
tags
.
all
(),
[
'green'
,
'red'
])
self
.
assert_tags_equal
(
Food
.
tags
.
all
(),
[
'green'
,
'red'
])
apple
.
tags
.
remove
(
'green'
)
self
.
assert_tags_equal
(
apple
.
tags
.
all
(),
[
'red'
])
self
.
assert_tags_equal
(
Food
.
tags
.
all
(),
[
'green'
,
'red'
])
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