Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
rp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
14
Issues
14
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
La Quadrature du Net
rpteam
rp
Commits
21f61095
Commit
21f61095
authored
Apr 28, 2017
by
cynddl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Force lowercase for language option in newspaper
parent
de6e90a8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
2 deletions
+10
-2
apps/rp/models/article.py
apps/rp/models/article.py
+10
-2
No files found.
apps/rp/models/article.py
View file @
21f61095
...
...
@@ -14,6 +14,12 @@ STATUS_CHOICES = (
(
"REJECTED"
,
_
(
"Rejected"
))
)
LANG_CHOICES
=
(
(
"FR"
,
_
(
"French"
)),
(
"EN"
,
_
(
"English"
)),
(
"NA"
,
_
(
"Other"
))
)
URL_HELP_TEXT
=
"""The URL should not contain any marketing tags. We
automatically strip the most known tags."""
...
...
@@ -27,7 +33,8 @@ article content. You should aim at around 500 characters. Use bracket ellipsis
class
Article
(
VoteMixin
):
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
(
_
(
"Opengraph metadata"
),
blank
=
True
,
null
=
True
)
screenshot
=
models
.
ImageField
(
...
...
@@ -72,7 +79,8 @@ class Article(VoteMixin):
self
.
save
()
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
.
parse
()
self
.
title
=
article
.
title
...
...
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