diff --git a/sapl/compilacao/models.py b/sapl/compilacao/models.py
index 1531e6542..6752a82c1 100644
--- a/sapl/compilacao/models.py
+++ b/sapl/compilacao/models.py
@@ -210,7 +210,7 @@ class TextoArticulado(TimestampedMixin):
if request.user in self.owners.all():
return True
- if self.privacidade == STATUS_TA_RESTRICT and\
+ if self.privacidade == STATUS_TA_IMMUTABLE_RESTRICT and\
request.user.has_perm(
'compilacao.view_restricted_textoarticulado'):
return True
diff --git a/sapl/crispy_layout_mixin.py b/sapl/crispy_layout_mixin.py
index 34c9ecab4..028301502 100644
--- a/sapl/crispy_layout_mixin.py
+++ b/sapl/crispy_layout_mixin.py
@@ -1,12 +1,12 @@
from math import ceil
-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 import template
from django.utils import formats
from django.utils.translation import ugettext as _
+import rtyaml
def heads_and_tails(list_of_lists):
@@ -91,7 +91,8 @@ def get_field_display(obj, fieldname):
else:
display = ''
elif 'ManyRelatedManager' in str(type(value))\
- or 'RelatedManager' in str(type(value)):
+ or 'RelatedManager' in str(type(value))\
+ or 'GenericRelatedObjectManager' in str(type(value)):
display = '
'
for v in value.all():
display += '- %s
' % str(v)
diff --git a/sapl/crud/base.py b/sapl/crud/base.py
index a5c029655..cc84c7b4e 100644
--- a/sapl/crud/base.py
+++ b/sapl/crud/base.py
@@ -16,8 +16,8 @@ from django.http.response import Http404
from django.shortcuts import redirect
from django.utils.decorators import classonlymethod
from django.utils.encoding import force_text
-from django.utils.translation import ugettext_lazy as _
from django.utils.translation import string_concat
+from django.utils.translation import ugettext_lazy as _
from django.views.generic import (CreateView, DeleteView, DetailView, ListView,
UpdateView)
from django.views.generic.base import ContextMixin
@@ -29,6 +29,7 @@ from sapl.rules.map_rules import (RP_ADD, RP_CHANGE, RP_DELETE, RP_DETAIL,
from sapl.settings import BASE_DIR
from sapl.utils import normalize
+
logger = logging.getLogger(BASE_DIR.name)
ACTION_LIST, ACTION_CREATE, ACTION_DETAIL, ACTION_UPDATE, ACTION_DELETE = \
@@ -1401,10 +1402,6 @@ class CrudBaseForListAndDetailExternalAppView(MasterDetailCrud):
class BaseMixin(Crud.PublicMixin, MasterDetailCrud.BaseMixin):
- @classmethod
- def url_name(cls, suffix):
- return '%s_parlamentar_%s' % (cls.model._meta.model_name, suffix)
-
def resolve_url(self, suffix, args=None):
obj = self.crud if hasattr(self, 'crud') else self
diff --git a/sapl/parlamentares/views.py b/sapl/parlamentares/views.py
index 38228d920..b461cdbee 100644
--- a/sapl/parlamentares/views.py
+++ b/sapl/parlamentares/views.py
@@ -54,6 +54,12 @@ class RelatoriaParlamentarCrud(CrudBaseForListAndDetailExternalAppView):
help_path = 'relatoria_parlamentar'
namespace = AppConfig.name
+ class BaseMixin(CrudBaseForListAndDetailExternalAppView.BaseMixin):
+
+ @classmethod
+ def url_name(cls, suffix):
+ return '%s_parlamentar_%s' % (cls.model._meta.model_name, suffix)
+
class ProposicaoParlamentarCrud(CrudBaseForListAndDetailExternalAppView):
model = Proposicao
@@ -61,10 +67,31 @@ class ProposicaoParlamentarCrud(CrudBaseForListAndDetailExternalAppView):
parent_field = 'autor__parlamentar_set'
namespace = AppConfig.name
+ class BaseMixin(CrudBaseForListAndDetailExternalAppView.BaseMixin):
+
+ @classmethod
+ def url_name(cls, suffix):
+ return '%s_parlamentar_%s' % (cls.model._meta.model_name, suffix)
+
class ListView(CrudBaseForListAndDetailExternalAppView.ListView):
def get_queryset(self):
- return super().get_queryset().filter(data_envio__isnull=False)
+ return super().get_queryset().filter(
+ data_envio__isnull=False,
+ data_recebimento__isnull=False)
+
+ class DetailView(CrudBaseForListAndDetailExternalAppView.DetailView):
+
+ @property
+ def extras_url(self):
+
+ if self.object.texto_articulado.exists():
+ ta = self.object.texto_articulado.first()
+ yield (str(reverse_lazy(
+ 'sapl.compilacao:ta_text',
+ kwargs={'ta_id': ta.pk})) + '?back_type=history',
+ 'btn-success',
+ _('Texto EletrĂ´nico'))
class ParticipacaoParlamentarCrud(CrudBaseForListAndDetailExternalAppView):
@@ -74,6 +101,12 @@ class ParticipacaoParlamentarCrud(CrudBaseForListAndDetailExternalAppView):
list_field_names = ['composicao__comissao__nome', 'cargo__nome', (
'composicao__periodo__data_inicio', 'composicao__periodo__data_fim')]
+ class BaseMixin(CrudBaseForListAndDetailExternalAppView.BaseMixin):
+
+ @classmethod
+ def url_name(cls, suffix):
+ return '%s_parlamentar_%s' % (cls.model._meta.model_name, suffix)
+
class ListView(CrudBaseForListAndDetailExternalAppView.ListView):
ordering = ('-composicao__periodo')
diff --git a/sapl/templates/compilacao/textoarticulado_detail.html b/sapl/templates/compilacao/textoarticulado_detail.html
index 40c961dfa..82a078697 100644
--- a/sapl/templates/compilacao/textoarticulado_detail.html
+++ b/sapl/templates/compilacao/textoarticulado_detail.html
@@ -7,7 +7,9 @@
{%if object %}
-
- {% if object.content_object%}
+ {% if request.GET.back_type == 'history' and object.content_object %}
+ {% trans 'Voltar para '%}{{object.content_object}}
+ {% elif object.content_object%}
{% trans 'Voltar para '%}{{object.content_object}}
{%else%}
{% trans 'InĂcio' %}
diff --git a/sapl/templates/crud/detail.html b/sapl/templates/crud/detail.html
index f88ba897d..f425ed791 100644
--- a/sapl/templates/crud/detail.html
+++ b/sapl/templates/crud/detail.html
@@ -21,6 +21,15 @@
{% endif %}
+ {% if view.extras_url %}
+
+ {% for url, css_class, text in view.extras_url %}
+
+ {{text}}
+
+ {% endfor %}
+
+ {% endif %}
{% endblock sub_actions %}
diff --git a/sapl/templates/crud/detail_detail.html b/sapl/templates/crud/detail_detail.html
index 219e287df..cb0b103ec 100644
--- a/sapl/templates/crud/detail_detail.html
+++ b/sapl/templates/crud/detail_detail.html
@@ -18,6 +18,17 @@
{% endif %}
+ {% if view.extras_url %}
+
+ {% for url, css_class, text in view.extras_url %}
+
+ {{text}}
+
+ {% endfor %}
+
+ {% endif %}
+
+
{% if view.update_url or view.delete_url %}
{% if view.update_url %}
diff --git a/sapl/templates/materia/proposicao_detail.html b/sapl/templates/materia/proposicao_detail.html
index dd6f68046..2a0f6e6de 100644
--- a/sapl/templates/materia/proposicao_detail.html
+++ b/sapl/templates/materia/proposicao_detail.html
@@ -123,5 +123,4 @@
{% endif %}
-
{% endblock detail_content %}