Projet

Général

Profil

0002-dossiers-make-the-age-format-configurable-via-servic.patch

Frédéric Péters, 10 septembre 2014 22:32

Télécharger (1,52 ko)

Voir les différences:

Subject: [PATCH 2/2] dossiers: make the age format configurable via service
 settings

Closes #5469
 calebasse/dossiers/models.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
calebasse/dossiers/models.py
21 21
from calebasse.actes.models import Act
22 22

  
23 23
from ..middleware.request import get_request
24
from ..utils import get_service_setting
24 25

  
25 26
DEFAULT_ACT_NUMBER_DIAGNOSTIC = 6
26 27
DEFAULT_ACT_NUMBER_TREATMENT = 30
......
371 372
    def age(self):
372 373
        if not self.birthdate:
373 374
            return 'inconnu'
375
        age_format = get_service_setting('age_format')
374 376
        now = datetime.today().date()
375 377
        age = relativedelta(now, self.birthdate)
376
        if age.years < 2:
377
            # for children < 2 years, return the number of months
378
        # by default we return the number of months for children < 2 years, but
379
        # there's a service setting to have it always displayed that way.
380
        if age.years < 2 or age_format == 'months_only':
378 381
            months = age.years * 12 + age.months
379 382
            if months:
380 383
                return '%s mois' % months
381
-