From 4289b8b2bb21f3a1fc8d79cd120bb94566a54dec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Rodrigues?= Date: Fri, 2 Aug 2019 16:28:50 -0300 Subject: [PATCH] =?UTF-8?q?Impl.=20#2909=20-=20Norma=20Jur=C3=ADdica?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/norma/forms.py | 7 +- .../0026_normajuridica_ultima_edicao.py | 20 +++ sapl/norma/models.py | 4 + sapl/norma/views.py | 12 ++ .../materia/materialegislativa_detail.html | 2 + sapl/templates/materia/tramitacao_detail.html | 3 +- .../templates/norma/normajuridica_detail.html | 155 +++++++++--------- 7 files changed, 127 insertions(+), 76 deletions(-) create mode 100644 sapl/norma/migrations/0026_normajuridica_ultima_edicao.py diff --git a/sapl/norma/forms.py b/sapl/norma/forms.py index 803cd2751..c86f52c66 100644 --- a/sapl/norma/forms.py +++ b/sapl/norma/forms.py @@ -134,10 +134,13 @@ class NormaJuridicaForm(FileFieldCheckMixin, ModelForm): 'texto_integral', 'assuntos', 'user', - 'ip'] + 'ip', + 'ultima_edicao'] + widgets = {'assuntos': widgets.CheckboxSelectMultiple, 'user': forms.HiddenInput(), - 'ip': forms.HiddenInput()} + 'ip': forms.HiddenInput(), + 'ultima_edicao': forms.HiddenInput()} def clean(self): diff --git a/sapl/norma/migrations/0026_normajuridica_ultima_edicao.py b/sapl/norma/migrations/0026_normajuridica_ultima_edicao.py new file mode 100644 index 000000000..7fa7a8da9 --- /dev/null +++ b/sapl/norma/migrations/0026_normajuridica_ultima_edicao.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.20 on 2019-08-02 19:05 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('norma', '0025_auto_20190704_1403'), + ] + + operations = [ + migrations.AddField( + model_name='normajuridica', + name='ultima_edicao', + field=models.DateTimeField(blank=True, null=True, verbose_name='Data e Hora da Edição'), + ), + ] diff --git a/sapl/norma/models.py b/sapl/norma/models.py index 05f0bbc5a..8371b6f52 100644 --- a/sapl/norma/models.py +++ b/sapl/norma/models.py @@ -156,6 +156,10 @@ class NormaJuridica(models.Model): blank=True, default='' ) + ultima_edicao = models.DateTimeField( + verbose_name=_('Data e Hora da Edição'), + blank=True, null=True + ) class Meta: verbose_name = _('Norma Jurídica') diff --git a/sapl/norma/views.py b/sapl/norma/views.py index 8d9a62eaa..66795ee42 100644 --- a/sapl/norma/views.py +++ b/sapl/norma/views.py @@ -1,3 +1,4 @@ +from datetime import datetime import logging import re @@ -222,6 +223,9 @@ class NormaCrud(Crud): initial['user'] = self.request.user initial['ip'] = get_client_ip(self.request) + tz = timezone.get_current_timezone() + initial['ultima_edicao'] = tz.localize(datetime.now()) + username = self.request.user.username try: self.logger.debug( @@ -285,6 +289,10 @@ class NormaCrud(Crud): if dict_objeto_antigo[atributo] != dict_objeto_novo[atributo]: self.object.user = self.request.user self.object.ip = get_client_ip(self.request) + + tz = timezone.get_current_timezone() + self.object.ultima_edicao = tz.localize(datetime.now()) + self.object.save() break @@ -293,6 +301,10 @@ class NormaCrud(Crud): if assuntos_antigos != assuntos_novos: self.object.user = self.request.user self.object.ip = get_client_ip(self.request) + + tz = timezone.get_current_timezone() + self.object.ultima_edicao = tz.localize(datetime.now()) + self.object.save() return super().form_valid(form) diff --git a/sapl/templates/materia/materialegislativa_detail.html b/sapl/templates/materia/materialegislativa_detail.html index 1eef8091d..38114e489 100644 --- a/sapl/templates/materia/materialegislativa_detail.html +++ b/sapl/templates/materia/materialegislativa_detail.html @@ -1,5 +1,6 @@ {% extends "crud/detail.html" %} {% load i18n %} + {% block sub_actions %} {{ block.super }} {% if object.em_tramitacao and mail_service_configured %} @@ -8,6 +9,7 @@ {% endif %} {% endblock sub_actions %} + {% block detail_content %} {{ block.super }} {% if object.registrovotacao_set.exists %} diff --git a/sapl/templates/materia/tramitacao_detail.html b/sapl/templates/materia/tramitacao_detail.html index 5f09e5be0..1ece652aa 100644 --- a/sapl/templates/materia/tramitacao_detail.html +++ b/sapl/templates/materia/tramitacao_detail.html @@ -1,5 +1,6 @@ {% extends "crud/detail_detail.html" %} {% load i18n %} + {% block detail_content %} {{ block.super }} {% if user.is_superuser %} @@ -48,4 +49,4 @@ {% endif %} {% endif %} -{% endblock detail_content %} \ No newline at end of file +{% endblock detail_content %} diff --git a/sapl/templates/norma/normajuridica_detail.html b/sapl/templates/norma/normajuridica_detail.html index 7d8509830..c7bc2e922 100644 --- a/sapl/templates/norma/normajuridica_detail.html +++ b/sapl/templates/norma/normajuridica_detail.html @@ -9,96 +9,91 @@ {% endif %} {% endblock %} - - {% block detail_content %} - {% for fieldset in view.layout_display %} -

