Browse Source

Adiciona dados da última alteração e Bug Fix (#2919)

* Impl. #2909 - Tramitação de Matéria Legislativa

* Impl. #2909 - Matéria Legislativa

* Impl. #2909 - Norma Jurídica

* Adicionar correções

* Adicionar migrações

* Impl. #2909 - Tramitação Documento Administrativo

* Adicionar correções

* Impl. #2936

* Evitar merge de migrações

* Evitar merge de migrações

* Evitar merge de migrações

* Adicionar migrações

* Adicionar migrations
pull/3052/head
João Rodrigues 5 years ago
committed by Edward
parent
commit
33d0287439
  1. 48
      sapl/materia/forms.py
  2. 25
      sapl/materia/migrations/0056_auto_20190829_1206.py
  3. 16
      sapl/materia/migrations/0058_merge_20190926_1250.py
  4. 16
      sapl/materia/migrations/0061_merge_20191009_1814.py
  5. 8
      sapl/materia/models.py
  6. 45
      sapl/materia/views.py
  7. 7
      sapl/norma/forms.py
  8. 20
      sapl/norma/migrations/0027_normajuridica_ultima_edicao.py
  9. 16
      sapl/norma/migrations/0028_merge_20191009_1814.py
  10. 4
      sapl/norma/models.py
  11. 12
      sapl/norma/views.py
  12. 48
      sapl/protocoloadm/forms.py
  13. 20
      sapl/protocoloadm/migrations/0024_tramitacaoadministrativo_ultima_edicao.py
  14. 20
      sapl/protocoloadm/migrations/0025_auto_20190815_1539.py
  15. 33
      sapl/protocoloadm/migrations/0026_auto_20190815_1737.py
  16. 16
      sapl/protocoloadm/migrations/0027_merge_20190926_1250.py
  17. 16
      sapl/protocoloadm/migrations/0028_merge_20191009_1814.py
  18. 22
      sapl/protocoloadm/models.py
  19. 77
      sapl/protocoloadm/views.py
  20. 28
      sapl/templates/materia/materialegislativa_detail.html
  21. 24
      sapl/templates/materia/tramitacao_detail.html
  22. 45
      sapl/templates/norma/normajuridica_detail.html
  23. 54
      sapl/templates/protocoloadm/documentoadministrativo_detail.html
  24. 24
      sapl/templates/protocoloadm/tramitacaoadministrativo_detail.html

48
sapl/materia/forms.py

@ -179,7 +179,8 @@ class MateriaLegislativaForm(FileFieldCheckMixin, ModelForm):
'anexadas', 'data_ultima_atualizacao']
widgets = {
'user': forms.HiddenInput(),
'ip': forms.HiddenInput()
'ip': forms.HiddenInput(),
'ultima_edicao': forms.HiddenInput()
}
def __init__(self, *args, **kwargs):
@ -463,9 +464,12 @@ class TramitacaoForm(ModelForm):
'data_fim_prazo',
'texto',
'user',
'ip']
'ip',
'ultima_edicao']
widgets = {'user': forms.HiddenInput(),
'ip': forms.HiddenInput()}
'ip': forms.HiddenInput(),
'ultima_edicao': forms.HiddenInput()}
def __init__(self, *args, **kwargs):
super(TramitacaoForm, self).__init__(*args, **kwargs)
@ -578,7 +582,8 @@ class TramitacaoForm(ModelForm):
texto=tramitacao.texto,
data_fim_prazo=tramitacao.data_fim_prazo,
user=tramitacao.user,
ip=tramitacao.ip
ip=tramitacao.ip,
ultima_edicao=tramitacao.ultima_edicao
))
Tramitacao.objects.bulk_create(lista_tramitacao)
@ -620,14 +625,16 @@ class TramitacaoUpdateForm(TramitacaoForm):
'data_fim_prazo',
'texto',
'user',
'ip'
'ip',
'ultima_edicao'
]
widgets = {
'data_encaminhamento': forms.DateInput(format='%d/%m/%Y'),
'data_fim_prazo': forms.DateInput(format='%d/%m/%Y'),
'user': forms.HiddenInput(),
'ip': forms.HiddenInput()
'ip': forms.HiddenInput(),
'ultima_edicao': forms.HiddenInput()
}
def clean(self):
@ -659,6 +666,17 @@ class TramitacaoUpdateForm(TramitacaoForm):
'tramitação, pois irá conflitar com a Unidade '
'Local da tramitação seguinte')
if not (cd['data_tramitacao'] != obj.data_tramitacao or \
cd['unidade_tramitacao_destino'] != obj.unidade_tramitacao_destino or \
cd['status'] != obj.status or cd['texto'] != obj.texto or \
cd['data_encaminhamento'] != obj.data_encaminhamento or \
cd['data_fim_prazo'] != obj.data_fim_prazo or cd['urgente'] != str(obj.urgente) or \
cd['turno'] != obj.turno):
### Se não ocorreram alterações, o usuário, ip, data e hora da última edição (real) são mantidos
cd['user'] = obj.user
cd['ip'] = obj.ip
cd['ultima_edicao'] = obj.ultima_edicao
cd['data_tramitacao'] = obj.data_tramitacao
cd['unidade_tramitacao_local'] = obj.unidade_tramitacao_local
@ -690,6 +708,7 @@ class TramitacaoUpdateForm(TramitacaoForm):
tram_anexada.data_fim_prazo = nova_tram_principal.data_fim_prazo
tram_anexada.user = nova_tram_principal.user
tram_anexada.ip = nova_tram_principal.ip
tram_anexada.ultima_edicao = nova_tram_principal.ultima_edicao
tram_anexada.save()
ma.em_tramitacao = False if nova_tram_principal.status.indicador == "F" else True
@ -1614,9 +1633,13 @@ class TramitacaoEmLoteForm(ModelForm):
'data_fim_prazo',
'texto',
'user',
'ip']
'ip',
'ultima_edicao']
widgets = {'user': forms.HiddenInput(),
'ip': forms.HiddenInput()}
'ip': forms.HiddenInput(),
'ultima_edicao': forms.HiddenInput()}
def __init__(self, *args, **kwargs):
super(TramitacaoEmLoteForm, self).__init__(*args, **kwargs)
@ -1737,9 +1760,12 @@ class TramitacaoEmLoteForm(ModelForm):
@transaction.atomic
def save(self, commit=True):
cd = self.cleaned_data
materias = self.initial['materias']
user = self.initial['user'] if 'user' in self.initial else None
ip = self.initial['ip'] if 'ip' in self.initial else ''
ultima_edicao = self.initial['ultima_edicao'] if 'ultima_edicao' in self.initial else ''
tramitar_anexadas = AppConfig.attr('tramitacao_materia')
for mat_id in materias:
mat = MateriaLegislativa.objects.get(id=mat_id)
@ -1755,7 +1781,8 @@ class TramitacaoEmLoteForm(ModelForm):
texto=cd['texto'],
data_fim_prazo=cd['data_fim_prazo'],
user=user,
ip=ip
ip=ip,
ultima_edicao=ultima_edicao
)
mat.em_tramitacao = False if tramitacao.status.indicador == "F" else True
mat.save()
@ -1781,7 +1808,8 @@ class TramitacaoEmLoteForm(ModelForm):
texto=tramitacao.texto,
data_fim_prazo=tramitacao.data_fim_prazo,
user=tramitacao.user,
ip=tramitacao.ip
ip=tramitacao.ip,
ultima_edicao=tramitacao.ultima_edicao
))
Tramitacao.objects.bulk_create(lista_tramitacao)

