From 8504619c755a163a276445c14de8ec4239e8811a Mon Sep 17 00:00:00 2001 From: Edward Ribeiro Date: Tue, 19 Apr 2016 13:38:02 -0300 Subject: [PATCH] =?UTF-8?q?Imprime=20datas=20em=20CRUD=20autom=C3=A1tico?= =?UTF-8?q?=20de=20acordo=20com=20formato=20em=20settings.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crispy_layout_mixin.py | 5 +++-- protocoloadm/views.py | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/crispy_layout_mixin.py b/crispy_layout_mixin.py index 7971466ca..0d15ad76d 100644 --- a/crispy_layout_mixin.py +++ b/crispy_layout_mixin.py @@ -5,6 +5,7 @@ import rtyaml from crispy_forms.bootstrap import FormActions from crispy_forms.helper import FormHelper from crispy_forms.layout import HTML, Div, Fieldset, Layout, Submit +from django.utils import formats from django.utils.translation import ugettext as _ @@ -57,9 +58,9 @@ def get_field_display(obj, fieldname): if value is None: display = '' elif 'date' in str(type(value)): - display = value.strftime("%d/%m/%Y") # TODO: localize + display = formats.date_format(value, "SHORT_DATE_FORMAT") elif 'bool' in str(type(value)): - display = 'Sim' if value else 'Não' + display = _('Sim') if value else _('Não') else: display = str(value) return verbose_name, display diff --git a/protocoloadm/views.py b/protocoloadm/views.py index fa0056044..8757debd4 100644 --- a/protocoloadm/views.py +++ b/protocoloadm/views.py @@ -67,7 +67,7 @@ class ProtocoloPesquisaView(FormView): # kwargs['final'] = request.POST['final'] # if request.POST['natureza_processo']: - # kwargs['natureza_processo'] = request.POST['natureza_processo'] + # kwargs['natureza_processo'] = request.POST['natureza_processo'] if request.POST['tipo_documento']: kwargs['tipo_documento'] = request.POST['tipo_documento'] @@ -238,6 +238,7 @@ class ComprovanteProtocoloView(TemplateView): autenticacao = _("** NULO **") if not protocolo.anulado: + # data is not i18n sensitive 'Y-m-d' is the right format. autenticacao = str(protocolo.tipo_processo) + \ protocolo.data.strftime("%Y/%m/%d") + \ str(protocolo.numero).zfill(6)