Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
La Quadrature du Net
rpteam
Revue de Press
Commits
e6c3d1e9
Commit
e6c3d1e9
authored
Apr 28, 2017
by
cynddl
Browse files
Fix tags: allow empty 'tags' field & save new tags
parent
21f61095
Changes
4
Hide whitespace changes
Inline
Side-by-side
apps/rp/forms.py
View file @
e6c3d1e9
...
...
@@ -9,3 +9,9 @@ class TagMultipleChoiceField(forms.ModelMultipleChoiceField):
return
[
self
.
prepare_value
(
v
)
for
v
in
value
]
else
:
return
super
(
TagMultipleChoiceField
,
self
).
prepare_value
(
value
)
def
clean
(
self
,
value
):
value
=
self
.
to_python
(
value
)
self
.
validate
(
value
)
self
.
run_validators
(
value
)
return
value
apps/rp/migrations/0013_auto_20170428_1341.py
0 → 100644
View file @
e6c3d1e9
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-04-28 13:41
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
import
taggit.managers
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'rp'
,
'0012_auto_20170427_1439'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'article'
,
name
=
'lang'
,
field
=
models
.
CharField
(
choices
=
[(
'FR'
,
'French'
),
(
'EN'
,
'English'
),
(
'NA'
,
'Other'
)],
default
=
'NA'
,
max_length
=
50
,
verbose_name
=
'Language'
),
),
migrations
.
AlterField
(
model_name
=
'article'
,
name
=
'tags'
,
field
=
taggit
.
managers
.
TaggableManager
(
blank
=
True
,
help_text
=
'A comma-separated list of tags.'
,
through
=
'taggit.TaggedItem'
,
to
=
'taggit.Tag'
,
verbose_name
=
'Tags'
),
),
]
apps/rp/models/article.py
View file @
e6c3d1e9
...
...
@@ -57,7 +57,7 @@ class Article(VoteMixin):
#: priority: True if article have priority
priority
=
models
.
BooleanField
(
default
=
False
)
tags
=
TaggableManager
()
tags
=
TaggableManager
(
blank
=
True
)
class
Meta
:
verbose_name
=
_
(
"Article"
)
...
...
apps/rp/views/articles.py
View file @
e6c3d1e9
...
...
@@ -83,7 +83,7 @@ class ArticleEdit(UpdateView):
# Change the layout of the tags field
form
.
fields
[
"tags"
]
=
TagMultipleChoiceField
(
queryset
=
Tag
.
objects
.
all
())
queryset
=
Tag
.
objects
.
all
()
,
required
=
False
)
left_layout
=
Div
(
Div
(
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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