Skip to content
This repository has been archived by the owner on Feb 13, 2019. It is now read-only.

Add Facebook image and description #258

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions bulbs/content/migrations/0013_auto_20160725_1042.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models
import djbetty.fields


class Migration(migrations.Migration):

dependencies = [
('content', '0012_auto_20160615_1605'),
]

operations = [
migrations.AddField(
model_name='content',
name='facebook_description',
field=models.TextField(default=b'', max_length=1024, blank=True),
),
migrations.AddField(
model_name='content',
name='facebook_image',
field=djbetty.fields.ImageField(default=None, null=True, blank=True),
),
]
3 changes: 3 additions & 0 deletions bulbs/content/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ class Content(PolymorphicModel, Indexable):
template_choice = models.IntegerField(default=0, choices=TEMPLATE_CHOICES)
# Facebook Instant Article ID
instant_article_id = models.BigIntegerField(blank=True, null=True, default=None)
facebook_description = models.TextField(max_length=1024, blank=True, default="")
facebook_image = ImageField(null=True, blank=True)

# custom ES manager
search_objects = ContentManager()
Expand All @@ -238,6 +240,7 @@ class Mapping:
slug = field.String(index="not_analyzed")
status = field.String(index="not_analyzed")
thumbnail_override = ElasticsearchImageField()
facebook_image = ElasticsearchImageField()

def __unicode__(self):
"""unicode friendly name
Expand Down
1 change: 1 addition & 0 deletions bulbs/content/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ class ContentSerializer(serializers.ModelSerializer):
thumbnail = ImageFieldSerializer(allow_null=True, read_only=True)
first_image = ImageFieldSerializer(allow_null=True, read_only=True)
thumbnail_override = ImageFieldSerializer(allow_null=True, required=False)
facebook_image = ImageFieldSerializer(allow_null=True, required=False)
absolute_url = serializers.ReadOnlyField(source="get_absolute_url")
status = serializers.ReadOnlyField(source="get_status")
template_type = serializers.SlugRelatedField(
Expand Down
4 changes: 4 additions & 0 deletions bulbs/super_features/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ class BaseSuperFeatureSerializer(ContentSerializer):
class Meta:
model = BaseSuperFeature

def to_representation(self, obj):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just adding this for documentation purposes, since this serializer isn't being used

self.superfeature_type = getattr(obj, 'superfeature_type')
return super(BaseSuperFeatureSerializer, self).to_representation(obj)


class BaseSuperFeaturePartialSerializer(ContentSerializer):

Expand Down
2 changes: 2 additions & 0 deletions tests/api/test_content_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ def test_create_article(self):
"description": "Testing out things with an article.",
"foo": "Fighters",
"feature_type": "Some Super Long String Probably",
"facebook_description": "this is the facebook description",
"facebook_image": {"id": 1},
"authors": [{
"id": author.id,
"username": author.username,
Expand Down