25
sapl/materia/migrations/0056_auto_20190829_1206.py

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-08-29 15:06
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('materia', '0055_auto_20190816_0943'),
]
operations = [
migrations.AddField(
model_name='materialegislativa',
name='ultima_edicao',
field=models.DateTimeField(blank=True, null=True, verbose_name='Data e Hora da Edição'),
),
migrations.AddField(
model_name='tramitacao',
name='ultima_edicao',
field=models.DateTimeField(blank=True, null=True, verbose_name='Data e Hora da Edição'),
),
]

16
sapl/materia/migrations/0058_merge_20190926_1250.py

@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-09-26 15:50
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('materia', '0057_materiaemtramitacao'),
('materia', '0056_auto_20190829_1206'),
]
operations = [
]

16
sapl/materia/migrations/0061_merge_20191009_1814.py

@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-10-09 21:14
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('materia', '0060_auto_20190930_1136'),
('materia', '0058_merge_20190926_1250'),
]
operations = [
]

8
sapl/materia/models.py

@ -295,6 +295,10 @@ class MateriaLegislativa(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 = _('Matéria Legislativa')
@ -1083,6 +1087,10 @@ class Tramitacao(models.Model):
max_length=30,
blank=True,
default='')
ultima_edicao = models.DateTimeField(
verbose_name=_('Data e Hora da Edição'),
blank=True, null=True
)
class Meta:
verbose_name = _('Tramitação')

