Browse Source

Refactor function name and add doc string

pull/203/head
Edward Ribeiro 9 years ago
parent
commit
a934462545
  1. 4
      protocoloadm/views.py
  2. 5
      sapl/utils.py

4
protocoloadm/views.py

@ -17,7 +17,7 @@ from vanilla import GenericView
import sapl
from materia.models import Proposicao, TipoMateriaLegislativa
from sapl.crud import build_crud
from sapl.utils import create_barcode_128_as_base64_png
from sapl.utils import create_barcode
from .forms import (AnularProcoloAdmForm, DocumentoAcessorioAdministrativoForm,
ProposicaoSimpleForm, ProtocoloDocumentForm, ProtocoloForm,
@ -324,7 +324,7 @@ class ComprovanteProtocoloView(TemplateView):
protocolo = Protocolo.objects.get(ano=ano, numero=numero)
# numero is string, padd with zeros left via .zfill()
base64_data = create_barcode_128_as_base64_png(numero.zfill(6))
base64_data = create_barcode(numero.zfill(6))
barcode = 'data:image/png;base64,{0}'.format(base64_data)
return self.render_to_response({"protocolo": protocolo,

5
sapl/utils.py

@ -32,7 +32,10 @@ def xstr(s):
return '' if s is None else str(s)
def create_barcode_128_as_base64_png(value):
def create_barcode(value):
'''
creates a base64 encoded barcode PNG image
'''
from base64 import b64encode
from reportlab.graphics.barcode import createBarcodeDrawing

Loading…
Cancel
Save