|
@@ -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'
|