45
sapl/materia/views.py

@ -1235,6 +1235,10 @@ class TramitacaoCrud(MasterDetailCrud):
initial['data_tramitacao'] = timezone.now().date()
initial['ip'] = get_client_ip(self.request)
initial['user'] = self.request.user
tz = timezone.get_current_timezone()
initial['ultima_edicao'] = tz.localize(datetime.now())
return initial
def get_context_data(self, **kwargs):
@ -1301,28 +1305,20 @@ class TramitacaoCrud(MasterDetailCrud):
layout_key = 'TramitacaoUpdate'
def form_valid(self, form):
dict_objeto_antigo = Tramitacao.objects.get(
pk=self.kwargs['pk']).__dict__
def get_initial(self):
initial = super(UpdateView, self).get_initial()
self.object = form.save()
dict_objeto_novo = self.object.__dict__
initial['ip'] = get_client_ip(self.request)
initial['user'] = self.request.user
user = self.request.user
tz = timezone.get_current_timezone()
initial['ultima_edicao'] = tz.localize(datetime.now())
atributos = [
'data_tramitacao', 'unidade_tramitacao_destino_id', 'status_id', 'texto',
'data_encaminhamento', 'data_fim_prazo', 'urgente', 'turno'
]
return initial
# Se não houve qualquer alteração em um dos dados, mantém o usuário
# e ip
for atributo in atributos:
if dict_objeto_antigo[atributo] != dict_objeto_novo[atributo]:
self.object.user = user
self.object.ip = get_client_ip(self.request)
self.object.save()
break
def form_valid(self, form):
self.object = form.save()
user = self.request.user
try:
self.logger.debug("user=" + user.username + ". Tentando enviar Tramitacao (sender={}, post={}, request={}"
@ -1718,6 +1714,9 @@ class MateriaLegislativaCrud(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())
return initial
@property
@ -1749,6 +1748,10 @@ class MateriaLegislativaCrud(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
@ -2399,6 +2402,9 @@ class PrimeiraTramitacaoEmLoteView(PermissionRequiredMixin, FilterView):
user = request.user
ip = get_client_ip(request)
tz = timezone.get_current_timezone()
ultima_edicao = tz.localize(datetime.now())
materias_ids = request.POST.getlist('materias')
if not materias_ids:
msg = _("Escolha alguma matéria para ser tramitada.")
@ -2407,7 +2413,8 @@ class PrimeiraTramitacaoEmLoteView(PermissionRequiredMixin, FilterView):
form = TramitacaoEmLoteForm(request.POST,
initial= {'materias': materias_ids,
'user': user, 'ip':ip})
'user': user, 'ip':ip,
'ultima_edicao': ultima_edicao})
if form.is_valid():
form.save()

7
sapl/norma/forms.py

@ -135,10 +135,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):

20
sapl/norma/migrations/0027_normajuridica_ultima_edicao.py

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-08-29 14:41
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('norma', '0026_auto_20190712_1053'),
]
operations = [
migrations.AddField(
model_name='normajuridica',
name='ultima_edicao',
field=models.DateTimeField(blank=True, null=True, verbose_name='Data e Hora da Edição'),
),
]

16
sapl/norma/migrations/0028_merge_20191009_1814.py

@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-10-09 21:14
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('norma', '0027_normajuridica_ultima_edicao'),
('norma', '0027_auto_20191001_1115'),
]
operations = [
]

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

12
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(
@ -286,6 +290,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
@ -295,6 +303,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)

48
sapl/protocoloadm/forms.py

