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
5c35d4f9
authored
Dec 08, 2009
by
Alex Gaynor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up the API.
parent
2311ed28
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
9 deletions
+5
-9
taggit/forms.py
+1
-1
taggit/managers.py
+4
-8
No files found.
taggit/forms.py
View file @
5c35d4f9
...
@@ -10,7 +10,7 @@ class TaggableForm(forms.ModelForm):
...
@@ -10,7 +10,7 @@ class TaggableForm(forms.ModelForm):
obj
=
super
(
TaggableForm
,
self
)
.
save
(
commit
=
False
)
obj
=
super
(
TaggableForm
,
self
)
.
save
(
commit
=
False
)
def
save_tags
():
def
save_tags
():
# TODO: Remove the assumption that the manager is named 'tags'
# TODO: Remove the assumption that the manager is named 'tags'
obj
.
tags
.
set
(
parse_tags
(
self
.
cleaned_data
[
'tags'
]))
obj
.
tags
.
set
(
*
parse_tags
(
self
.
cleaned_data
[
'tags'
]))
if
commit
:
if
commit
:
obj
.
save
()
obj
.
save
()
save_tags
()
save_tags
()
...
...
taggit/managers.py
View file @
5c35d4f9
...
@@ -26,23 +26,19 @@ class _TaggableManager(models.Manager):
...
@@ -26,23 +26,19 @@ class _TaggableManager(models.Manager):
return
Tag
.
objects
.
filter
(
items__content_type
=
ct
)
.
distinct
()
return
Tag
.
objects
.
filter
(
items__content_type
=
ct
)
.
distinct
()
@require_instance_manager
@require_instance_manager
def
add
(
self
,
tags
):
def
add
(
self
,
*
tags
):
if
isinstance
(
tags
,
basestring
):
tags
=
[
tags
]
for
tag
in
tags
:
for
tag
in
tags
:
tag
,
_
=
Tag
.
objects
.
get_or_create
(
name
=
tag
)
tag
,
_
=
Tag
.
objects
.
get_or_create
(
name
=
tag
)
TaggedItem
.
objects
.
create
(
object_id
=
self
.
object_id
,
TaggedItem
.
objects
.
create
(
object_id
=
self
.
object_id
,
content_type
=
ContentType
.
objects
.
get_for_model
(
self
.
model
),
tag
=
tag
)
content_type
=
ContentType
.
objects
.
get_for_model
(
self
.
model
),
tag
=
tag
)
@require_instance_manager
@require_instance_manager
def
set
(
self
,
tags
):
def
set
(
self
,
*
tags
):
self
.
clear
()
self
.
clear
()
self
.
add
(
tags
)
self
.
add
(
*
tags
)
@require_instance_manager
@require_instance_manager
def
remove
(
self
,
tags
):
def
remove
(
self
,
*
tags
):
if
isinstance
(
tags
,
basestring
):
tags
=
[
tags
]
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
))
.
filter
(
content_type
=
ContentType
.
objects
.
get_for_model
(
self
.
model
))
.
filter
(
tag__name__in
=
tags
)
.
delete
()
tag__name__in
=
tags
)
.
delete
()
...
...
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