drop unneeded heading from primary hero api detail (#12053)
This commit is contained in:
Родитель
db23dc6525
Коммит
8c7052b9ea
|
@ -44,7 +44,6 @@ small number of shelves this endpoint is not paginated.
|
|||
:>json string results[].gradient.start: The starting color for gradient - typically top or left.
|
||||
:>json string results[].gradient.end: The ending color for gradient - typically bottom or right.
|
||||
:>json string results[].featured_image: The image used to illustrate the item.
|
||||
:>json string results[].heading: The heading for this item. May contain some HTML tags.
|
||||
:>json string|null results[].description: The description for this item, if any. May contain some HTML tags.
|
||||
:>json object results[].addon: The :ref:`add-on <addon-detail-object>` for this item if the addon is hosted on AMO. Either this field or ``external`` will be present. Only a subset of fields are present: ``id``, ``authors``, ``average_daily_users``, ``current_version`` (with only the ``id``, ``compatibility``, ``is_strict_compatibility_enabled`` and ``files`` fields present), ``guid``, ``icon_url``, ``name``, ``ratings``, ``previews``, ``slug``, ``theme_data``, ``type`` and ``url``.
|
||||
:>json object results[].external: The :ref:`add-on <addon-detail-object>` for this item if the addon is externally hosted. Either this field or ``addon`` will be present. Only a subset of fields are present: ``id``, ``guid``, ``homepage``, ``name`` and ``type``.
|
||||
|
|
|
@ -17,14 +17,13 @@ class ExternalAddonSerializer(AddonSerializer):
|
|||
class PrimaryHeroShelfSerializer(serializers.ModelSerializer):
|
||||
description = serializers.CharField(source='disco_addon.description')
|
||||
featured_image = serializers.SerializerMethodField()
|
||||
heading = serializers.CharField(source='disco_addon.heading')
|
||||
addon = DiscoveryAddonSerializer(source='disco_addon.addon')
|
||||
external = ExternalAddonSerializer(source='disco_addon.addon')
|
||||
|
||||
class Meta:
|
||||
model = PrimaryHero
|
||||
fields = ('addon', 'description', 'external', 'featured_image',
|
||||
'gradient', 'heading')
|
||||
'gradient')
|
||||
|
||||
def to_representation(self, instance):
|
||||
rep = super().to_representation(instance)
|
||||
|
|
|
@ -11,18 +11,16 @@ from ..serializers import (
|
|||
|
||||
class TestPrimaryHeroShelfSerializer(TestCase):
|
||||
def test_basic(self):
|
||||
addon = addon_factory(summary='Summary')
|
||||
addon = addon_factory()
|
||||
hero = PrimaryHero.objects.create(
|
||||
disco_addon=DiscoveryItem.objects.create(
|
||||
addon=addon,
|
||||
custom_heading='Its a héading!'),
|
||||
addon=addon, custom_description='Déscription'),
|
||||
image='foo.png',
|
||||
gradient_color='#123456')
|
||||
data = PrimaryHeroShelfSerializer(instance=hero).data
|
||||
assert data == {
|
||||
'featured_image': hero.image_path,
|
||||
'heading': 'Its a héading!',
|
||||
'description': '<blockquote>Summary</blockquote>',
|
||||
'description': '<blockquote>Déscription</blockquote>',
|
||||
'gradient': {
|
||||
'start': GRADIENT_START_COLOR,
|
||||
'end': '#123456'
|
||||
|
@ -35,15 +33,12 @@ class TestPrimaryHeroShelfSerializer(TestCase):
|
|||
summary='Summary', homepage='https://foo.baa', version_kw={
|
||||
'channel': amo.RELEASE_CHANNEL_UNLISTED})
|
||||
hero = PrimaryHero.objects.create(
|
||||
disco_addon=DiscoveryItem.objects.create(
|
||||
addon=addon,
|
||||
custom_heading='Its a héading!'),
|
||||
disco_addon=DiscoveryItem.objects.create(addon=addon),
|
||||
image='foo.png',
|
||||
gradient_color='#123456',
|
||||
is_external=True)
|
||||
assert PrimaryHeroShelfSerializer(instance=hero).data == {
|
||||
'featured_image': hero.image_path,
|
||||
'heading': 'Its a héading!',
|
||||
'description': '<blockquote>Summary</blockquote>',
|
||||
'gradient': {
|
||||
'start': GRADIENT_START_COLOR,
|
||||
|
|
|
@ -19,12 +19,12 @@ class TestPrimaryHeroShelfViewSet(TestCase):
|
|||
hero_a = PrimaryHero.objects.create(
|
||||
disco_addon=DiscoveryItem.objects.create(
|
||||
addon=addon_factory(),
|
||||
custom_heading='Its a héading!'),
|
||||
custom_description='Its a déscription!'),
|
||||
image='foo.png',
|
||||
gradient_color='#123456')
|
||||
hero_b = PrimaryHero.objects.create(
|
||||
disco_addon=DiscoveryItem.objects.create(
|
||||
addon=addon_factory()),
|
||||
addon=addon_factory(summary='fooo')),
|
||||
image='baa.png',
|
||||
gradient_color='#987654')
|
||||
hero_external = PrimaryHero.objects.create(
|
||||
|
|
Загрузка…
Ссылка в новой задаче