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
17abbc2c
Commit
17abbc2c
authored
May 18, 2017
by
cynddl
Browse files
Add a created_by field for Article + add missing voting fields in API results
parent
c90d4d2b
Pipeline
#1047
passed with stage
in 25 seconds
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
apps/rp/api/serializers.py
View file @
17abbc2c
...
...
@@ -6,4 +6,4 @@ from rp.models import Article
class
ArticleSerializer
(
serializers
.
ModelSerializer
):
class
Meta
:
model
=
Article
fields
=
(
'id'
,
'url'
,
'title'
)
fields
=
(
'id'
,
'url'
,
'title'
,
'und_score_up'
,
'und_score_down'
)
apps/rp/migrations/0015_article_created_by.py
0 → 100644
View file @
17abbc2c
# -*- coding: utf-8 -*-
# Generated by Django 1.11.1 on 2017-05-18 12:05
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'rp'
,
'0014_auto_20170501_1611'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'article'
,
name
=
'created_by'
,
field
=
models
.
CharField
(
max_length
=
255
,
null
=
True
),
),
]
apps/rp/models.py
View file @
17abbc2c
...
...
@@ -60,6 +60,7 @@ class Article(VoteMixin):
help_text
=
EXTRACTS_HELP_TEXT
)
created_at
=
models
.
DateTimeField
(
_
(
"Creation date"
),
auto_now_add
=
True
)
created_by
=
models
.
CharField
(
max_length
=
255
,
null
=
True
)
updated_at
=
models
.
DateTimeField
(
_
(
"Last update"
),
auto_now
=
True
)
published_at
=
models
.
DateTimeField
(
_
(
"Publication date"
),
blank
=
True
,
null
=
True
)
...
...
@@ -130,7 +131,7 @@ class Article(VoteMixin):
article
,
_
=
Article
.
objects
.
get_or_create
(
url
=
url
)
if
article
.
created_by
is
None
:
article
.
created_by
=
by
article
.
created_by
=
str
(
by
)
if
by
is
not
None
:
article
.
upvote
(
by
)
...
...
apps/rp/views/articles.py
View file @
17abbc2c
...
...
@@ -65,6 +65,7 @@ class ArticleEdit(PermissionRequiredMixin, UpdateView):
self
.
success_url
=
reverse
(
"rp:article-view"
,
args
=
[
self
.
object
.
id
])
elif
"publish"
in
self
.
request
.
POST
:
self
.
object
.
publish
()
self
.
object
.
save
()
return
HttpResponseRedirect
(
self
.
get_success_url
())
...
...
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