Projet

Général

Profil

« Précédent | Suivant » 

Révision f82ab4b8

Ajouté par Frédéric Péters il y a plus de 9 ans

convert invoice values to proper datatypes (#6433)

This removes the need to call portail_citoyen2 templatetags to do the
conversion at template rendering time.

Voir les différences:

facturier/models.py
1
from datetime import datetime
2
from decimal import Decimal
3

  
1 4
from django.db import models
2 5
from django.core.urlresolvers import reverse
3 6
from django.utils.translation import ugettext_lazy as _, pgettext_lazy
......
99 102
                        invoice['download_url'] = reverse('invoice-download',
100 103
                            args=(self.slug, invoice_id, invoice_hash))
101 104
                        break
105
            # convert values to proper datatypes
106
            for amount_key in ('paid_amount', 'total_amount', 'amount'):
107
                if invoice.get(amount_key):
108
                    invoice[amount_key] = Decimal(invoice[amount_key])
109
            for date_key in ('creation_date', 'expiration_date', 'paid_date',
110
                    'tipi_paid_date'):
111
                if invoice.get(date_key):
112
                    invoice[date_key] = datetime.strptime(invoice[date_key], '%Y-%m-%d')
102 113
        return invoice
103 114

  
104 115

  

Formats disponibles : Unified diff