mirror of https://github.com/interlegis/sapl.git
Browse Source
Remove remoções de zeros a esquerda do número de norma Corrige testes de normapull/2770/head
6 changed files with 60 additions and 18 deletions
@ -0,0 +1,40 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# Generated by Django 1.11.20 on 2019-05-08 14:40 |
||||
|
from __future__ import unicode_literals |
||||
|
|
||||
|
import re |
||||
|
|
||||
|
import django.contrib.postgres.fields |
||||
|
from django.db import migrations, models |
||||
|
|
||||
|
|
||||
|
def cria_numero_pesquisa(apps, schema_editor): |
||||
|
NormaJuridica = apps.get_model('norma', 'NormaJuridica') |
||||
|
for norma in NormaJuridica.objects.all(): |
||||
|
norma.numero_pesquisa = list(map(lambda x: str(int(x)) if x.isnumeric() else x, re.split('\W+', norma.numero))) |
||||
|
norma.save() |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('norma', '0024_auto_20190425_0917'), |
||||
|
] |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.AddField( |
||||
|
model_name='normajuridica', |
||||
|
name='numero_pesquisa', |
||||
|
field=django.contrib.postgres.fields.ArrayField( |
||||
|
base_field=models.CharField(max_length=8, verbose_name='Número para Pesquisa'), default=[], size=8), |
||||
|
), |
||||
|
|
||||
|
migrations.RunPython(cria_numero_pesquisa), |
||||
|
|
||||
|
migrations.AlterField( |
||||
|
model_name='normajuridica', |
||||
|
name='numero_pesquisa', |
||||
|
field=django.contrib.postgres.fields.ArrayField( |
||||
|
base_field=models.CharField(max_length=8, verbose_name='Número para Pesquisa'), size=8), |
||||
|
), |
||||
|
] |
||||
Loading…
Reference in new issue