diff --git a/sapl/materia/views.py b/sapl/materia/views.py index 50f3a525d..69d96cbc8 100644 --- a/sapl/materia/views.py +++ b/sapl/materia/views.py @@ -826,8 +826,14 @@ class ReciboProposicaoView(TemplateView): # FIXME hash para textos articulados _hash = 'P' + ta.hash() + '/' + str(proposicao.id) + from sapl.utils import create_barcode + base64_data = create_barcode(_hash, 100, 2000) + barcode = 'data:image/png;base64,{0}'.format(base64_data) + + context.update({'proposicao': proposicao, - 'hash': _hash}) + 'hash': _hash, + 'barcode': barcode}) return context def get(self, request, *args, **kwargs): diff --git a/sapl/templates/materia/recibo_proposicao.html b/sapl/templates/materia/recibo_proposicao.html index a2ec81039..a839250f9 100644 --- a/sapl/templates/materia/recibo_proposicao.html +++ b/sapl/templates/materia/recibo_proposicao.html @@ -67,5 +67,6 @@


________________________________________________________________ {{proposicao.autor}} + {% endblock detail_content %} diff --git a/sapl/utils.py b/sapl/utils.py index 3ef2c05eb..1569cedca 100644 --- a/sapl/utils.py +++ b/sapl/utils.py @@ -230,7 +230,7 @@ def get_base_url(request): return "{0}://{1}".format(protocol, current_domain) -def create_barcode(value): +def create_barcode(value, width=170, height=50): ''' creates a base64 encoded barcode PNG image ''' @@ -239,8 +239,8 @@ def create_barcode(value): value_bytes = bytes(value, "ascii") barcode = createBarcodeDrawing('Code128', value=value_bytes, - barWidth=170, - height=50, + barWidth=width, + height=height, fontSize=2, humanReadable=True) data = b64encode(barcode.asString('png'))