Commit 17abbc2c authored by cynddl's avatar cynddl

Add a created_by field for Article + add missing voting fields in API results

parent c90d4d2b
Pipeline #1047 passed with stage
in 25 seconds
......@@ -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')
# -*- 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),
),
]
......@@ -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)
......
......@@ -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())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment