diff --git a/compilacao/forms.py b/compilacao/forms.py index 6cfbbd873..3842bf340 100644 --- a/compilacao/forms.py +++ b/compilacao/forms.py @@ -1,8 +1,124 @@ +from crispy_forms.helper import FormHelper +from crispy_forms.layout import Layout, Fieldset, ButtonHolder, Submit, Field,\ + Div, Column, Row, Hidden, Button from django import forms +from django.core.urlresolvers import reverse +from django.forms.models import ModelForm from django.utils.translation import ugettext_lazy as _ +from compilacao.models import Nota, TipoNota, Dispositivo +import sapl + class UpLoadImportFileForm(forms.Form): import_file = forms.FileField( required=True, label=_('Arquivo formato ODF para Importanção')) + + +def get_tipos_nota(): + return [(t.id, t.sigla + ' - ' + t.nome) for t in TipoNota.objects.all()] + + +class NotaForm(ModelForm): + NPRIV = 1 + NSTRL = 2 + NINST = 3 + NPUBL = 4 + + PUBLICIDADE_CHOICES = ( + # Only the owner of the note has visibility. + (NPRIV, _('Nota Privada')), + # All of the same group have visibility. + (NSTRL, _('Nota Setorial')), + # All authenticated users have visibility. + (NINST, _('Nota Institucional')), + # All users have visibility. + (NPUBL, _('Nota Pública')), + ) + + titulo = forms.CharField(label=' ', required=False) + texto = forms.CharField(label='', widget=forms.Textarea) + url_externa = forms.URLField(label='', required=False) + + publicidade = forms.ChoiceField( + required=True, + label='Publicidade', + choices=PUBLICIDADE_CHOICES, + widget=forms.Select(attrs={'class': 'selector'})) + + tipo = forms.ModelChoiceField( + required=False, + label='Tipo da Nota', + queryset=TipoNota.objects.all(), + empty_label=None) + + publicacao = forms.DateField(label=u'Publicação', + input_formats=['%d/%m/%Y'], + required=True, + widget=forms.DateInput( + format='%d/%m/%Y')) + efetividade = forms.DateField(label=u'Efetividade', + input_formats=['%d/%m/%Y'], + required=True, + widget=forms.DateInput( + format='%d/%m/%Y')) + dispositivo = forms.ModelChoiceField(queryset=Dispositivo.objects.all(), + widget=forms.HiddenInput()) + pk = forms.IntegerField(widget=forms.HiddenInput(), + required=False) + + class Meta: + model = Nota + fields = ['titulo', + 'texto', + 'url_externa', + 'publicidade', + 'publicacao', + 'efetividade', + 'tipo', + 'dispositivo', + 'pk' + ] + + def __init__(self, *args, **kwargs): + + row1 = sapl.layout.to_row([ + ('tipo', 4), + ]) + row1.append( + Column( + Field( + 'titulo', + placeholder=_('Título da Nota (opcional)') + ), + css_class='columns large-8')) + + row3 = sapl.layout.to_row([ + ('publicidade', 3), + ('publicacao', 3), + ('efetividade', 3), + (Button('submit', 'Salvar', + css_class='button primary'), 3) + ]) + + self.helper = FormHelper() + self.helper.layout = Layout( + row1, + Field('texto', placeholder=_('Adicionar Nota')), + Field('url_externa', placeholder=_('URL Externa (opcional)')), + row3 + ) + + kwargs.pop('norma_id') + dispositivo_id = kwargs.pop('dispositivo_id') + if 'pk' in kwargs: + pk = kwargs.pop('pk') + else: + pk = '' + + super(NotaForm, self).__init__(*args, **kwargs) + + self.fields['dispositivo'].initial = dispositivo_id + if pk: + self.fields['pk'].initial = pk diff --git a/compilacao/migrations/0025_auto_20151122_1744.py b/compilacao/migrations/0025_auto_20151122_1744.py new file mode 100644 index 000000000..1b69eb301 --- /dev/null +++ b/compilacao/migrations/0025_auto_20151122_1744.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('compilacao', '0024_auto_20151120_1814'), + ] + + operations = [ + migrations.RenameField( + model_name='nota', + old_name='efetifidade', + new_name='efetividade', + ), + migrations.AlterField( + model_name='nota', + name='dispositivo', + field=models.ForeignKey(to='compilacao.Dispositivo', related_name='notas', verbose_name='Dispositivo da Nota'), + ), + ] diff --git a/compilacao/migrations/0026_auto_20151122_1756.py b/compilacao/migrations/0026_auto_20151122_1756.py new file mode 100644 index 000000000..9d75c3f91 --- /dev/null +++ b/compilacao/migrations/0026_auto_20151122_1756.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('compilacao', '0025_auto_20151122_1744'), + ] + + operations = [ + migrations.AlterModelOptions( + name='nota', + options={'verbose_name': 'Nota', 'ordering': ['publicacao'], 'verbose_name_plural': 'Notas'}, + ), + migrations.AddField( + model_name='nota', + name='titulo', + field=models.CharField(verbose_name='Título', max_length=100, default=''), + ), + migrations.AlterField( + model_name='nota', + name='texto', + field=models.TextField(verbose_name='Texto'), + ), + ] diff --git a/compilacao/models.py b/compilacao/models.py index baaa77dd1..076df95e0 100644 --- a/compilacao/models.py +++ b/compilacao/models.py @@ -256,7 +256,7 @@ class TipoDispositivo(BaseModel): return self.nome def permitido_inserir_in( - self, base, include_relative_autos=True, perfil_pk=None): + self, pai_relativo, include_relative_autos=True, perfil_pk=None): if not perfil_pk: perfis = PerfilEstruturalTextosNormativos.objects.filter( @@ -267,7 +267,7 @@ class TipoDispositivo(BaseModel): perfil_pk = perfis[0].pk - pp = self.possiveis_pais.filter(pai=base, perfil_id=perfil_pk) + pp = self.possiveis_pais.filter(pai=pai_relativo, perfil_id=perfil_pk) if pp.exists(): if not include_relative_autos: if pp[0].filho_de_insercao_automatica: @@ -1051,6 +1051,7 @@ class Nota(TimestampedMixin): NSTRL = 2 NINST = 3 NPUBL = 4 + PUBLICIDADE_CHOICES = ( # Only the owner of the note has visibility. (NPRIV, _('Nota Privada')), @@ -1062,19 +1063,25 @@ class Nota(TimestampedMixin): (NPUBL, _('Nota Pública')), ) - texto = models.TextField(verbose_name=_('Texto da Nota')) + titulo = models.CharField( + verbose_name=_('Título'), + max_length=100, + default='', + blank=True) + texto = models.TextField(verbose_name=_('Texto')) url_externa = models.CharField( max_length=1024, blank=True, verbose_name=_('Url externa')) publicacao = models.DateTimeField(verbose_name=_('Data de Publicação')) - efetifidade = models.DateTimeField(verbose_name=_('Data de Efeito')) + efetividade = models.DateTimeField(verbose_name=_('Data de Efeito')) tipo = models.ForeignKey(TipoNota, verbose_name=_('Tipo da Nota')) dispositivo = models.ForeignKey( Dispositivo, - verbose_name=_('Dispositivo da Nota')) + verbose_name=_('Dispositivo da Nota'), + related_name='notas') owner = models.ForeignKey(User, verbose_name=_('Dono da Nota')) publicidade = models.PositiveSmallIntegerField( @@ -1084,9 +1091,10 @@ class Nota(TimestampedMixin): class Meta: verbose_name = _('Nota') verbose_name_plural = _('Notas') + ordering = ['-publicacao', '-modified'] def __str__(self): return '%s: %s' % ( self.tipo, - self.PUBLICIDADE_CHOICES[self.publicidade][1] + self.get_publicidade_display() ) diff --git a/compilacao/urls.py b/compilacao/urls.py index d59058411..7a3c2b012 100644 --- a/compilacao/urls.py +++ b/compilacao/urls.py @@ -22,6 +22,18 @@ urlpatterns_compilacao = [ url(r'^(?P[0-9]+)/compilacao/(?P[0-9]+)/actions', views.ActionsEditView.as_view(), name='dispositivo_actions'), + url(r'^(?P[0-9]+)/compilacao/' + '(?P[0-9]+)/nota/create$', + views.NotasCreateView.as_view(), name='nota_create'), + + url(r'^(?P[0-9]+)/compilacao/' + '(?P[0-9]+)/nota/(?P[0-9]+)/edit$', + views.NotasEditView.as_view(), name='nota_edit'), + + url(r'^(?P[0-9]+)/compilacao/' + '(?P[0-9]+)/nota/delete$', + views.NotasDeleteView.as_view(), name='nota_delete'), + ] urlpatterns = [ diff --git a/compilacao/views.py b/compilacao/views.py index 28000547a..2702a8f9d 100644 --- a/compilacao/views.py +++ b/compilacao/views.py @@ -2,24 +2,29 @@ from collections import OrderedDict from datetime import datetime, timedelta from os.path import sys +from django.contrib.auth.models import User from django.core.signing import Signer +from django.core.urlresolvers import reverse from django.db.models import Q -from django.http.response import JsonResponse +from django.http.response import JsonResponse, HttpResponse from django.shortcuts import render from django.utils.dateparse import parse_date from django.utils.translation import ugettext_lazy as _ from django.views.generic.base import TemplateView -from django.views.generic.edit import FormMixin +from django.views.generic.edit import FormMixin, UpdateView from django.views.generic.list import ListView +from vanilla.model_views import CreateView +from compilacao import forms from compilacao.file2dispositivo import Parser -from compilacao.forms import UpLoadImportFileForm +from compilacao.forms import NotaForm from compilacao.models import (Dispositivo, PerfilEstruturalTextosNormativos, TipoDispositivo, TipoNota, TipoPublicacao, - TipoVide, VeiculoPublicacao) + TipoVide, VeiculoPublicacao, Nota) from norma.models import NormaJuridica from sapl.crud import build_crud + DISPOSITIVO_SELECT_RELATED = ( 'tipo_dispositivo', 'norma_publicada', @@ -149,7 +154,8 @@ class CompilacaoView(ListView): return Dispositivo.objects.filter( ordem__gt=0, norma_id=self.kwargs['norma_id'] - ).select_related(*DISPOSITIVO_SELECT_RELATED) + ).select_related(*DISPOSITIVO_SELECT_RELATED).prefetch_related( + 'notas',) def get_vigencias(self): itens = Dispositivo.objects.filter( @@ -272,7 +278,7 @@ class CompilacaoEditView(CompilacaoView, FormMixin): pk_view = 0 def post(self, request, *args, **kwargs): - form = UpLoadImportFileForm(request.POST, request.FILES) + form = forms.UpLoadImportFileForm(request.POST, request.FILES) message = "Arquivo Submetido com sucesso" self.object_list = self.get_queryset() @@ -312,7 +318,7 @@ class CompilacaoEditView(CompilacaoView, FormMixin): def get(self, request, *args, **kwargs): self.object_list = self.get_queryset() - form_class = UpLoadImportFileForm + form_class = forms.UpLoadImportFileForm self.form = self.get_form(form_class) context = self.get_context_data( object_list=self.object_list, @@ -739,8 +745,8 @@ class ActionsEditMixin(object): def render_to_json_response(self, context, **response_kwargs): - test = getattr(self, context['action']) - return JsonResponse(test(context), safe=False) + action = getattr(self, context['action']) + return JsonResponse(action(context), safe=False) def delete_item_dispositivo(self, context): return self.delete_bloco_dispositivo(context) @@ -778,7 +784,8 @@ class ActionsEditMixin(object): parents = [base, ] + base.get_parents() tipos_dp_auto_insert = tipo.filhos_permitidos.filter( - filho_de_insercao_automatica=True) + filho_de_insercao_automatica=True, + perfil_id=context['perfil_pk']) count_auto_insert = 0 for tipoauto in tipos_dp_auto_insert: @@ -793,9 +800,6 @@ class ActionsEditMixin(object): else: count_auto_insert += 1 - ordem = base.criar_espaco( - espaco_a_criar=1 + count_auto_insert, local=local_add) - dp_irmao = None dp_pai = None for dp in parents: @@ -838,6 +842,28 @@ class ActionsEditMixin(object): else: dp.set_numero_completo([1, 0, 0, 0, 0, 0, ]) + # verificar se existe restrição de quantidade de itens + if dp.dispositivo_pai: + pp = dp.tipo_dispositivo.possiveis_pais.filter( + pai_id=dp.dispositivo_pai.tipo_dispositivo_id, + perfil_id=context['perfil_pk']) + + if pp.exists() and pp[0].quantidade_permitida >= 0: + qtd_existente = Dispositivo.objects.filter( + norma_id=dp.norma_id, + tipo_dispositivo_id=dp.tipo_dispositivo_id).count() + + if qtd_existente >= pp[0].quantidade_permitida: + return {'pk': base.pk, + 'pai': [base.dispositivo_pai.pk, ], + 'alert': str(_('Limite de inserções de ' + 'dispositivos deste tipo ' + 'foi excedido.')) + } + + ordem = base.criar_espaco( + espaco_a_criar=1 + count_auto_insert, local=local_add) + dp.rotulo = dp.rotulo_padrao() dp.ordem = ordem dp.incrementar_irmaos(variacao, [local_add, ]) @@ -846,6 +872,7 @@ class ActionsEditMixin(object): dp.save() dp_auto_insert = None + # Inserção automática if count_auto_insert: dp_pk = dp.pk @@ -1055,3 +1082,82 @@ class ActionsEditView(ActionsEditMixin, TemplateView): context['perfil_pk'] = self.request.session['perfil_estrutural'] return self.render_to_json_response(context, **response_kwargs) + + +class NotasCreateView(FormMixin, CreateView): + template_name = 'compilacao/nota_ajaxform.html' + form_class = forms.NotaForm + + def get(self, request, *args, **kwargs): + + if 'action' in request.GET and request.GET['action'] == 'modelo_nota': + tn = TipoNota.objects.get(pk=request.GET['id_tipo']) + return HttpResponse(tn.modelo) + + return super(NotasCreateView, self).get(request, *args, **kwargs) + + def get_form_kwargs(self): + kwargs = super(NotasCreateView, self).get_form_kwargs() + kwargs.update(self.kwargs) + return kwargs + + def post(self, request, *args, **kwargs): + try: + form = NotaForm(request.POST, request.FILES, **kwargs) + + if form.is_valid(): + nt = form.save(commit=False) + # TODO: Implementar tratamento do usuário. + nt.owner_id = User.objects.order_by('id')[:1][0].pk + nt.save() + self.kwargs['pk'] = nt.pk + return self.form_valid(form) + else: + return self.form_invalid(form) + except Exception as e: + print(e) + return HttpResponse("post") + + def get_success_url(self): + return reverse( + 'dispositivo', kwargs={ + 'norma_id': self.kwargs[ + 'norma_id'], + 'dispositivo_id': self.kwargs[ + 'dispositivo_id']}) + + +class NotasEditView(UpdateView): + model = Nota + template_name = 'compilacao/nota_ajaxform.html' + form_class = forms.NotaForm + + def get(self, request, *args, **kwargs): + try: + # TODO: permitir edição apenas das notas do usuário conectado + # TODO: tratar revalidação no método post + # TODO: não mostrar botão de edição na interface + if 'action' in request.GET and request.GET['action'] == 'modelo_nota': + tn = TipoNota.objects.get(pk=request.GET['id_tipo']) + return HttpResponse(tn.modelo) + + return super(NotasEditView, self).get(request, *args, **kwargs) + except Exception as e: + print(e) + + def get_form_kwargs(self): + kwargs = super(NotasEditView, self).get_form_kwargs() + kwargs.update(self.kwargs) + return kwargs + + def get_success_url(self): + return reverse( + 'dispositivo', kwargs={ + 'norma_id': self.kwargs[ + 'norma_id'], + 'dispositivo_id': self.kwargs[ + 'dispositivo_id']}) + + +class NotasDeleteView(FormMixin, CreateView): + pass diff --git a/sapl/settings.py b/sapl/settings.py index 52d0b2b53..998d10b7d 100644 --- a/sapl/settings.py +++ b/sapl/settings.py @@ -60,7 +60,8 @@ INSTALLED_APPS = ( 'sass_processor', ) if DEBUG: - INSTALLED_APPS += ('debug_toolbar',) + # INSTALLED_APPS += ('debug_toolbar',) + pass MIDDLEWARE_CLASSES = ( 'django.contrib.sessions.middleware.SessionMiddleware', diff --git a/static/img/down_arrow_select.jpg b/static/img/down_arrow_select.jpg new file mode 100644 index 000000000..a3a75352d Binary files /dev/null and b/static/img/down_arrow_select.jpg differ diff --git a/static/img/hand-note.png b/static/img/hand-note.png new file mode 100644 index 000000000..43c757bf1 Binary files /dev/null and b/static/img/hand-note.png differ diff --git a/static/js/compilacao.js b/static/js/compilacao.js index 30e8551a0..2adf251fa 100644 --- a/static/js/compilacao.js +++ b/static/js/compilacao.js @@ -1,227 +1,3 @@ - -var editortype = "textarea"; -var gets = 0; -var onSubmitEditForm = function(event) { - - var texto = ''; - var editorTiny = tinymce.get('editdi_texto'); - - if (editorTiny != null) - texto = editorTiny.getContent(); - else - texto = $('#editdi_texto').val(); - - var formData = { - 'csrfmiddlewaretoken' : $('input[name=csrfmiddlewaretoken]').val(), - 'texto' : texto - }; - - var url = $('.csform form').attr( "action_ajax" ); - $("#message_block").css("display", "block"); - - $.post(url, formData) - .done(function(data) { - - if (typeof data == "string") { - $('.dpt-selected').html(data); - clearEditSelected(); - reloadFunctionClicks(); - return; - } - - clearEditSelected(); - - if (data.pk != null) - refreshScreenFocusPk(data); - else { - alert('Erro na inserção!'); - flag_refresh_all = false; - } - - }).always(function() { - $("#message_block").css("display", "none"); - }); - if (event != null) - event.preventDefault(); -} - - -var clickEditDispositivo = function(event) { - var _pk = event.currentTarget.getAttribute('pk'); - if ($('#dpt'+_pk).hasClass("dpt-selected")) { - clearEditSelected(); - return; - } - clearEditSelected(); - clickUpdateDispositivo(event); -} - -var clickUpdateDispositivo = function(event, __pk_refresh, __pk_edit, __action, flag_actions_vibible, flag_refresh_all) { - - var pk_refresh = __pk_refresh; - var pk_edit = __pk_edit; - var _action = __action; - var _variacao = ''; - var _tipo_pk = ''; - var _perfil_pk = ''; - - if (event != null) { - pk_refresh = event.currentTarget.getAttribute('pk'); - _action = $(this).attr('action'); - _variacao = $(this).attr('variacao'); - _tipo_pk = $(this).attr('tipo_pk'); - _perfil_pk = $(this).attr('perfil_pk'); - } - - if (pk_edit == null) - pk_edit = pk_refresh; - - var url = ''; - if (_action == '') - return; - else if ( _action == null) { - url = pk_refresh+'/refresh?edit='+pk_edit; - } - else if (_action.startsWith('refresh')) { - var str = _action.split(':'); - if (str.length > 1) { - if(_action.endsWith('perfil')) { - url = '&perfil_pk='+_perfil_pk; - } - else { - editortype = str[1]; - SetCookie("editortype", editortype, 30) - } - } - url = pk_refresh+'/refresh?edit='+pk_edit+url; - } - else if (_action.startsWith('add_')) { - - url = pk_refresh+'/actions?action='+_action; - url += '&tipo_pk='+_tipo_pk; - url += '&variacao='+_variacao; - - $("#message_block").css("display", "block"); - - } - else if (_action.startsWith('delete_')) { - url = pk_refresh+'/actions?action='+_action; - $("#message_block").css("display", "block"); - } - - $.get(url).done(function( data ) { - if ( _action == null || _action.startsWith('refresh')) { - - if (flag_refresh_all) { - if (flag_actions_vibible) - clearEditSelected(); - - $( '#dpt' + pk_refresh ).html( data); - } - else { - //console.log(pk_refresh + ' - '+pk_edit) - if (flag_actions_vibible == null || flag_actions_vibible) - clearEditSelected(); - - $( '#dpt' + pk_refresh ).prepend( data ); - } - - reloadFunctionClicks(); - - var _editortype = editortype; - if ( $('.edt-'+_editortype).length == 0) { - _editortype = 'construct'; - } - - if ( _editortype == 'tinymce' ) { - initTinymce(); - } - else if (_editortype == 'textarea') { - $('.csform form').submit(onSubmitEditForm); - } - else if (_editortype == 'construct') { - $('.csform .btn-salvar').parent().addClass("displaynone"); - $('.csform .btn-salvar, .csform .fields').addClass("displaynone"); - $('#dpt'+pk_refresh).css('min-height', $('.actions_right').height()*2); - $('.actions_inserts').removeClass('menu_flutuante'); - } - else if (_editortype == 'detail') { - $('.csform .btn-salvar').parent().removeClass("displaynone"); - $('.csform .btn-salvar, .csform .fields').removeClass("displaynone"); - $('#dpt'+pk_refresh).css('min-height', $('.actions_right').height()*2); - $('.actions_inserts').addClass('menu_flutuante'); - } - - $(".edt-"+_editortype).addClass('selected'); - //$(".container").addClass('class_color_container'); - - if (flag_actions_vibible == null || flag_actions_vibible) { - $('html, body').animate({ - scrollTop: $('#dpt' + pk_edit ).offset().top - window.innerHeight / 10 - }, 300); - $('#dpt'+pk_edit).addClass('dpt-selected'); - } - } - - else if (_action == 'add_next' || _action == 'add_in') { - clearEditSelected(); - if (data.pk != null) { - refreshScreenFocusPk(data); - } - else { - alert('Erro na inserção!'); - } - } - else if (_action.startsWith('delete_')) { - $("#message_block").css("display", "block"); - clearEditSelected(); - if (data.pk != null) { - refreshScreenFocusPk(data); - } - else { - alert('Erro exclusão!'); - } - } - else { - clearEditSelected(); - reloadFunctionClicks(); - } - }).always(function() { - $("#message_block").css("display", "none"); - }); -} - -function refreshScreenFocusPk(data) { - - for (var pai = 0; pai < data.pai.length; pai++) - if (data.pai[pai] != -1) { - clickUpdateDispositivo(null, data.pai[pai], data.pk, 'refresh', pai == 0, true); - } - else { - href = location.href.split('#')[0] - location.href = href+'#'+data.pk - location.reload(true) - } -} - -function clearEditSelected() { - $(".container").removeClass('class_color_container'); - tinymce.remove(); - $('.dpt-selected').removeClass('dpt-selected'); - $('.dpt').css('min-height', ''); - $('.csform').remove(); -} - -function reloadFunctionClicks() { - $('.dpt .de, .btn-action, .btn-edit').off(); - - $('.dpt .de, .btn-edit').on('click', clickEditDispositivo); - - $('.btn-action').on('click', clickUpdateDispositivo); - - $('#editdi_texto').focus(); -} - function initTinymce() { tinymce.init({ @@ -239,7 +15,6 @@ function initTinymce() { }); } -//cookies function SetCookie(cookieName,cookieValue,nDays) { var today = new Date(); var expire = new Date(); @@ -258,22 +33,3 @@ function ReadCookie(cookieName) { if (ind1==-1) ind1=theCookie.length; return unescape(theCookie.substring(ind+cookieName.length+2,ind1)); } - -$(document).ready(function() { - - editortype = ReadCookie("editortype") - - if (editortype == null || editortype == "") { - editortype = "textarea" - SetCookie("editortype", editortype, 30) - } - - reloadFunctionClicks(); - $("#message_block").css("display", "none"); - - href = location.href.split('#') - if (href.length == 2) { - clickUpdateDispositivo(null, href[1], href[1], 'refresh', true); - } - -}); diff --git a/static/js/compilacao_edit.js b/static/js/compilacao_edit.js new file mode 100644 index 000000000..1c7cb9226 --- /dev/null +++ b/static/js/compilacao_edit.js @@ -0,0 +1,254 @@ + +var editortype = "textarea"; +var gets = 0; +var onSubmitEditForm = function(event) { + + var texto = ''; + var editorTiny = tinymce.get('editdi_texto'); + + if (editorTiny != null) + texto = editorTiny.getContent(); + else + texto = $('#editdi_texto').val(); + + var formData = { + 'csrfmiddlewaretoken' : $('input[name=csrfmiddlewaretoken]').val(), + 'texto' : texto + }; + + var url = $('.csform form').attr( "action_ajax" ); + $("#message_block").css("display", "block"); + + $.post(url, formData) + .done(function(data) { + + if (typeof data == "string") { + $('.dpt-selected').html(data); + clearEditSelected(); + reloadFunctionClicks(); + return; + } + + clearEditSelected(); + + if (data.pk != null) + refreshScreenFocusPk(data); + else { + alert('Erro na inserção!'); + flag_refresh_all = false; + } + + }).always(function() { + $("#message_block").css("display", "none"); + }); + if (event != null) + event.preventDefault(); +} + + +var clickEditDispositivo = function(event) { + var _pk = event.currentTarget.getAttribute('pk'); + if ($('#dpt'+_pk).hasClass("dpt-selected")) { + clearEditSelected(); + return; + } + clearEditSelected(); + clickUpdateDispositivo(event); +} + +var clickUpdateDispositivo = function(event, __pk_refresh, __pk_edit, __action, flag_actions_vibible, flag_refresh_all) { + + var pk_refresh = __pk_refresh; + var pk_edit = __pk_edit; + var _action = __action; + var _variacao = ''; + var _tipo_pk = ''; + var _perfil_pk = ''; + + if (event != null) { + pk_refresh = event.currentTarget.getAttribute('pk'); + _action = $(this).attr('action'); + _variacao = $(this).attr('variacao'); + _tipo_pk = $(this).attr('tipo_pk'); + _perfil_pk = $(this).attr('perfil_pk'); + } + + if (pk_edit == null) + pk_edit = pk_refresh; + + var url = ''; + if (_action == '') + return; + else if ( _action == null) { + url = pk_refresh+'/refresh?edit='+pk_edit; + } + else if (_action.startsWith('refresh')) { + var str = _action.split(':'); + if (str.length > 1) { + if(_action.endsWith('perfil')) { + url = '&perfil_pk='+_perfil_pk; + $("#message_block").css("display", "block"); + } + else { + editortype = str[1]; + SetCookie("editortype", editortype, 30) + } + } + url = pk_refresh+'/refresh?edit='+pk_edit+url; + + } + else if (_action.startsWith('add_')) { + + url = pk_refresh+'/actions?action='+_action; + url += '&tipo_pk='+_tipo_pk; + url += '&variacao='+_variacao; + + $("#message_block").css("display", "block"); + + } + else if (_action.startsWith('delete_')) { + var r = confirm("Confirma Exclusão deste dispositivo?"); + if (r == true) { + x = "You pressed OK!"; + } else { + return + } + url = pk_refresh+'/actions?action='+_action; + $("#message_block").css("display", "block"); + } + + $.get(url).done(function( data ) { + if ( _action == null || _action.startsWith('refresh')) { + + if (flag_refresh_all) { + if (flag_actions_vibible) + clearEditSelected(); + + $( '#dpt' + pk_refresh ).html( data); + } + else { + //console.log(pk_refresh + ' - '+pk_edit) + if (flag_actions_vibible == null || flag_actions_vibible) + clearEditSelected(); + + $( '#dpt' + pk_refresh ).prepend( data ); + } + + reloadFunctionClicks(); + + var _editortype = editortype; + if ( $('.edt-'+_editortype).length == 0) { + _editortype = 'construct'; + } + + if ( _editortype == 'tinymce' ) { + initTinymce(); + } + else if (_editortype == 'textarea') { + $('.csform form').submit(onSubmitEditForm); + } + else if (_editortype == 'construct') { + $('.csform .btn-salvar').parent().addClass("displaynone"); + $('.csform .btn-salvar, .csform .fields').addClass("displaynone"); + $('#dpt'+pk_refresh).css('min-height', $('.actions_right').height()*2); + $('.actions_inserts').removeClass('menu_flutuante'); + } + else if (_editortype == 'detail') { + $('.csform .btn-salvar').parent().removeClass("displaynone"); + $('.csform .btn-salvar, .csform .fields').removeClass("displaynone"); + $('#dpt'+pk_refresh).css('min-height', $('.actions_right').height()*2); + $('.actions_inserts').addClass('menu_flutuante'); + } + + $(".edt-"+_editortype).addClass('selected'); + //$(".container").addClass('class_color_container'); + + if (flag_actions_vibible == null || flag_actions_vibible) { + $('#dpt'+pk_edit).addClass('dpt-selected'); + $('html, body').animate({ + scrollTop: $('#dpt' + pk_edit ).offset().top - window.innerHeight / 10 + }, 300); + } + } + + else if (_action == 'add_next' || _action == 'add_in') { + clearEditSelected(); + if (data.pk != null) { + + if (data.alert != null) + alert(data.alert) + + refreshScreenFocusPk(data); + } + else { + alert('Erro na inserção!'); + } + } + else if (_action.startsWith('delete_')) { + $("#message_block").css("display", "block"); + clearEditSelected(); + if (data.pk != null) { + refreshScreenFocusPk(data); + } + else { + alert('Erro exclusão!'); + } + } + else { + clearEditSelected(); + reloadFunctionClicks(); + } + }).always(function() { + $("#message_block").css("display", "none"); + }); +} + +function refreshScreenFocusPk(data) { + + for (var pai = 0; pai < data.pai.length; pai++) + if (data.pai[pai] != -1) { + clickUpdateDispositivo(null, data.pai[pai], data.pk, 'refresh', pai == 0, true); + } + else { + href = location.href.split('#')[0] + location.href = href+'#'+data.pk + location.reload(true) + } +} + +function clearEditSelected() { + $(".container").removeClass('class_color_container'); + tinymce.remove(); + $('.dpt-selected').removeClass('dpt-selected'); + $('.dpt').css('min-height', ''); + $('.csform').remove(); +} + +function reloadFunctionClicks() { + $('.dpt .de, .btn-action, .btn-edit').off(); + + $('.dpt .de, .btn-edit').on('click', clickEditDispositivo); + + $('.btn-action').on('click', clickUpdateDispositivo); + + $('#editdi_texto').focus(); +} + +$(document).ready(function() { + + editortype = ReadCookie("editortype") + + if (editortype == null || editortype == "") { + editortype = "textarea" + SetCookie("editortype", editortype, 30) + } + + reloadFunctionClicks(); + $("#message_block").css("display", "none"); + + href = location.href.split('#') + if (href.length == 2) { + clickUpdateDispositivo(null, href[1], href[1], 'refresh', true); + } + +}); diff --git a/static/js/compilacao_notas.js b/static/js/compilacao_notas.js new file mode 100644 index 000000000..8688272c0 --- /dev/null +++ b/static/js/compilacao_notas.js @@ -0,0 +1,91 @@ + +function onEventsDneExec(pk) { + + $('html, body').animate({ + scrollTop: $('#dne' + pk ).offset().top - window.innerHeight / 5 + }, 300); + + $('.dateinput').fdatepicker({ + // TODO localize + format: 'dd/mm/yyyy', + language: 'pt', + endDate: '31/12/2100', + todayBtn: true + }); + + $('#dne'+pk+" select[name='tipo']").change(function(event) { + var url = ''; + url = 'compilacao/'+pk+'/nota/create?action=modelo_nota&id_tipo='+this.value; + $.get(url).done(function( data ) { + $('#dne'+pk+" textarea[name='texto']").val(data); + }); + }); + + $('#dne'+pk+" .button").click(onSubmitEditForm); +} + +var onSubmitEditForm = function(event) { + + var id_dispositivo = $('#id_dispositivo').val(); + var id_nota = $('#id_pk').val(); + var url = 'compilacao/'+id_dispositivo+'/nota/' + + if (id_nota == '') + url += 'create'; + else + url += id_nota+'/edit'; + + $.post( url, $('#dne'+id_dispositivo+" form").serialize(), function(data) { + + if (typeof data == "string") { + if (data.indexOf('= 0) { + $('#dne'+id_dispositivo+' .dne-form').html(data); + onEventsDneExec(id_dispositivo); + } + else { + $('#dne'+id_dispositivo+' .dne-form').closest('.dpt').html(data) + onReadyNotas(); + } + } + } + ); +} +function getFormNota(_this, _btn) { + + var id_dispositivo = $('.dne-exec .dne-form').closest('.dne').attr('pk'); + if (id_dispositivo != null) { + $('#dne'+id_dispositivo).removeClass('dne-exec'); + $('#dne'+id_dispositivo+' .dne-form').html(''); + } + + var url = ''; + if (_btn == 'btn-create') { + id_dispositivo = $(_this).attr('pk'); + url = 'compilacao/'+id_dispositivo+'/nota/create'; + } + else { + var id_nota = $(_this).attr('pk'); + id_dispositivo = $(_this).closest('.dn').attr('pk'); + url = 'compilacao/'+id_dispositivo+'/nota/'+id_nota+'/edit' + } + $('#dne'+id_dispositivo).addClass('dne-exec'); + $('#dne'+id_dispositivo).addClass('dne-exec'); + + $.get(url).done(function( data ) { + $('#dne'+id_dispositivo+' .dne-form').html(data); + onEventsDneExec(id_dispositivo); + }); +} +function onReadyNotas() { + $('.dne .btn-create').off(); + $('.dne .btn-edit').off(); + $('.dne .btn-create').click(function(){ + getFormNota(this, 'btn-create') + }); + $('.dn .btn-edit').click(function(){ + getFormNota(this, 'btn-edit') + }); +} +$(document).ready(function() { + onReadyNotas() +}); diff --git a/static/js/compilacao_view.js b/static/js/compilacao_view.js new file mode 100644 index 000000000..d196ef3e4 --- /dev/null +++ b/static/js/compilacao_view.js @@ -0,0 +1,40 @@ +$( window ).scroll(function() { + if (window.pageYOffset <= 180) + $( "section.vigencias" ).removeClass("fixed"); + else if (!$( "section.vigencias" ).hasClass("fixed")) + $( "section.vigencias" ).addClass("fixed"); +}); + +$(window).load(function() { + setTimeout(function() { + height = $( "section.vigencias" ).height(); + $('html, body').animate({ + scrollTop: window.pageYOffset - height - 55 + }, 300); + }, 100); +}); + +function textoMultiVigente(item) { + $(".cp .tipo-vigencias a").removeClass("selected") + $(item).addClass("selected") + $(".desativado").removeClass("displaynone"); + $(".link_alterador").removeClass("displaynone"); +} + +function textoVigente(item, link) { + $(".cp .tipo-vigencias a").removeClass("selected") + $(item).addClass("selected") + $(".desativado").addClass("displaynone"); + $(".link_alterador").removeClass("displaynone"); + if (!link) + $(".link_alterador").addClass("displaynone"); +} + +$(document).ready(function() { + $("#btn_font_menos").click(function() { + $(".dpt").css("font-size", "-=1"); + }); + $("#btn_font_mais").click(function() { + $(".dpt").css("font-size", "+=1"); + }); +}); diff --git a/static/styles/compilacao.scss b/static/styles/compilacao.scss index c1ca8d044..fbd590873 100644 --- a/static/styles/compilacao.scss +++ b/static/styles/compilacao.scss @@ -16,21 +16,49 @@ $color_actions_border: #CCC; -o-border-radius: $radius; border-radius: $radius; } +@mixin placeholder($color, $opacity, $fontsize, $fontweight) { + + &::-webkit-input-placeholder { + color: $color; + opacity: $opacity; + font-size:$fontsize; + font-weight: $fontweight; + } + &::-moz-placeholder { + color: $color; + opacity: $opacity; + font-size:$fontsize; + font-weight: $fontweight; + } + &::-moz-placeholder { + color: $color; + opacity: $opacity; + font-size:$fontsize; + font-weight: $fontweight; + } + &:-ms-input-placeholder { + color: $color; + opacity: $opacity; + font-size:$fontsize; + font-weight: $fontweight; + } +} + @mixin li_flutuante() { & > ul { transform: translateY(30px); - transition: transform 0.1s linear, - opacity 0.1s linear, - clip 0s 0.3s; + transition: transform 0.1s linear, opacity 0.1s linear, clip 0s 0.3s; clip: rect(0, 0, 0, 0); opacity: 0; position:absolute; margin-left: 0.5em; box-shadow: 0px 6px 18px rgba(0, 0, 0, 0.19), 0px 2px 6px rgba(0, 0, 0, 0.23); + -webkit-transition-delay: 0.4s; /* Safari */ + transition-delay: 0.4s; li { a { border-right: 0px !important; @@ -112,9 +140,20 @@ $color_actions_border: #CCC; .cp { + .desativado, .desativado * { + text-decoration: line-through; + color: #777 !important; + + table, table td { + border: 1px dotted #ccc; + } + } + .dpt { font-size:1em; transition: all 0.2s ease-in-out; + position: relative; + .ementa { padding: 4em 0em 3em 35%; @@ -169,6 +208,10 @@ $color_actions_border: #CCC; .artigo { font-size: 1.15em; float:left; + .dptt { + z-index: 98; + position: relative; + } } .caput { @@ -224,16 +267,223 @@ $color_actions_border: #CCC; color: #018 !important; } } - } /* and dpt */ - .desativado, .desativado * { - text-decoration: line-through; - color: #777 !important; + .dn { /* Notas de Dispositivo*/ + font-size: 0.8rem; + font-weight: normal; + line-height: 1rem; + position: relative; + p, ul { + font-size: 0.8rem; + font-weight: normal; + line-height: 1rem; + margin: 0 0 0 0; + list-style: none; + } + .dnl { /* Lista Notas de Dispositivo*/ + display: block; + margin-left: 15%; - table, table td { - border: 1px dotted #ccc; + .dnli { + margin-top: 0.5em; + border-top: 1px solid #c7e3d3; + display: block; + + ul { + transition: opacity 0.5s linear, clip 0s 0.3s; + clip: rect(0, 0, 0, 0); + opacity: 0; + position: absolute; + background: transparent; + right: 0; + padding: 0.5em 0.5em 0em 0.5em; + border: 1px solid #c7e3d3; + border-top: 0px; + + + } + + &:hover { + min-height: 2.5em; + ul { + transition: opacity 0.5s linear, clip 0s 0.3s; + clip: auto; + opacity: 1; + background: rgba(230,230,230, 0.9); + } + } + + li { + display: table-cell; + color: #aaa; + &.bullet { + padding: 0 0.333em; + padding-bottom: 0.2em; + } + + &:hover { + color: #787; + } + } + .ntitulo { + font-weight: bold; + color: #676; + font-size: 90%; + } + .ntexto { + color: #787; + } + .nowner { + color: #27AE60; + } + } + } } - } + + .dptt { + .dne { + position: relative; + display: block; + font-size: 0.8rem; + font-weight: normal; + line-height: 1rem; + text-align: left; + height: 0; + transform: scaleY(0); + transform-origin: top; + transition: all 0.3s ease; + * { + font-size: 0.8rem; + font-weight: normal; + line-height: 1rem; + } + + ul.btns-action { + position: absolute; + margin: 0 0 0 0; + display: table; + list-style: none; + clip: rect(0,0,0,0); + opacity: 0; + transition: opacity 1.5s linear, clip 1s linear; + transition-delay: 0s; + li { + display: table-cell; + background-color: #ddd; + border-radius: 50%; + a { + border-radius: 50%; + display: inline-block; + background: url(/static/img/hand-note.png) no-repeat 50% 50%; + padding: 1.2em 1.7em; + &:hover { + background-color: rgba(0, 150, 0, 0.1); + } + } + } + } + } + .dne-exec { + box-shadow: -4px 15px 15px rgba(0, 0, 0, 0.1), 0px 6px 6px rgba(0, 0, 0, 0.23); + @include background-top-down(#f5f5f5, #eee); + + transform: scaleY(1); + height: auto; + transition-delay: 0s; + margin: 1em 0 2em 0; + padding: 0em; + ul.btns-action { + display: none; + } + + .dne-form { + .asterisk { + color: transparent; + &::before { + color: red; + content: "\2b25"; + padding: 0.333em; + vertical-align: super; + } + } + fieldset { + border: 0px; + } + select { + background: url(/static/img/down_arrow_select.jpg) no-repeat right #ddd; + border: 0px; + outline:0px; + } + .row:first-of-type { + margin-top: 1em; + display: inline-block; + } + .input { + border: 0px; + border-bottom: 1px solid #ccc; + margin: 0 0 0 0 ; + padding: 0.5em; + background: #eee; + height: auto; + box-shadow: 0 0 0; + @include placeholder(#777, 1, 100%, normal); + &:focus { + background: #fafafa; + } + } + .textinput[name='titulo']{ + @extend .input; + font-size:130%; + font-weight: bold; + border-bottom: 0; + @include placeholder(#777, 1, 100%, bold); + } + + .textarea { + @extend .input; + resize: vertical; + font-weight: normal; + } + + .urlinput { + @extend .input; + margin-bottom: 1em; + } + + .button { + width: 100%; + margin-top: 1.6em; + height: 2.3125rem; + padding: 0; + } + } + } + &:hover { + .dne { + height: 3.2em; + transform: scaleY(1); + transition-delay: 1s; + + ul.btns-action { + clip: rect(-100px, 2000px, 2000px, -100px); + opacity: 1; + transition: opacity 0.5s linear, clip 0s 0.3s; + transition-delay: 0.5s; + li { + a { + } + } + } + } + .dne-exec { + transition-delay: 0s; + height: auto; + + } + } + + } + } /* and dpt */ .top-bar { line-height: 1.6rem; @@ -371,6 +621,7 @@ $color_actions_border: #CCC; } } + .bloco { display: block; clear: both; @@ -402,9 +653,7 @@ $color_actions_border: #CCC; display: block; } } - .btns-action { - opacity: 0; - } + } /* fim dpt */ .dpt-selected { @@ -488,10 +737,10 @@ $color_actions_border: #CCC; display: table-cell; vertical-align: top; &:hover { - background-color: rgba(0,0,0,0.08); + background-color: rgba(255, 255, 255, 0.5); & > a { text-shadow: 0 0 5px #777; - color: #ff0; + color: #0a5; } } } @@ -506,6 +755,10 @@ $color_actions_border: #CCC; font-size: 80%; text-align: right; z-index: 5; + display: table; + li { + display: table-cell; + } } .actions_parents { @@ -556,13 +809,13 @@ $color_actions_border: #CCC; left: 0; bottom: 0; display: inline-block; + border-top: 1px solid $color_actions_border; a { padding: 0 0.4em; } li { border: 0px; border-right: 1px solid $color_actions_border; - border-top: 1px solid $color_actions_border; } } @@ -688,9 +941,9 @@ $color_actions_border: #CCC; @include li_flutuante(); table-layout: fixed; } - &.opc_excluir { + &.menu_excluir { @include li_flutuante(); - table-layout: fixed; + display: block; position: static; @@ -727,7 +980,7 @@ $color_actions_border: #CCC; @include li_flutuante(); - &.opc_excluir { + &.menu_excluir { & > ul { li { &:first-child { @@ -738,14 +991,10 @@ $color_actions_border: #CCC; } } } - } } - } - - textarea { margin: 0; resize: vertical; @@ -775,7 +1024,7 @@ $color_actions_border: #CCC; } .selected { - background-color: rgba(0, 0, 0, 0.1); + background-color: rgba(255, 255, 255, 0.5); a { &:hover { color: $color_actions !important; @@ -799,6 +1048,9 @@ $color_actions_border: #CCC; text-shadow: 0 0 5px #fff; box-shadow: 0 0 5px #777; } +.mce-menu { + background: #eee !important; +} .displaynone { display: none !important; @@ -869,7 +1121,7 @@ $color_actions_border: #CCC; left: auto; } } - &.opc_excluir > ul { + &.menu_excluir > ul { left: 10% !important; right: 0 !important; margin-left: 0; diff --git a/templates/compilacao/edit.html b/templates/compilacao/edit.html index 5781ca373..404949703 100644 --- a/templates/compilacao/edit.html +++ b/templates/compilacao/edit.html @@ -9,6 +9,7 @@ {% block head_content %}{{block.super}} + {% endblock %} diff --git a/templates/compilacao/edit_bloco.html b/templates/compilacao/edit_bloco.html index 5febac519..4da277ed6 100644 --- a/templates/compilacao/edit_bloco.html +++ b/templates/compilacao/edit_bloco.html @@ -59,11 +59,11 @@ {% if not dpt|is_relative_auto_insert:request %} -
  •  Excluir +
  • @@ -82,9 +82,10 @@ -
    -
    Ordem: {{dpt.ordem}}, Nivel: {{dpt.nivel}}, Número: {{dpt.get_numero_completo}}
    -
    +
      +
    • Ordem: {{dpt.ordem}}, Nivel: {{dpt.nivel}}, Número: {{dpt.get_numero_completo}}
    • +
    • .
    • +
      Em Edição:
      diff --git a/templates/compilacao/index.html b/templates/compilacao/index.html index ddec9f487..4e2aee533 100644 --- a/templates/compilacao/index.html +++ b/templates/compilacao/index.html @@ -6,6 +6,12 @@ {% block head_content %}{{block.super}} + + + + + {# TODO: incluir javascript compilacao_notas apenas se houver usuário conectado e que possua permissão para cadastro de notas #} + {% endblock %} @@ -14,67 +20,16 @@ {% endblock %} {% block base_content %} -
      +
      + a + A +
      -
      -a -A -
      - - {% for key, values in view.get_vigencias.items %} - {% if forloop.first %} + {% for key, values in view.get_vigencias.items %} + {% if forloop.first %}
      {% endblock base_content %} diff --git a/templates/compilacao/index_bloco.html b/templates/compilacao/index_bloco.html index def483898..65d7cd202 100644 --- a/templates/compilacao/index_bloco.html +++ b/templates/compilacao/index_bloco.html @@ -7,24 +7,85 @@ {% elif dpt.nivel < view.flag_nivel_old %} {% close_div view.flag_nivel_old dpt.nivel 0 %} {% endif%} -
      -
      - {% spaceless %} - {{ dpt.tipo_dispositivo.rotulo_prefixo_html|safe }}{{ dpt.rotulo }}{{ dpt.tipo_dispositivo.rotulo_sufixo_html|safe }}{{ dpt.tipo_dispositivo.texto_prefixo_html|safe }}{%if dpt.texto%}{{ dpt.texto|safe }}{%else%} {%endif%} - {% if dpt.norma_publicada_id != None and not dpt.tipo_dispositivo.dispositivo_de_articulacao %} - - {{ dpt.tipo_dispositivo.nota_automatica_prefixo_html|safe }} - {% nota_automatica dpt %} - {{ dpt.tipo_dispositivo.nota_automatica_sufixo_html|safe }} - - {% endif %} - {% endspaceless %} - {% if view.is_norma_alteradora and dpt.tipo_dispositivo.class_css == 'bloco_alteracao'%} - {%with node=dpt template_name='compilacao/index_bloco_alteracao.html' %} - {%include template_name%} - {%endwith%} - {% endif%} + + + {% if forloop.first and view|isinst:'DispositivoView' %} + {% else %} +
      + {% endif%} + + {% spaceless %} +
      +
      + {{ dpt.tipo_dispositivo.rotulo_prefixo_html|safe }}{{ dpt.rotulo }}{{ dpt.tipo_dispositivo.rotulo_sufixo_html|safe }}{{ dpt.tipo_dispositivo.texto_prefixo_html|safe }}{%if dpt.texto%}{{ dpt.texto|safe }}{%else%} {%endif%} + {% if dpt.norma_publicada_id != None and not dpt.tipo_dispositivo.dispositivo_de_articulacao %} + + {{ dpt.tipo_dispositivo.nota_automatica_prefixo_html|safe }} + {% nota_automatica dpt %} + {{ dpt.tipo_dispositivo.nota_automatica_sufixo_html|safe }} + + {% endif %} + {% if not dpt.tipo_dispositivo.dispositivo_de_articulacao%} +
      {# TODO: User - dne - Dispostivo Nota Editor - tratar permissão de usuário#} + +
      +
      + {% endif%}
      + {% if not dpt.tipo_dispositivo.dispositivo_de_articulacao%} +
      {# Dispostivo Nota#} + +
        {# Dispostivo Nota Lista#} + {% for nota in dpt.notas.all %}{# TODO: User - dnl - Dispostivo Nota Editor - tratar permissão de usuário quanto a publicidade#} +
      • +
          +
        • Editar
        • {# TODO: User - tratar permissão usuário #} +
        • +
        • Excluir
        • {# TODO: User - tratar permissão usuário #} +
        • + + +
        • {{nota.tipo.nome}}
        • +
        • +
        • {%if nota.owner.first_name%}{{nota.owner.first_name}}{%else%}{{nota.owner}}{%endif%}
        • +
        • +
        • {{nota.publicacao|date:"d M Y"}}
        • +
        + + + {%if nota.url_externa %}{%endif%} + {%if nota.titulo %}
        {{nota.titulo}}
        {%endif%} + {%if nota.url_externa %}
        {%endif%} + + {%if nota.url_externa %}{%endif%} +
        {{ nota.texto}}
        + {%if nota.url_externa %}
        {%endif%} + +{%comment%} +
          +
        • {{nota.efetividade|date:"d M Y"}}
        • +
        • +
        • {{nota.get_publicidade_display}}
        • +
        +{%endcomment%} +
      • {# Dispostivo Nota Lista Item#} + {% endfor %} +
      +
      + {% endif%} +
      + {% endspaceless %} + {% if view.is_norma_alteradora and dpt.tipo_dispositivo.class_css == 'bloco_alteracao'%} + {%with node=dpt template_name='compilacao/index_bloco_alteracao.html' %} + {%include template_name%} + {%endwith%} + {% endif%} {% set_nivel_old view dpt.nivel %} {% endfor %} -{% close_div view.flag_nivel_old view.flag_nivel_ini 0 %} +{% if view|isinst:'DispositivoView' %} + {% close_div view.flag_nivel_old view.flag_nivel_ini -1 %} +{% else %} + {% close_div view.flag_nivel_old view.flag_nivel_ini 0 %} +{% endif%} diff --git a/templates/compilacao/index_bloco_alteracao.html b/templates/compilacao/index_bloco_alteracao.html index 3f7b71744..e5925a8ac 100644 --- a/templates/compilacao/index_bloco_alteracao.html +++ b/templates/compilacao/index_bloco_alteracao.html @@ -3,8 +3,10 @@ {% spaceless %}
      +
      {{ ch.tipo_dispositivo.rotulo_prefixo_html|safe }}{{ ch.rotulo }}{{ ch.tipo_dispositivo.rotulo_sufixo_html|safe }}{{ ch.tipo_dispositivo.texto_prefixo_html|safe }}{{ ch.texto|safe }} -
      +
      +
      {% endspaceless %} {% endfor %} diff --git a/templates/compilacao/nota_ajaxform.html b/templates/compilacao/nota_ajaxform.html new file mode 100644 index 000000000..8b032736f --- /dev/null +++ b/templates/compilacao/nota_ajaxform.html @@ -0,0 +1,3 @@ +{% load crispy_forms_tags %} +{% crispy form form.helper%} +