fix float format in fees

sync_v2
Razmig Sarkissian 5 months ago
parent 0e7d746352
commit ba671c41f7
  1. 11
      tournaments/models/tournament.py
  2. 2
      tournaments/templates/register_tournament.html
  3. 4
      tournaments/templates/tournaments/tournament_info.html

@ -1108,14 +1108,18 @@ class Tournament(BaseModel):
return True return True
def options_fee(self): def options_fee(self):
def format_currency(amount):
"""Format currency amount, removing unnecessary decimals"""
return f"{amount:g}" if amount % 1 == 0 else f"{amount:.2f}"
options = [] options = []
# Entry fee # Entry fee
if self.entry_fee is not None and self.entry_fee > 0: if self.entry_fee is not None and self.entry_fee > 0:
options.append(f"Frais d'inscription: {self.entry_fee} € par joueur") options.append(f"Frais d'inscription: {format_currency(self.entry_fee)} € par joueur")
# Club member fee reduction # Club member fee reduction
if self.club_member_fee_deduction and self.club_member_fee_deduction > 0: if self.club_member_fee_deduction and self.club_member_fee_deduction > 0:
options.append(f"Réduction de {self.club_member_fee_deduction} € pour les membres du club") options.append(f"Réduction de {format_currency(self.club_member_fee_deduction)} € pour les membres du club")
return options return options
@ -1133,6 +1137,9 @@ class Tournament(BaseModel):
date = formats.date_format(self.registration_date_limit.astimezone(timezone), format='j F Y H:i') date = formats.date_format(self.registration_date_limit.astimezone(timezone), format='j F Y H:i')
options.append(f"Clôture des inscriptions le {date}") options.append(f"Clôture des inscriptions le {date}")
# Période de désinscription
options.append(f"Désinscription possible jusqu'à {self.unregister_delta_in_hours}h avant le tournoi")
options.append(self.get_selection_status_localized) options.append(self.get_selection_status_localized)
# Cible d'équipes # Cible d'équipes

@ -197,7 +197,7 @@
Confirmer votre inscription en payant immédiatement : Confirmer votre inscription en payant immédiatement :
</div> </div>
<button type="submit" name="proceed_to_payment" class="rounded-button"> <button type="submit" name="proceed_to_payment" class="rounded-button">
Procéder au paiement de {{ cart_data.team_fee_from_cart_players }}€ Procéder au paiement de {{ cart_data.team_fee_from_cart_players|floatformat:2 }}€
</button> </button>
{% endif %} {% endif %}
{% if tournament.should_request_payment is False or tournament.online_payment_is_mandatory is False or cart_data.waiting_list_position >= 0 %} {% if tournament.should_request_payment is False or tournament.online_payment_is_mandatory is False or cart_data.waiting_list_position >= 0 %}

@ -102,9 +102,9 @@
{% else %} {% else %}
<a href="{% url 'proceed_to_payment' tournament.id %}" class="rounded-button positive-button"> <a href="{% url 'proceed_to_payment' tournament.id %}" class="rounded-button positive-button">
{% if team.needs_confirmation %} {% if team.needs_confirmation %}
Confirmer en payant ({{ team.get_remaining_fee }}€) Confirmer en payant {{ team.get_remaining_fee|floatformat:2 }}€
{% else %} {% else %}
Procéder au paiement ({{ team.get_remaining_fee }}€) Procéder au paiement de {{ team.get_remaining_fee|floatformat:2 }}€
{% endif %} {% endif %}
</a> </a>
{% endif %} {% endif %}

Loading…
Cancel
Save