Browse Source

Permite visualizacao de expedientes diversos para usuario anonimo e cria autorizacoes para este caso

pull/585/head
Eduardo Calil 8 years ago
parent
commit
fb9db55f63
  1. 7
      sapl/sessao/views.py
  2. 7
      sapl/static/js/app.js
  3. 21
      sapl/templates/sessao/expediente.html

7
sapl/sessao/views.py

@ -922,17 +922,18 @@ class ResumoView(SessaoCrud.CrudDetailView):
return self.render_to_response(context) return self.render_to_response(context)
class ExpedienteView(PermissionRequiredMixin, class ExpedienteView(FormMixin,
FormMixin,
SessaoCrud.CrudDetailView): SessaoCrud.CrudDetailView):
template_name = 'sessao/expediente.html' template_name = 'sessao/expediente.html'
form_class = ExpedienteForm form_class = ExpedienteForm
permission_required = permissoes_sessao()
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
self.object = self.get_object() self.object = self.get_object()
form = ExpedienteForm(request.POST) form = ExpedienteForm(request.POST)
if not self.request.user.has_perms(permissoes_sessao()):
return self.form_invalid(form)
if form.is_valid(): if form.is_valid():
list_tipo = request.POST.getlist('tipo') list_tipo = request.POST.getlist('tipo')
list_conteudo = request.POST.getlist('conteudo') list_conteudo = request.POST.getlist('conteudo')

7
sapl/static/js/app.js

@ -1,4 +1,4 @@
function initTinymce(elements) { function initTinymce(elements, readonly=false) {
removeTinymce(); removeTinymce();
var config_tinymce = { var config_tinymce = {
force_br_newlines : false, force_br_newlines : false,
@ -11,6 +11,11 @@ function initTinymce(elements) {
border_css: "/static/styles/style_tinymce.css", border_css: "/static/styles/style_tinymce.css",
content_css: "/static/styles/style_tinymce.css", content_css: "/static/styles/style_tinymce.css",
} }
if (readonly) {
config_tinymce.readonly = 1
}
if (elements != null) { if (elements != null) {
config_tinymce['elements'] = elements; config_tinymce['elements'] = elements;
config_tinymce['mode'] = "exact"; config_tinymce['mode'] = "exact";

21
sapl/templates/sessao/expediente.html

@ -1,9 +1,11 @@
{% extends "crud/detail.html" %} {% extends "crud/detail.html" %}
{% load i18n %} {% load i18n %}
{% load crispy_forms_tags %} {% load crispy_forms_tags %}
{% load common_tags %}
{% block detail_content %} {% block detail_content %}
{% if perms|get_add_perm:view %}
<form method="post"> <form method="post">
{% csrf_token %} {% csrf_token %}
@ -20,10 +22,29 @@
<input type="submit" value="Salvar" class="btn btn-primary"/> <input type="submit" value="Salvar" class="btn btn-primary"/>
</form> </form>
{% else %}
{% for e in expedientes %}
<fieldset class="form-group">
<legend>{{e.tipo}}</legend>
<textarea rows="5" cols="50" name="conteudo" id="conteudo" class="form-control">{{e.conteudo}}</textarea>
<br />
</fieldset>
{% endfor %}
{% endif %}
{% endblock detail_content %} {% endblock detail_content %}
<!-- Texto RICO --> <!-- Texto RICO -->
{% block extra_js %} {% block extra_js %}
{% if perms|get_add_perm:view %}
<script language="JavaScript"> <script language="JavaScript">
initTinymce(null); initTinymce(null);
</script> </script>
<!-- Se nao tiver permissao, o texto rico fica readonly -->
{% else %}
<script language="JavaScript">
initTinymce(null, true);
</script>
{% endif %}
{% endblock %} {% endblock %}

Loading…
Cancel
Save