Exemple #1
0
 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
     }
Exemple #2
0
 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
     }
Exemple #3
0
 def __unicode__(self):
     return locale_to_native(self.locale)
Exemple #4
0
 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)
Exemple #5
0
 def test_basic(self):
     with patch('affiliates.base.utils.LOCALE_TO_NATIVE', {'en-us': 'English'}):
         eq_(locale_to_native('en-us'), 'English')
Exemple #6
0
 def __unicode__(self):
     return locale_to_native(self.locale)