Skip to content
GitLab
Menu
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
21f61095
Commit
21f61095
authored
Apr 28, 2017
by
cynddl
Browse files
Force lowercase for language option in newspaper
parent
de6e90a8
Changes
1
Hide whitespace changes
Inline
Side-by-side
apps/rp/models/article.py
View file @
21f61095
...
@@ -14,6 +14,12 @@ STATUS_CHOICES = (
...
@@ -14,6 +14,12 @@ STATUS_CHOICES = (
(
"REJECTED"
,
_
(
"Rejected"
))
(
"REJECTED"
,
_
(
"Rejected"
))
)
)
LANG_CHOICES
=
(
(
"FR"
,
_
(
"French"
)),
(
"EN"
,
_
(
"English"
)),
(
"NA"
,
_
(
"Other"
))
)
URL_HELP_TEXT
=
"""The URL should not contain any marketing tags. We
URL_HELP_TEXT
=
"""The URL should not contain any marketing tags. We
automatically strip the most known tags."""
automatically strip the most known tags."""
...
@@ -27,7 +33,8 @@ article content. You should aim at around 500 characters. Use bracket ellipsis
...
@@ -27,7 +33,8 @@ article content. You should aim at around 500 characters. Use bracket ellipsis
class
Article
(
VoteMixin
):
class
Article
(
VoteMixin
):
url
=
models
.
URLField
(
"URL"
,
help_text
=
URL_HELP_TEXT
)
url
=
models
.
URLField
(
"URL"
,
help_text
=
URL_HELP_TEXT
)
lang
=
models
.
CharField
(
_
(
"Language"
),
max_length
=
50
,
null
=
True
)
lang
=
models
.
CharField
(
_
(
"Language"
),
choices
=
LANG_CHOICES
,
default
=
"NA"
,
max_length
=
50
)
metadata
=
models
.
TextField
(
metadata
=
models
.
TextField
(
_
(
"Opengraph metadata"
),
blank
=
True
,
null
=
True
)
_
(
"Opengraph metadata"
),
blank
=
True
,
null
=
True
)
screenshot
=
models
.
ImageField
(
screenshot
=
models
.
ImageField
(
...
@@ -72,7 +79,8 @@ class Article(VoteMixin):
...
@@ -72,7 +79,8 @@ class Article(VoteMixin):
self
.
save
()
self
.
save
()
def
parse
(
self
):
def
parse
(
self
):
article
=
ArticleParser
(
url
=
self
.
url
,
language
=
self
.
lang
)
lang_lower
=
self
.
lang
.
lower
()
if
self
.
lang
!=
"NA"
else
None
article
=
ArticleParser
(
url
=
self
.
url
,
language
=
lang_lower
)
article
.
download
()
article
.
download
()
article
.
parse
()
article
.
parse
()
self
.
title
=
article
.
title
self
.
title
=
article
.
title
...
...
Write
Preview
Supports
Markdown
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