{{ fieldset.legend }}

- {% for row in fieldset.rows %} -
- {% for column in row %} -
-
-

{{ column.verbose_name }}

-
- {% comment %}TODO Transformar os links em URLs diretamente no CRUD{% endcomment %} - - {% if column.text|url %} - - {% elif column.verbose_name == 'Matéria' %} - {% if object.materia.id %} - - {% else %} -
{{ column.text|safe|default:"" }}
- {% endif %} - {% else %} -
{{ column.text|safe|default:"" }}
- {% endif %} + {% for fieldset in view.layout_display %} +

{{ fieldset.legend }}

+ {% for row in fieldset.rows %} +
+ {% for column in row %} +
+
+

{{ column.verbose_name }}

+
+ {% comment %}TODO Transformar os links em URLs diretamente no CRUD{% endcomment %} + {% if column.text|url %} + -
+ {% elif column.verbose_name == 'Matéria' %} + {% if object.materia.id %} + + {% else %} +
{{ column.text|safe|default:"" }}
+ {% endif %} + {% else %} +
{{ column.text|safe|default:"" }}
+ {% endif %}
- {% endfor %} +
{% endfor %} - {% endfor %} - -
-
-
-

Normas Relacionadas

- - {% if object.get_normas_relacionadas.0|length > 0 %} - {% for p in object.get_normas_relacionadas.0 %} -
- {{ p.tipo_vinculo.descricao_ativa }}  - - {{ p.norma_relacionada.epigrafe }} - -
- {% endfor %} - {% endif %} - - {% if object.get_normas_relacionadas.1|length > 0 %} - {% for r in object.get_normas_relacionadas.1 %} -
- {{ r.tipo_vinculo.descricao_passiva }}  - - {{ r.norma_principal.epigrafe }} - -
- {% endfor %} - {% endif %} - -
-
-
-
-  

Anexos Norma Jurídica

+ {% endfor %} + {% endfor %} +
+
+
+

Normas Relacionadas

+ {% if object.get_normas_relacionadas.0|length > 0 %} + {% for p in object.get_normas_relacionadas.0 %} +
+ {{ p.tipo_vinculo.descricao_ativa }}  + + {{ p.norma_relacionada.epigrafe }} + +
+ {% endfor %} + {% endif %} + {% if object.get_normas_relacionadas.1|length > 0 %} + {% for r in object.get_normas_relacionadas.1 %} +
+ {{ r.tipo_vinculo.descricao_passiva }}  + + {{ r.norma_principal.epigrafe }} + +
+ {% endfor %} + {% endif %} +
+
+
+
+
+  

Anexos Norma Jurídica

{% if object.get_anexos_norma_juridica|length > 0 %} {% for p in object.get_anexos_norma_juridica %} {% endfor %} {% endif %}
-

- {% if user.is_superuser %}
{% if object.user %} -
+

Usuário

@@ -106,19 +101,35 @@
{% endif %} {% if object.ip %} -
+

IP

-
{{object.ip}}
+
+ {{ object.ip }} +
{% endif %} -
- {% endif %} + {% if object.ultima_edicao %} +
+
+

Data e Hora da Edição

+
+
+
+ {{ object.ultima_edicao }} +
+
+
+
+
+ {% endif %} +
+ {% endif %} {% if object.texto_articulado.exists and object.texto_articulado.first.has_view_permission %}
@@ -131,7 +142,6 @@ {% endif %} {% endblock detail_content %} - {% block webpack_loader_js %} {{ block.super }} {% if object.texto_articulado.exists and object.texto_articulado.first.has_view_permission %} @@ -139,7 +149,6 @@ {% endif %} {% endblock %} - {% block extra_js %} {% if object.texto_articulado.exists and object.texto_articulado.first.has_view_permission %}