Beispiel #1
0
 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 ''
     }
Beispiel #2
0
 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
     }
Beispiel #3
0
    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 ''
        }
Beispiel #4
0
    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
        }
Beispiel #5
0
def getSymbol(value):
    return currency_symbol(value)
Beispiel #6
0
 def get_currency(self, instance):
     return currency_symbol(instance.currency)