Browse Source

FIX #2221 (#2222)

* Fix #2221

* fix #2221
pull/2227/head
Mariana Mendes 6 years ago
committed by Edward
parent
commit
101dd2cd2e
  1. 21
      sapl/materia/migrations/0030_tramitacao_timestamp.py
  2. 3
      sapl/materia/models.py
  3. 3
      sapl/materia/views.py

21
sapl/materia/migrations/0030_tramitacao_timestamp.py

@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.13 on 2018-09-18 12:13
from __future__ import unicode_literals
from django.db import migrations, models
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('materia', '0029_auto_20180901_1628'),
]
operations = [
migrations.AddField(
model_name='tramitacao',
name='timestamp',
field=models.DateTimeField(default=django.utils.timezone.now),
),
]

3
sapl/materia/models.py

@ -908,6 +908,9 @@ class Tramitacao(models.Model):
null=True,
verbose_name=_('Status'))
materia = models.ForeignKey(MateriaLegislativa, on_delete=models.CASCADE)
# TODO: Remover os campos de data
# TODO: pois timestamp supre a necessidade
timestamp = models.DateTimeField(default=timezone.now)
data_tramitacao = models.DateField(verbose_name=_('Data Tramitação'))
unidade_tramitacao_local = models.ForeignKey(
UnidadeTramitacao,

3
sapl/materia/views.py

@ -1080,6 +1080,7 @@ class TramitacaoCrud(MasterDetailCrud):
ultima_tramitacao = Tramitacao.objects.filter(
materia_id=self.kwargs['pk']).order_by(
'-data_tramitacao',
'-timestamp',
'-id').first()
if ultima_tramitacao:
@ -1150,6 +1151,7 @@ class TramitacaoCrud(MasterDetailCrud):
qs = super(MasterDetailCrud.ListView, self).get_queryset()
kwargs = {self.crud.parent_field: self.kwargs['pk']}
return qs.filter(**kwargs).order_by('-data_tramitacao',
'-timestamp',
'-id')
class DeleteView(MasterDetailCrud.DeleteView):
@ -1162,6 +1164,7 @@ class TramitacaoCrud(MasterDetailCrud):
ultima_tramitacao = materia.tramitacao_set.order_by(
'-data_tramitacao',
'-timestamp',
'-id').first()
if tramitacao.pk != ultima_tramitacao.pk:

Loading…
Cancel
Save