diff --git a/sapl/materia/forms.py b/sapl/materia/forms.py
index c46a6eb81..02b7e3c19 100644
--- a/sapl/materia/forms.py
+++ b/sapl/materia/forms.py
@@ -72,13 +72,13 @@ class MateriaSimplificadaForm(ModelForm):
class Meta:
model = MateriaLegislativa
fields = ['tipo', 'numero', 'ano', 'data_apresentacao',
- 'numero_origem_externa', 'regime_tramitacao',
+ 'numero_protocolo', 'regime_tramitacao',
'em_tramitacao', 'ementa', 'texto_original']
def __init__(self, *args, **kwargs):
row1 = to_row([('tipo', 6), ('numero', 3), ('ano', 3)])
- row2 = to_row([('data_apresentacao', 6), ('numero_origem_externa', 6)])
+ row2 = to_row([('data_apresentacao', 6), ('numero_protocolo', 6)])
row3 = to_row([('regime_tramitacao', 6), ('em_tramitacao', 6)])
row4 = to_row([('ementa', 12)])
row5 = to_row([('texto_original', 12)])
diff --git a/sapl/materia/views.py b/sapl/materia/views.py
index 48fdce626..1c102e1fe 100644
--- a/sapl/materia/views.py
+++ b/sapl/materia/views.py
@@ -1,7 +1,6 @@
from datetime import datetime
from random import choice
from string import ascii_letters, digits
-
from crispy_forms.helper import FormHelper
from crispy_forms.layout import HTML
from django.contrib import messages
@@ -87,8 +86,7 @@ class CriarProtocoloMateriaView(CreateView):
context['form'].fields['numero'].initial = protocolo.numero
context['form'].fields['ano'].initial = protocolo.ano
context['form'].fields['data_apresentacao'].initial = protocolo.data
- context['form'].fields[
- 'numero_origem_externa'].initial = protocolo.numero
+ context['form'].fields['numero_protocolo'].initial = protocolo.numero
context['form'].fields['ementa'].initial = protocolo.observacao
return context
diff --git a/sapl/protocoloadm/forms.py b/sapl/protocoloadm/forms.py
index b439ffb88..a75c4072b 100644
--- a/sapl/protocoloadm/forms.py
+++ b/sapl/protocoloadm/forms.py
@@ -553,6 +553,10 @@ class DocumentoAdministrativoForm(ModelForm):
'texto_integral',
]
+ def save(self, commit=True):
+ documento = super(DocumentoAdministrativoForm, self).save(commit)
+ return documento
+
def __init__(self, *args, **kwargs):
row1 = to_row(
diff --git a/sapl/protocoloadm/views.py b/sapl/protocoloadm/views.py
index dd478b93a..447f96a9f 100644
--- a/sapl/protocoloadm/views.py
+++ b/sapl/protocoloadm/views.py
@@ -3,6 +3,7 @@ from datetime import date, datetime
from braces.views import FormValidMessageMixin
from django.contrib import messages
from django.contrib.auth.mixins import PermissionRequiredMixin
+from django.core.exceptions import ObjectDoesNotExist
from django.core.urlresolvers import reverse
from django.db.models import Max
from django.http import HttpResponseRedirect
@@ -14,7 +15,7 @@ from django_filters.views import FilterView
import sapl
from sapl.crud.base import Crud, CrudAux, MasterDetailCrud, make_pagination
-from sapl.materia.models import TipoMateriaLegislativa
+from sapl.materia.models import MateriaLegislativa, TipoMateriaLegislativa
from sapl.utils import create_barcode, get_client_ip
from .forms import (AnularProcoloAdmForm, DocumentoAcessorioAdministrativoForm,
@@ -274,6 +275,24 @@ class ProtocoloMostrarView(PermissionRequiredMixin, TemplateView):
def get_context_data(self, **kwargs):
context = super(ProtocoloMostrarView, self).get_context_data(**kwargs)
protocolo = Protocolo.objects.get(pk=self.kwargs['pk'])
+
+ if protocolo.tipo_materia:
+ try:
+ materia = MateriaLegislativa.objects.get(
+ numero_protocolo=protocolo.numero, ano=protocolo.ano)
+ except ObjectDoesNotExist:
+ context['materia'] = None
+ else:
+ context['materia'] = materia
+ elif protocolo.tipo_documento:
+ try:
+ documento = DocumentoAdministrativo.objects.get(
+ numero_protocolo=protocolo.numero, ano=protocolo.ano)
+ except ObjectDoesNotExist:
+ context['documento'] = None
+ else:
+ context['documento'] = documento
+
context['protocolo'] = protocolo
return context
diff --git a/sapl/templates/protocoloadm/protocolo_mostrar.html b/sapl/templates/protocoloadm/protocolo_mostrar.html
index fcae89de4..df35a92e6 100644
--- a/sapl/templates/protocoloadm/protocolo_mostrar.html
+++ b/sapl/templates/protocoloadm/protocolo_mostrar.html
@@ -15,14 +15,27 @@
- Documento Vinculado:
+ Documento Vinculado:
{% if protocolo.tipo_documento %}
- Criar Documento
+ {% if documento %}
+ {{documento}}
+
+ {% else %}
+
+ Criar Documento
+ {% endif %}
{% elif protocolo.tipo_materia %}
- Criar Matéria
+ {% if materia %}
+ {{materia}}
+
+ {% else %}
+
+ Criar Matéria
+ {% endif %}
{% endif %}
+
Comprovante