diff --git a/protocoloadm/views.py b/protocoloadm/views.py index 8fe0a1fd3..9e20d93d7 100644 --- a/protocoloadm/views.py +++ b/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, diff --git a/sapl/utils.py b/sapl/utils.py index 8cf0f453e..1ede6eabf 100644 --- a/sapl/utils.py +++ b/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