Commit 02e2001b authored by Baptiste Jonglez's avatar Baptiste Jonglez
Browse files

Improve display of offer price

parent 41baa7cc
......@@ -49,11 +49,25 @@ class Offer(models.Model):
return self.configuration_type
get_configuration_type_display.short_description = 'type de configuration'
def display_price(self):
"""Displays the price of an offer in a human-readable manner
(for instance "30€ / month")
"""
if int(self.period_fees) == self.period_fees:
fee = int(self.period_fees)
else:
fee = self.period_fees
if self.billing_period == 1:
period = ""
else:
period = self.billing_period
return "{period_fee}€ / {billing_period} mois".format(
period_fee=fee,
billing_period=period)
def __unicode__(self):
return '{name} - {period_fee}€ / {billing_period}m'.format(
name=self.name,
period_fee=self.period_fees,
billing_period=self.billing_period)
return '{name} - {price}'.format(name=self.name,
price=self.display_price())
class Meta:
verbose_name = 'offre'
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment