Browse Source

Imprime datas em CRUD automático de acordo com formato em settings.py

pull/336/head
Edward Ribeiro 9 years ago
parent
commit
8504619c75
  1. 5
      crispy_layout_mixin.py
  2. 1
      protocoloadm/views.py

5
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

1
protocoloadm/views.py

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

Loading…
Cancel
Save