@ -689,9 +689,12 @@ class TramitacaoAdmForm(ModelForm):
'data_fim_prazo',
'texto',
'user',
'ip']
'ip',
'ultima_edicao']
widgets = {'user': forms.HiddenInput(),
'ip': forms.HiddenInput()}
'ip': forms.HiddenInput(),
'ultima_edicao': forms.HiddenInput()}
def __init__(self, *args, **kwargs):
@ -806,7 +809,8 @@ class TramitacaoAdmForm(ModelForm):
texto=tramitacao.texto,
data_fim_prazo=tramitacao.data_fim_prazo,
user=tramitacao.user,
ip=tramitacao.ip
ip=tramitacao.ip,
ultima_edicao=tramitacao.ultima_edicao
))
TramitacaoAdministrativo.objects.bulk_create(lista_tramitacao)
@ -820,7 +824,7 @@ def compara_tramitacoes_doc(tramitacao1, tramitacao2):
if not tramitacao1 or not tramitacao2:
return False
lst_items = ['id', 'documento_id', 'timestamp']
lst_items = ['id', 'documento_id', 'timestamp', 'ultima_edicao']
values = [(k,v) for k,v in tramitacao1.__dict__.items() if ((k not in lst_items) and (k[0] != '_'))]
other_values = [(k,v) for k,v in tramitacao2.__dict__.items() if (k not in lst_items and k[0] != '_')]
return values == other_values
@ -847,9 +851,12 @@ class TramitacaoAdmEditForm(TramitacaoAdmForm):
'data_fim_prazo',
'texto',
'user',
'ip']
'ip',
'ultima_edicao']
widgets = {'user': forms.HiddenInput(),
'ip': forms.HiddenInput()}
'ip': forms.HiddenInput(),
'ultima_edicao': forms.HiddenInput()}
def clean(self):
super(TramitacaoAdmEditForm, self).clean()
@ -886,6 +893,7 @@ class TramitacaoAdmEditForm(TramitacaoAdmForm):
cd['data_fim_prazo'] != obj.data_fim_prazo):
cd['user'] = obj.user
cd['ip'] = obj.ip
cd['ultima_edicao'] = obj.ultima_edicao
cd['data_tramitacao'] = obj.data_tramitacao
cd['unidade_tramitacao_local'] = obj.unidade_tramitacao_local
@ -917,6 +925,7 @@ class TramitacaoAdmEditForm(TramitacaoAdmForm):
tram_anexada.data_fim_prazo = nova_tram_principal.data_fim_prazo
tram_anexada.user = nova_tram_principal.user
tram_anexada.ip = nova_tram_principal.ip
tram_anexada.ultima_edicao = nova_tram_principal.ultima_edicao
tram_anexada.save()
da.tramitacao = False if nova_tram_principal.status.indicador == "F" else True
@ -1084,10 +1093,17 @@ class DocumentoAdministrativoForm(FileFieldCheckMixin, ModelForm):
'observacao',
'texto_integral',
'protocolo',
'restrito'
'restrito',
'user',
'ip',
'ultima_edicao'
]
widgets = {'protocolo': forms.HiddenInput()}
widgets = {'protocolo': forms.HiddenInput(),
'user': forms.HiddenInput(),
'ip': forms.HiddenInput(),
'ultima_edicao': forms.HiddenInput()
}
def clean(self):
super(DocumentoAdministrativoForm, self).clean()
@ -1489,9 +1505,12 @@ class TramitacaoEmLoteAdmForm(ModelForm):
'data_fim_prazo',
'texto',
'user',
'ip']
'ip',
'ultima_edicao']
widgets = {'user': forms.HiddenInput(),
'ip': forms.HiddenInput()}
'ip': forms.HiddenInput(),
'ultima_edicao': forms.HiddenInput()}
def __init__(self, *args, **kwargs):
@ -1612,9 +1631,12 @@ class TramitacaoEmLoteAdmForm(ModelForm):
@transaction.atomic
def save(self, commit=True):
cd = self.cleaned_data
documentos = self.initial['documentos']
user = self.initial['user'] if 'user' in self.initial else None
ip = self.initial['ip'] if 'ip' in self.initial else ''
ultima_edicao = self.initial['ultima_edicao'] if 'ultima_edicao' in self.initial else ''
tramitar_anexados = AppConfig.attr('tramitacao_documento')
for doc_id in documentos:
doc = DocumentoAdministrativo.objects.get(id=doc_id)
@ -1629,7 +1651,8 @@ class TramitacaoEmLoteAdmForm(ModelForm):
texto=cd['texto'],
data_fim_prazo=cd['data_fim_prazo'],
user=user,
ip=ip
ip=ip,
ultima_edicao=ultima_edicao
)
doc.tramitacao = False if tramitacao.status.indicador == "F" else True
doc.save()
@ -1654,7 +1677,8 @@ class TramitacaoEmLoteAdmForm(ModelForm):
texto=tramitacao.texto,
data_fim_prazo=tramitacao.data_fim_prazo,
user=tramitacao.user,
ip=tramitacao.ip
ip=tramitacao.ip,
ultima_edicao=tramitacao.ultima_edicao
))
TramitacaoAdministrativo.objects.bulk_create(lista_tramitacao)

