def variation_json_dict(self, variation): """ Convert a variation to a dict suitable for turning into JSON used by the customization frontend. """ # Useful for subclasses that need extra info. return { 'locale': locale_to_native(variation.locale), 'color': variation.color, 'size': variation.size, # <- Why we can't use serialize. 'image': variation.image.url }
def __unicode__(self): return locale_to_native(self.locale)
def test_invalid_locale(self): """If the given locale isn't in product_details, return None.""" with patch('affiliates.base.utils.LOCALE_TO_NATIVE', {'en-us': 'English'}): eq_(locale_to_native('fr'), None)
def test_basic(self): with patch('affiliates.base.utils.LOCALE_TO_NATIVE', {'en-us': 'English'}): eq_(locale_to_native('en-us'), 'English')