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. 49
      sapl/templates/sessao/expediente.html

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

7
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";

49
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 %}
<form method="post">
{% csrf_token %}
{% if perms|get_add_perm:view %}
<form method="post">
{% csrf_token %}
{% for e in expedientes %}
<fieldset class="form-group">
<legend>{{e.tipo}}</legend>
<input type="hidden" name="tipo" id="tipo" value="{{e.tipo.id}}" class="form-control"/>
<textarea rows="5" cols="50" name="conteudo" id="conteudo" class="form-control">{{e.conteudo}}</textarea>
<br />
</fieldset>
{% endfor %}
<br />
<input type="submit" value="Salvar" class="btn btn-primary"/>
</form>
{% else %}
{% for e in expedientes %}
<fieldset class="form-group">
<legend>{{e.tipo}}</legend>
<input type="hidden" name="tipo" id="tipo" value="{{e.tipo.id}}" class="form-control"/>
<textarea rows="5" cols="50" name="conteudo" id="conteudo" class="form-control">{{e.conteudo}}</textarea>
<br />
</fieldset>
<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 %}
<br />
<input type="submit" value="Salvar" class="btn btn-primary"/>
</form>
{% endif %}
{% endblock detail_content %}
<!-- Texto RICO -->
{% block extra_js %}
<script language="JavaScript">
initTinymce(null);
</script>
{% if perms|get_add_perm:view %}
<script language="JavaScript">
initTinymce(null);
</script>
<!-- Se nao tiver permissao, o texto rico fica readonly -->
{% else %}
<script language="JavaScript">
initTinymce(null, true);
</script>
{% endif %}
{% endblock %}

Loading…
Cancel
Save