remove requirement that primary hero featured image should be set (#12414)
This commit is contained in:
Родитель
66b807bf14
Коммит
9c40be32af
|
@ -44,7 +44,7 @@ small number of shelves this endpoint is not paginated.
|
|||
:>json object results[].gradient: The background colors used for the gradient.
|
||||
:>json string results[].gradient.start: The starting color name for gradient - typically top or left. The name is from the `photon color variables <https://github.com/FirefoxUX/photon-colors/blob/master/photon-colors.scss>`_.
|
||||
:>json string results[].gradient.end: The ending color name for gradient - typically bottom or right. The name is from the `photon color variables <https://github.com/FirefoxUX/photon-colors/blob/master/photon-colors.scss>`_.
|
||||
:>json string results[].featured_image: The image used to illustrate the item.
|
||||
:>json string|null results[].featured_image: The image used to illustrate the item, if set.
|
||||
:>json string|null results[].description: The description for this item, if any.
|
||||
:>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``.
|
||||
|
|
|
@ -120,9 +120,6 @@ class PrimaryHero(ModelBase):
|
|||
if not self.gradient_color:
|
||||
error_dict['gradient_color'] = ValidationError(
|
||||
'Gradient color is required for enabled shelves')
|
||||
if not self.image:
|
||||
error_dict['image'] = ValidationError(
|
||||
'A featured image is required for enabled shelves')
|
||||
|
||||
if self.is_external and not self.disco_addon.addon.homepage:
|
||||
error_dict['is_external'] = ValidationError(
|
||||
|
|
|
@ -51,6 +51,7 @@ class TestPrimaryHero(TestCase):
|
|||
ph.clean() # it raises if there's an error
|
||||
|
||||
def test_clean_gradient_and_image(self):
|
||||
# Currently, gradient is required and image isn't.
|
||||
ph = PrimaryHero.objects.create(
|
||||
disco_addon=DiscoveryItem.objects.create(addon=addon_factory()))
|
||||
ph.disco_addon.update(recommendable=True)
|
||||
|
@ -62,7 +63,7 @@ class TestPrimaryHero(TestCase):
|
|||
with self.assertRaises(ValidationError) as ve:
|
||||
ph.clean()
|
||||
assert 'gradient_color' in ve.exception.error_dict
|
||||
assert 'image' in ve.exception.error_dict
|
||||
assert 'image' not in ve.exception.error_dict
|
||||
|
||||
ph.update(image='foo.png')
|
||||
with self.assertRaises(ValidationError) as ve:
|
||||
|
@ -71,12 +72,6 @@ class TestPrimaryHero(TestCase):
|
|||
assert 'image' not in ve.exception.error_dict
|
||||
|
||||
ph.update(image='', gradient_color='#123456')
|
||||
with self.assertRaises(ValidationError) as ve:
|
||||
ph.clean()
|
||||
assert 'gradient_color' not in ve.exception.error_dict
|
||||
assert 'image' in ve.exception.error_dict
|
||||
|
||||
ph.update(image='baa.jpg')
|
||||
ph.clean() # it raises if there's an error
|
||||
|
||||
def test_clean_only_enabled(self):
|
||||
|
|
Загрузка…
Ссылка в новой задаче