+
+
+class UserPremiumField(serializers.ReadOnlyField):
+ def __init__(self, *args, **kwargs):
+ super(UserPremiumField, self).__init__(*args, source='*', **kwargs)
+
+ def to_representation(self, value):
+ return user_is_subscribed(value)
+
+
+class ThumbnailField(serializers.FileField):
+ def __init__(self, geometry, *args, **kwargs):
+ self.geometry = geometry
+ super(ThumbnailField, self).__init__(*args, **kwargs)
+
+ def to_representation(self, value):
+ if value:
+ return super(ThumbnailField, self).to_representation(
+ default.backend.get_thumbnail(value, self.geometry)
+ )