20
sapl/protocoloadm/migrations/0024_tramitacaoadministrativo_ultima_edicao.py

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-08-08 21:14
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('protocoloadm', '0023_merge_20190802_1112'),
]
operations = [
migrations.AddField(
model_name='tramitacaoadministrativo',
name='ultima_edicao',
field=models.DateField(blank=True, null=True, verbose_name='Data e Hora da Edição'),
),
]

20
sapl/protocoloadm/migrations/0025_auto_20190815_1539.py

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.23 on 2019-08-15 18:39
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('protocoloadm', '0024_tramitacaoadministrativo_ultima_edicao'),
]
operations = [
migrations.AlterField(
model_name='tramitacaoadministrativo',
name='ultima_edicao',
field=models.DateTimeField(blank=True, null=True, verbose_name='Data e Hora da Edição'),
),
]

33
sapl/protocoloadm/migrations/0026_auto_20190815_1737.py

@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.23 on 2019-08-15 20:37
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('protocoloadm', '0025_auto_20190815_1539'),
]
operations = [
migrations.AddField(
model_name='documentoadministrativo',
name='ip',
field=models.CharField(blank=True, default='', max_length=30, verbose_name='IP'),
),
migrations.AddField(
model_name='documentoadministrativo',
name='ultima_edicao',
field=models.DateTimeField(blank=True, null=True, verbose_name='Data e Hora da Edição'),
),
migrations.AddField(
model_name='documentoadministrativo',
name='user',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL, verbose_name='Usuário'),
),
]

16
sapl/protocoloadm/migrations/0027_merge_20190926_1250.py

@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-09-26 15:50
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('protocoloadm', '0026_auto_20190815_1737'),
('protocoloadm', '0024_merge_20190821_1418'),
]
operations = [
]

16
sapl/protocoloadm/migrations/0028_merge_20191009_1814.py

@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-10-09 21:14
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('protocoloadm', '0027_merge_20190926_1250'),
('protocoloadm', '0025_auto_20191001_1115'),
]
operations = [
]

22
sapl/protocoloadm/models.py

@ -186,6 +186,24 @@ class DocumentoAdministrativo(models.Model):
)
)
user = models.ForeignKey(
get_settings_auth_user_model(),
verbose_name=_('Usuário'),
on_delete=models.PROTECT,
null=True,
blank=True
)
ip = models.CharField(
verbose_name=_('IP'),
max_length=30,
blank=True,
default=''
)
ultima_edicao = models.DateTimeField(
verbose_name=_('Data e Hora da Edição'),
blank=True, null=True
)
class Meta:
verbose_name = _('Documento Administrativo')
verbose_name_plural = _('Documentos Administrativos')
@ -340,6 +358,10 @@ class TramitacaoAdministrativo(models.Model):
max_length=30,
blank=True,
default='')
ultima_edicao = models.DateTimeField(
verbose_name=_('Data e Hora da Edição'),
blank=True, null=True
)
class Meta:
verbose_name = _('Tramitação de Documento Administrativo')

77
sapl/protocoloadm/views.py

