From fb9db55f63c9a1db4e3412833e9cc3cb1b31d92f Mon Sep 17 00:00:00 2001 From: Eduardo Calil Date: Wed, 14 Sep 2016 09:59:15 -0300 Subject: [PATCH] Permite visualizacao de expedientes diversos para usuario anonimo e cria autorizacoes para este caso --- sapl/sessao/views.py | 7 ++-- sapl/static/js/app.js | 7 +++- sapl/templates/sessao/expediente.html | 49 +++++++++++++++++++-------- 3 files changed, 45 insertions(+), 18 deletions(-) diff --git a/sapl/sessao/views.py b/sapl/sessao/views.py index f2256e5e7..7dfe8c2f8 100644 --- a/sapl/sessao/views.py +++ b/sapl/sessao/views.py @@ -922,17 +922,18 @@ class ResumoView(SessaoCrud.CrudDetailView): return self.render_to_response(context) -class ExpedienteView(PermissionRequiredMixin, - FormMixin, +class ExpedienteView(FormMixin, SessaoCrud.CrudDetailView): template_name = 'sessao/expediente.html' form_class = ExpedienteForm - permission_required = permissoes_sessao() def post(self, request, *args, **kwargs): self.object = self.get_object() form = ExpedienteForm(request.POST) + if not self.request.user.has_perms(permissoes_sessao()): + return self.form_invalid(form) + if form.is_valid(): list_tipo = request.POST.getlist('tipo') list_conteudo = request.POST.getlist('conteudo') diff --git a/sapl/static/js/app.js b/sapl/static/js/app.js index 4a8853cd3..127bf2b86 100644 --- a/sapl/static/js/app.js +++ b/sapl/static/js/app.js @@ -1,4 +1,4 @@ -function initTinymce(elements) { +function initTinymce(elements, readonly=false) { removeTinymce(); var config_tinymce = { force_br_newlines : false, @@ -11,6 +11,11 @@ function initTinymce(elements) { border_css: "/static/styles/style_tinymce.css", content_css: "/static/styles/style_tinymce.css", } + + if (readonly) { + config_tinymce.readonly = 1 + } + if (elements != null) { config_tinymce['elements'] = elements; config_tinymce['mode'] = "exact"; diff --git a/sapl/templates/sessao/expediente.html b/sapl/templates/sessao/expediente.html index 0ef0c6e2d..66aacb226 100644 --- a/sapl/templates/sessao/expediente.html +++ b/sapl/templates/sessao/expediente.html @@ -1,29 +1,50 @@ {% extends "crud/detail.html" %} {% load i18n %} {% load crispy_forms_tags %} +{% load common_tags %} {% block detail_content %} -
- {% csrf_token %} +{% if perms|get_add_perm:view %} + + {% csrf_token %} + + {% for e in expedientes %} +
+ {{e.tipo}} + + +
+
+ {% endfor %} + +
+ +
+ +{% else %} {% for e in expedientes %} -
- {{e.tipo}} - - -
-
+
+ {{e.tipo}} + +
+
{% endfor %} -
- - +{% endif %} {% endblock detail_content %} {% block extra_js %} - + {% if perms|get_add_perm:view %} + + + {% else %} + + {% endif %} {% endblock %}