Browse Source

Adiciona data_ultima_atualizacao em Norma, MateriaLegislativa e DocumentoAcessorio (#1270)

Este campo permite que se se use o comando do haystack ./manage.py
update_index --age=2 para indexar somente os registros que foram
modificados nas ultimas duas horas.
pull/1276/head
Edward 8 years ago
committed by GitHub
parent
commit
aa77412623
  1. 9
      sapl/base/search_indexes.py
  2. 25
      sapl/materia/migrations/0009_auto_20170712_0951.py
  3. 10
      sapl/materia/models.py
  4. 20
      sapl/norma/migrations/0006_normajuridica_data_ultima_atualizacao.py
  5. 5
      sapl/norma/models.py

9
sapl/base/search_indexes.py

@ -28,6 +28,9 @@ class DocumentoAcessorioIndex(indexes.SearchIndex, indexes.Indexable):
def index_queryset(self, using=None):
return self.get_model().objects.all()
def get_updated_field(self):
return 'data_ultima_atualizacao'
def solr_extraction(self, arquivo):
extracted_data = self._get_backend(None).extract_file_contents(
arquivo)['contents']
@ -111,6 +114,9 @@ class MateriaLegislativaIndex(DocumentoAcessorioIndex):
model = MateriaLegislativa
template_name = 'materia/materialegislativa_text.txt'
def get_updated_field(self):
return 'data_ultima_atualizacao'
class NormaJuridicaIndex(DocumentoAcessorioIndex):
text = indexes.CharField(document=True, use_template=True)
@ -118,3 +124,6 @@ class NormaJuridicaIndex(DocumentoAcessorioIndex):
filename = 'texto_integral'
model = NormaJuridica
template_name = 'norma/normajuridica_text.txt'
def get_updated_field(self):
return 'data_ultima_atualizacao'

25
sapl/materia/migrations/0009_auto_20170712_0951.py

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.11 on 2017-07-12 09:51
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('materia', '0008_auto_20170622_1527'),
]
operations = [
migrations.AddField(
model_name='documentoacessorio',
name='data_ultima_atualizacao',
field=models.DateTimeField(auto_now=True, null=True, verbose_name='Data'),
),
migrations.AddField(
model_name='materialegislativa',
name='data_ultima_atualizacao',
field=models.DateTimeField(auto_now=True, null=True, verbose_name='Data'),
),
]

10
sapl/materia/models.py

@ -225,6 +225,11 @@ class MateriaLegislativa(models.Model):
through_fields=('materia', 'autor'),
symmetrical=False,)
data_ultima_atualizacao = models.DateTimeField(
blank=True, null=True,
auto_now=True,
verbose_name=_('Data'))
class Meta:
verbose_name = _('Matéria Legislativa')
verbose_name_plural = _('Matérias Legislativas')
@ -421,6 +426,11 @@ class DocumentoAcessorio(models.Model):
proposicao = GenericRelation(
'Proposicao', related_query_name='proposicao')
data_ultima_atualizacao = models.DateTimeField(
blank=True, null=True,
auto_now=True,
verbose_name=_('Data'))
class Meta:
verbose_name = _('Documento Acessório')
verbose_name_plural = _('Documentos Acessórios')

20
sapl/norma/migrations/0006_normajuridica_data_ultima_atualizacao.py

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.11 on 2017-07-12 09:51
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('norma', '0005_merge'),
]
operations = [
migrations.AddField(
model_name='normajuridica',
name='data_ultima_atualizacao',
field=models.DateTimeField(auto_now=True, null=True, verbose_name='Data'),
),
]

5
sapl/norma/models.py

@ -121,6 +121,11 @@ class NormaJuridica(models.Model):
texto_articulado = GenericRelation(
TextoArticulado, related_query_name='texto_articulado')
data_ultima_atualizacao = models.DateTimeField(
blank=True, null=True,
auto_now=True,
verbose_name=_('Data'))
class Meta:
verbose_name = _('Norma Jurídica')
verbose_name_plural = _('Normas Jurídicas')

Loading…
Cancel
Save