@ -350,6 +350,17 @@ class DocumentoAdministrativoCrud(Crud):
form_class = DocumentoAdministrativoForm
layout_key = None
def get_initial(self):
initial = super().get_initial()
initial['user'] = self.request.user
initial['ip'] = get_client_ip(self.request)
tz = timezone.get_current_timezone()
initial['ultima_edicao'] = tz.localize(datetime.now())
return initial
@property
def cancel_url(self):
return self.search_url
@ -358,6 +369,33 @@ class DocumentoAdministrativoCrud(Crud):
form_class = DocumentoAdministrativoForm
layout_key = None
def form_valid(self, form):
dict_objeto_antigo = DocumentoAdministrativo.objects.get(
pk=self.kwargs['pk']
).__dict__
self.object = form.save()
dict_objeto_novo = self.object.__dict__
atributos = [
'tipo_id', 'ano', 'numero', 'data', 'protocolo_id', 'assunto',
'interessado', 'tramitacao', 'restrito', 'texto_integral','numero_externo',
'dias_prazo', 'data_fim_prazo', 'observacao'
]
for atributo in atributos:
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
return super().form_valid(form)
def get_initial(self):
if self.object.protocolo:
p = self.object.protocolo
@ -373,6 +411,16 @@ class DocumentoAdministrativoCrud(Crud):
return redirect('/')
return super(Crud.DetailView, self).get(args, kwargs)
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['user'] = self.request.user
context['documentoadministrativo'] = DocumentoAdministrativo.objects.get(
pk=self.kwargs['pk']
)
return context
def urlize(self, obj, fieldname):
a = '<a href="%s">%s</a>' % (
reverse(
@ -645,6 +693,12 @@ class CriarDocumentoProtocolo(PermissionRequiredMixin, CreateView):
doc['assunto'] = protocolo.assunto_ementa
doc['interessado'] = protocolo.interessado
doc['numero'] = numero_max + 1 if numero_max else 1
doc['user'] = self.request.user
doc['ip'] = get_client_ip(self.request)
tz = timezone.get_current_timezone()
doc['ultima_edicao'] = tz.localize(datetime.now())
return doc
@ -1165,6 +1219,10 @@ class TramitacaoAdmCrud(MasterDetailCrud):
initial['data_tramitacao'] = timezone.now().date()
initial['ip'] = get_client_ip(self.request)
initial['user'] = self.request.user
tz = timezone.get_current_timezone()
initial['ultima_edicao'] = tz.localize(datetime.now())
return initial
def get_context_data(self, **kwargs):
@ -1228,6 +1286,10 @@ class TramitacaoAdmCrud(MasterDetailCrud):
initial = super(UpdateView, self).get_initial()
initial['ip'] = get_client_ip(self.request)
initial['user'] = self.request.user
tz = timezone.get_current_timezone()
initial['ultima_edicao'] = tz.localize(datetime.now())
return initial
def form_valid(self, form):
@ -1381,6 +1443,13 @@ class DesvincularDocumentoView(PermissionRequiredMixin, CreateView):
ano=form.cleaned_data['ano'],
tipo=form.cleaned_data['tipo'])
documento.protocolo = None
documento.user = self.request.user
documento.ip = get_client_ip(self.request)
tz = timezone.get_current_timezone()
documento.ultima_edicao = tz.localize(datetime.now())
documento.save()
return redirect(self.get_success_url())
@ -1545,6 +1614,9 @@ class PrimeiraTramitacaoEmLoteAdmView(PermissionRequiredMixin, FilterView):
user = request.user
ip = get_client_ip(request)
tz = timezone.get_current_timezone()
ultima_edicao = tz.localize(datetime.now())
documentos_ids = request.POST.getlist('documentos')
if not documentos_ids:
msg = _("Escolha algum Documento para ser tramitado.")
@ -1552,8 +1624,9 @@ class PrimeiraTramitacaoEmLoteAdmView(PermissionRequiredMixin, FilterView):
return self.get(request, self.kwargs)
form = TramitacaoEmLoteAdmForm(request.POST,
initial={'documentos': documentos_ids,
'user': user, 'ip': ip})
initial= {'documentos': documentos_ids,
'user': user, 'ip':ip,
'ultima_edicao': ultima_edicao})
if form.is_valid():
form.save()

28
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 @@
</div>
{% endif %}
{% endblock sub_actions %}
{% block detail_content %}
{{ block.super }}
{% if object.registrovotacao_set.exists %}
@ -46,13 +48,15 @@
{% if user.is_superuser %}
<div class="row">
{% if materia.user %}
<div class="col-sm-6">
<div class="col-sm-4">
<div id="div_id_user" class="form-group">
<p class="control-label">Usuário</p>
<div class="controls">
<div class="form-control-static">
<div class="dont-break-out">
<a href="{% url 'sapl.base:user_edit' materia.user.pk %}">{{materia.user}}</a>
<a href="{% url 'sapl.base:user_edit' materia.user.pk %}">
{{ materia.user }}
</a>
</div>
</div>
</div>
@ -60,12 +64,28 @@
</div>
{% endif %}
{% if materia.ip %}
<div class="col-sm-6">
<div class="col-sm-4">
<div id="div_ip_user" class="form-group">
<p class="control-label">IP</p>
<div class="controls">
<div class="form-control-static">
<div class="dont-break-out">{{materia.ip}}</div>
<div class="dont-break-out">
{{ materia.ip }}
</div>
</div>
</div>
</div>
</div>
{% endif %}
{% if materia.ultima_edicao %}
<div class="col-sm-4">
<div id="div_ud_user" class="form-group">
<p class="control-label">Data e Hora da Edição</p>
<div class="controls">
<div class="form-control-static">
<div class="dont-break-out">
{{ materia.ultima_edicao }}
</div>
</div>
</div>
</div>

