def to_representation(self, obj): return { 'id': obj.pk, 'name': clean_html(obj.name), 'pubDate': obj.created_at.strftime("%d.%m.%y"), 'currency': currency_symbol(obj.currency), 'price': obj.cost, 'cover': obj.image.big if obj.image else '', 'details': clean_html(obj.description) if obj.description else '' }
def to_representation(self, obj): return { 'id': obj.pk, 'name': clean_html(obj.name), 'endDate': obj.end_coupon_date.strftime("%d.%m.%y"), 'currency': currency_symbol(obj.currency), 'oldPrice': obj.cost, 'cover': obj.image.big if obj.image else '', 'details': clean_html(obj.description) if obj.description else '', 'percent': obj.coupon_discount_percent }
def to_representation(self, obj): if obj.short_description: short_text = obj.short_description else: short_text = Truncator(obj.description).words("30", html=True) return { 'id': obj.pk, 'name': clean_html(obj.name), 'pubDate': obj.created_at.strftime("%d.%m.%y"), 'currency': currency_symbol(obj.currency), 'price': obj.cost, 'cover': obj.image.big if obj.image else '', 'details': clean_html(short_text) if short_text else '' }
def to_representation(self, obj): if obj.short_description: short_text = obj.short_description else: short_text = Truncator(obj.description).words("30", html=True) return { 'id': obj.pk, 'name': clean_html(obj.name), 'endDate': obj.end_coupon_date.strftime("%d.%m.%y"), 'currency': currency_symbol(obj.currency), 'oldPrice': obj.cost, 'cover': obj.image.big if obj.image else '', 'details': clean_html(short_text) if short_text else '', 'percent': obj.coupon_discount_percent }
def getSymbol(value): return currency_symbol(value)
def get_currency(self, instance): return currency_symbol(instance.currency)