mirror of https://github.com/interlegis/sapl.git
Luciano Henrique Nunes de Almeida
8 years ago
committed by
GitHub
10 changed files with 223 additions and 75 deletions
@ -0,0 +1,51 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# Generated by Django 1.9.12 on 2017-03-31 19:00 |
||||
|
from __future__ import unicode_literals |
||||
|
|
||||
|
from django.db import migrations, models |
||||
|
import django.db.models.deletion |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('base', '0001_initial'), |
||||
|
] |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.CreateModel( |
||||
|
name='Argumento', |
||||
|
fields=[ |
||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), |
||||
|
('argumento', models.CharField(max_length=50, verbose_name='Argumento')), |
||||
|
], |
||||
|
options={ |
||||
|
'verbose_name': 'Argumento da constraint', |
||||
|
'verbose_name_plural': 'Argumentos da constraint', |
||||
|
}, |
||||
|
), |
||||
|
migrations.CreateModel( |
||||
|
name='Constraint', |
||||
|
fields=[ |
||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), |
||||
|
('nome_tabela', models.CharField(max_length=50, verbose_name='Nome da tabela')), |
||||
|
('nome_constraint', models.CharField(max_length=100, verbose_name='Nome da constraint')), |
||||
|
('nome_model', models.CharField(max_length=50, verbose_name='Nome da model')), |
||||
|
('tipo_constraint', models.CharField(max_length=50, verbose_name='Tipo da constraint')), |
||||
|
], |
||||
|
options={ |
||||
|
'verbose_name': 'Constraint removida', |
||||
|
'verbose_name_plural': 'Constraints removidas', |
||||
|
}, |
||||
|
), |
||||
|
migrations.AddField( |
||||
|
model_name='problemamigracao', |
||||
|
name='eh_importante', |
||||
|
field=models.BooleanField(default=False, verbose_name='É importante?'), |
||||
|
), |
||||
|
migrations.AddField( |
||||
|
model_name='argumento', |
||||
|
name='constraint', |
||||
|
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='base.Constraint'), |
||||
|
), |
||||
|
] |
@ -0,0 +1,12 @@ |
|||||
|
from django.core.management.base import BaseCommand |
||||
|
|
||||
|
from sapl.legacy.migration import recria_constraints |
||||
|
|
||||
|
|
||||
|
class Command(BaseCommand): |
||||
|
|
||||
|
help = (u'Recria constraints do PostgreSQL excluidas durante ' |
||||
|
'migração de dados') |
||||
|
|
||||
|
def handle(self, *args, **options): |
||||
|
recria_constraints() |
@ -1,28 +1,8 @@ |
|||||
from subprocess import PIPE, call |
|
||||
from threading import Thread |
|
||||
|
|
||||
from django.db.models.signals import post_delete, post_save |
from django.db.models.signals import post_delete, post_save |
||||
|
from sapl.utils import save_texto, delete_texto |
||||
from sapl.settings import PROJECT_DIR |
|
||||
|
|
||||
from .models import NormaJuridica |
from .models import NormaJuridica |
||||
|
|
||||
|
|
||||
class UpdateIndexCommand(Thread): |
|
||||
def run(self): |
|
||||
call([PROJECT_DIR.child('manage.py'), 'update_index'], |
|
||||
stdout=PIPE) |
|
||||
|
|
||||
|
|
||||
def save_texto(sender, instance, **kwargs): |
|
||||
update_index = UpdateIndexCommand() |
|
||||
update_index.start() |
|
||||
|
|
||||
|
|
||||
def delete_texto(sender, instance, **kwargs): |
|
||||
update_index = UpdateIndexCommand() |
|
||||
update_index.start() |
|
||||
|
|
||||
|
|
||||
post_save.connect(save_texto, sender=NormaJuridica) |
post_save.connect(save_texto, sender=NormaJuridica) |
||||
post_delete.connect(delete_texto, sender=NormaJuridica) |
post_delete.connect(delete_texto, sender=NormaJuridica) |
||||
|
Loading…
Reference in new issue