24
sapl/templates/materia/tramitacao_detail.html

@ -6,13 +6,15 @@
{% if user.is_superuser %}
<div class="row">
{% if tramitacao.user %}
<div class="col-sm-6">
<div class="col-sm-4">
<div id="div_id_user" class="form-group">
<p class="control-label">Usuário</p>
<div class="controls">
<div class="form-control-static">
<div class="dont-break-out">
<a href="{% url 'sapl.base:user_edit' tramitacao.user.pk %}">{{tramitacao.user}}</a>
<a href="{% url 'sapl.base:user_edit' tramitacao.user.pk %}">
{{ tramitacao.user }}
</a>
</div>
</div>
</div>
@ -20,13 +22,27 @@
</div>
{% endif %}
{% if tramitacao.ip %}
<div class="col-sm-6">
<div class="col-sm-4">
<div id="div_ip_user" class="form-group">
<p class="control-label">IP</p>
<div class="controls">
<div class="form-control-static">
<div class="dont-break-out">
{{tramitacao.ip}}
{{ tramitacao.ip }}
</div>
</div>
</div>
</div>
</div>
{% endif %}
{% if tramitacao.ultima_edicao %}
<div class="col-sm-4">
<div id="div_ud_user" class="form-group">
<p class="control-label">Data e Hora da Edição</p>
<div class="controls">
<div class="form-control-static">
<div class="dont-break-out">
{{ tramitacao.ultima_edicao }}
</div>
</div>
</div>

45
sapl/templates/norma/normajuridica_detail.html

@ -9,8 +9,6 @@
{% endif %}
{% endblock %}
{% block detail_content %}
{% for fieldset in view.layout_display %}
<h2 class="legend">{{ fieldset.legend }}</h2>
@ -22,12 +20,15 @@
<p class="control-label">{{ column.verbose_name }}</p>
<div class="controls">
{% comment %}TODO Transformar os links em URLs diretamente no CRUD{% endcomment %}
{% if column.text|url %}
<div class="form-control-static"><a href="{{ column.text|safe }}"> {{ column.text|safe|default:"" }} </a></div>
<div class="form-control-static">
<a href="{{ column.text|safe }}"> {{ column.text|safe|default:"" }} </a>
</div>
{% elif column.verbose_name == 'Matéria' %}
{% if object.materia.id %}
<div class="form-control-static"><a href="{% url 'sapl.materia:materialegislativa_detail' object.materia.id %}"> {{ column.text|safe|default:"" }} </a></div>
<div class="form-control-static">
<a href="{% url 'sapl.materia:materialegislativa_detail' object.materia.id %}"> {{ column.text|safe|default:"" }} </a>
</div>
{% else %}
<div class="form-control-static">{{ column.text|safe|default:"" }}</div>
{% endif %}
@ -41,12 +42,10 @@
</div>
{% endfor %}
{% endfor %}
<hr />
<div class="row">
<div class="col-sm-12">
<p class="control-label">Normas Relacionadas</p>
{% if object.get_normas_relacionadas.0|length > 0 %}
{% for p in object.get_normas_relacionadas.0 %}
<div class="form-control-static">
@ -57,7 +56,6 @@
</div>
{% endfor %}
{% endif %}
{% if object.get_normas_relacionadas.1|length > 0 %}
{% for r in object.get_normas_relacionadas.1 %}
<div class="form-control-static">
@ -68,7 +66,6 @@
</div>
{% endfor %}
{% endif %}
</div>
</div>
<hr />
@ -86,19 +83,19 @@
{% endif %}
</div>
</div>
<br><br>
{% if user.is_superuser %}
<div class="row">
{% if object.user %}
<div class="col-sm-6">
<div class="col-sm-4">
<div id="div_id_user" class="form-group">
<p class="control-label">Usuário</p>
<div class="controls">
<div class="form-control-static">
<div class="dont-break-out">
<a href="{% url 'sapl.base:user_edit' object.user.pk %}">{{object.user}}</a>
<a href="{% url 'sapl.base:user_edit' object.user.pk %}">
{{ object.user }}
</a>
</div>
</div>
</div>
@ -106,12 +103,28 @@
</div>
{% endif %}
{% if object.ip %}
<div class="col-sm-6">
<div class="col-sm-4">
<div id="div_ip_user" class="form-group">
<p class="control-label">IP</p>
<div class="controls">
<div class="form-control-static">
<div class="dont-break-out">{{object.ip}}</div>
<div class="dont-break-out">
{{ object.ip }}
</div>
</div>
</div>
</div>
</div>
{% endif %}
{% if object.ultima_edicao %}
<div class="col-sm-4">
<div id="div_ud_user" class="form-group">
<p class="control-label">Data e Hora da Edição</p>
<div class="controls">
<div class="form-control-static">
<div class="dont-break-out">
{{ object.ultima_edicao }}
</div>
</div>
</div>
</div>
@ -131,7 +144,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 +151,6 @@
{% endif %}
{% endblock %}
{% block extra_js %}
{% if object.texto_articulado.exists and object.texto_articulado.first.has_view_permission %}
<script language="Javascript">

