mirror of https://github.com/interlegis/sapl.git
Browse Source
* Adicionar migração - deduplica protocolos * Fixes #615960 (OSTicket) * Corrigir erros * Refatoração * Adicionar correçãopull/2995/head
João Rodrigues
5 years ago
committed by
Cesar Carvalho
8 changed files with 71 additions and 40 deletions
@ -0,0 +1,25 @@ |
|||||
|
from __future__ import unicode_literals |
||||
|
|
||||
|
from django.db import migrations |
||||
|
|
||||
|
|
||||
|
def deduplica_protocolos(apps, schema_editor): |
||||
|
from sapl.base.views import protocolos_duplicados |
||||
|
|
||||
|
Protocolo = apps.get_model('protocoloadm', 'Protocolo') |
||||
|
|
||||
|
protocolos = protocolos_duplicados() |
||||
|
for protocolo in protocolos: |
||||
|
protocolo_principal = Protocolo.objects.filter(numero=protocolo['numero'], ano=protocolo['ano']).order_by('-id')[0] |
||||
|
Protocolo.objects.filter(numero=protocolo['numero'], ano=protocolo['ano']).exclude(id=protocolo_principal.id).delete() |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('protocoloadm', '0021_merge_20190429_1531'), |
||||
|
] |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.RunPython(deduplica_protocolos) |
||||
|
] |
@ -0,0 +1,19 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# Generated by Django 1.11.20 on 2019-07-11 20:55 |
||||
|
from __future__ import unicode_literals |
||||
|
|
||||
|
from django.db import migrations |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('protocoloadm', '0022_deduplica_protocolos'), |
||||
|
] |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.AlterUniqueTogether( |
||||
|
name='protocolo', |
||||
|
unique_together=set([('numero', 'ano')]), |
||||
|
), |
||||
|
] |
@ -0,0 +1,16 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# Generated by Django 1.11.20 on 2019-08-21 17:18 |
||||
|
from __future__ import unicode_literals |
||||
|
|
||||
|
from django.db import migrations |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('protocoloadm', '0023_auto_20190711_1755'), |
||||
|
('protocoloadm', '0023_merge_20190802_1112'), |
||||
|
] |
||||
|
|
||||
|
operations = [ |
||||
|
] |
Loading…
Reference in new issue