Browse Source

Fix #786

pull/788/head
LeandroRoberto 8 years ago
parent
commit
1a33f87eae
  1. 2
      sapl/compilacao/models.py
  2. 5
      sapl/crispy_layout_mixin.py
  3. 7
      sapl/crud/base.py
  4. 35
      sapl/parlamentares/views.py
  5. 4
      sapl/templates/compilacao/textoarticulado_detail.html
  6. 9
      sapl/templates/crud/detail.html
  7. 11
      sapl/templates/crud/detail_detail.html
  8. 1
      sapl/templates/materia/proposicao_detail.html

2
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

5
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 = '<ul>'
for v in value.all():
display += '<li>%s</li>' % str(v)

7
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

35
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')

4
sapl/templates/compilacao/textoarticulado_detail.html

@ -7,7 +7,9 @@
<ul class="nav nav-pills navbar-right">
{%if object %}
<li>
{% if object.content_object%}
{% if request.GET.back_type == 'history' and object.content_object %}
<a href="javascript:window.history.back()" title="{% trans 'Voltar para '%}{{object.content_object}}">{% trans 'Voltar para '%}{{object.content_object}}</a>
{% elif object.content_object%}
<a href="{% url object|urldetail_content_type object.content_object.pk %}" title="{% trans 'Voltar para '%}{{object.content_object}}">{% trans 'Voltar para '%}{{object.content_object}}</a>
{%else%}
<a href="{% url 'sapl.compilacao:ta_detail' object.pk %}">{% trans 'Início' %}</a>

9
sapl/templates/crud/detail.html

@ -21,6 +21,15 @@
</a>
{% endif %}
</div>
{% if view.extras_url %}
<div class="actions btn-group btn-group-sm" role="group">
{% for url, css_class, text in view.extras_url %}
<a href="{{url}}" class="btn btn-default {{css_class}}">
{{text}}
</a>
{% endfor %}
</div>
{% endif %}
{% endblock sub_actions %}
<div class="editons pull-right">

11
sapl/templates/crud/detail_detail.html

@ -18,6 +18,17 @@
</a>
{% endif %}
</div>
{% if view.extras_url %}
<div class="actions btn-group btn-group-sm" role="group">
{% for url, css_class, text in view.extras_url %}
<a href="{{url}}" class="btn btn-default {{css_class}}">
{{text}}
</a>
{% endfor %}
</div>
{% endif %}
{% if view.update_url or view.delete_url %}
<div class="actions btn-group pull-right " role="group">
{% if view.update_url %}

1
sapl/templates/materia/proposicao_detail.html

@ -123,5 +123,4 @@
</div>
</div>
{% endif %}
{% endblock detail_content %}

Loading…
Cancel
Save