54
sapl/templates/protocoloadm/documentoadministrativo_detail.html

@ -0,0 +1,54 @@
{% extends "crud/detail.html" %}
{% load i18n %}
{% block detail_content %}
{{ block.super }}
{% if user.is_superuser %}
<div class="row">
{% if documentoadministrativo.user %}
<div class="col-sm-4">
<div id="div_id_user" class="form-group">
<p class="control-label">Usuário</p>
<div class="controls">
<div class="form-control-static">
<div class="dont-break-out">
<a href="{% url 'sapl.base:user_edit' documentoadministrativo.user.pk %}">
{{ documentoadministrativo.user }}
</a>
</div>
</div>
</div>
</div>
</div>
{% endif %}
{% if documentoadministrativo.ip %}
<div class="col-sm-4">
<div id="div_ip_user" class="form-group">
<p class="control-label">IP</p>
<div class="controls">
<div class="form-control-static">
<div class="dont-break-out">
{{ documentoadministrativo.ip }}
</div>
</div>
</div>
</div>
</div>
{% endif %}
{% if documentoadministrativo.ultima_edicao %}
<div class="col-sm-4">
<div id="div_ud_user" class="form-group">
<p class="control-label">Data e Hora da Edição</p>
<div class="controls">
<div class="form-control-static">
<div class="dont-break-out">
{{ documentoadministrativo.ultima_edicao }}
</div>
</div>
</div>
</div>
</div>
{% endif %}
</div>
{% endif %}
{% endblock detail_content %}

24
sapl/templates/protocoloadm/tramitacaoadministrativo_detail.html

@ -20,13 +20,15 @@
{% if user.is_superuser %}
<div class="row">
{% if tramitacaoadministrativo.user %}
<div class="col-sm-6">
<div class="col-sm-4">
<div id="div_id_user" class="form-group">
<p class="control-label">Usuário</p>
<div class="controls">
<div class="form-control-static">
<div class="dont-break-out">
<a href="{% url 'sapl.base:user_edit' tramitacaoadministrativo.user.pk %}">{{tramitacaoadministrativo.user}}</a>
<a href="{% url 'sapl.base:user_edit' tramitacaoadministrativo.user.pk %}">
{{ tramitacaoadministrativo.user }}
</a>
</div>
</div>
</div>
@ -34,13 +36,27 @@
</div>
{% endif %}
{% if tramitacaoadministrativo.ip %}
<div class="col-sm-6">
<div class="col-sm-4">
<div id="div_ip_user" class="form-group">
<p class="control-label">IP</p>
<div class="controls">
<div class="form-control-static">
<div class="dont-break-out">
{{tramitacaoadministrativo.ip}}
{{ tramitacaoadministrativo.ip }}
</div>
</div>
</div>
</div>
</div>
{% endif %}
{% if tramitacaoadministrativo.ultima_edicao %}
<div class="col-sm-4">
<div id="div_ud_user" class="form-group">
<p class="control-label">Data e Hora da Edição</p>
<div class="controls">
<div class="form-control-static">
<div class="dont-break-out">
{{ tramitacaoadministrativo.ultima_edicao }}
</div>
</div>
</div>

Loading…
Cancel
Save